66502640f5af689db5dddaabed1f0fe5ae2b5ffe
[dotfiles/.git] / 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.6";
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 nullLogger = {
2118         logEvent: ts.noop,
2119         logErrEvent: ts.noop,
2120         logPerfEvent: ts.noop,
2121         logInfoEvent: ts.noop,
2122         logStartCommand: ts.noop,
2123         logStopCommand: ts.noop,
2124         logStartUpdateProgram: ts.noop,
2125         logStopUpdateProgram: ts.noop,
2126         logStartUpdateGraph: ts.noop,
2127         logStopUpdateGraph: ts.noop,
2128         logStartResolveModule: ts.noop,
2129         logStopResolveModule: ts.noop,
2130         logStartParseSourceFile: ts.noop,
2131         logStopParseSourceFile: ts.noop,
2132         logStartReadFile: ts.noop,
2133         logStopReadFile: ts.noop,
2134         logStartBindFile: ts.noop,
2135         logStopBindFile: ts.noop,
2136         logStartScheduledOperation: ts.noop,
2137         logStopScheduledOperation: ts.noop,
2138     };
2139     var etwModule;
2140     try {
2141         etwModule = require("@microsoft/typescript-etw");
2142     }
2143     catch (e) {
2144         etwModule = undefined;
2145     }
2146     ts.perfLogger = etwModule && etwModule.logEvent ? etwModule : nullLogger;
2147 })(ts || (ts = {}));
2148 var ts;
2149 (function (ts) {
2150     var versionRegExp = /^(0|[1-9]\d*)(?:\.(0|[1-9]\d*)(?:\.(0|[1-9]\d*)(?:\-([a-z0-9-.]+))?(?:\+([a-z0-9-.]+))?)?)?$/i;
2151     var prereleaseRegExp = /^(?:0|[1-9]\d*|[a-z-][a-z0-9-]*)(?:\.(?:0|[1-9]\d*|[a-z-][a-z0-9-]*))*$/i;
2152     var buildRegExp = /^[a-z0-9-]+(?:\.[a-z0-9-]+)*$/i;
2153     var numericIdentifierRegExp = /^(0|[1-9]\d*)$/;
2154     var Version = (function () {
2155         function Version(major, minor, patch, prerelease, build) {
2156             if (minor === void 0) { minor = 0; }
2157             if (patch === void 0) { patch = 0; }
2158             if (prerelease === void 0) { prerelease = ""; }
2159             if (build === void 0) { build = ""; }
2160             if (typeof major === "string") {
2161                 var result = ts.Debug.checkDefined(tryParseComponents(major), "Invalid version");
2162                 (major = result.major, minor = result.minor, patch = result.patch, prerelease = result.prerelease, build = result.build);
2163             }
2164             ts.Debug.assert(major >= 0, "Invalid argument: major");
2165             ts.Debug.assert(minor >= 0, "Invalid argument: minor");
2166             ts.Debug.assert(patch >= 0, "Invalid argument: patch");
2167             ts.Debug.assert(!prerelease || prereleaseRegExp.test(prerelease), "Invalid argument: prerelease");
2168             ts.Debug.assert(!build || buildRegExp.test(build), "Invalid argument: build");
2169             this.major = major;
2170             this.minor = minor;
2171             this.patch = patch;
2172             this.prerelease = prerelease ? prerelease.split(".") : ts.emptyArray;
2173             this.build = build ? build.split(".") : ts.emptyArray;
2174         }
2175         Version.tryParse = function (text) {
2176             var result = tryParseComponents(text);
2177             if (!result)
2178                 return undefined;
2179             var major = result.major, minor = result.minor, patch = result.patch, prerelease = result.prerelease, build = result.build;
2180             return new Version(major, minor, patch, prerelease, build);
2181         };
2182         Version.prototype.compareTo = function (other) {
2183             if (this === other)
2184                 return 0;
2185             if (other === undefined)
2186                 return 1;
2187             return ts.compareValues(this.major, other.major)
2188                 || ts.compareValues(this.minor, other.minor)
2189                 || ts.compareValues(this.patch, other.patch)
2190                 || comparePrerelaseIdentifiers(this.prerelease, other.prerelease);
2191         };
2192         Version.prototype.increment = function (field) {
2193             switch (field) {
2194                 case "major": return new Version(this.major + 1, 0, 0);
2195                 case "minor": return new Version(this.major, this.minor + 1, 0);
2196                 case "patch": return new Version(this.major, this.minor, this.patch + 1);
2197                 default: return ts.Debug.assertNever(field);
2198             }
2199         };
2200         Version.prototype.toString = function () {
2201             var result = this.major + "." + this.minor + "." + this.patch;
2202             if (ts.some(this.prerelease))
2203                 result += "-" + this.prerelease.join(".");
2204             if (ts.some(this.build))
2205                 result += "+" + this.build.join(".");
2206             return result;
2207         };
2208         Version.zero = new Version(0, 0, 0);
2209         return Version;
2210     }());
2211     ts.Version = Version;
2212     function tryParseComponents(text) {
2213         var match = versionRegExp.exec(text);
2214         if (!match)
2215             return undefined;
2216         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;
2217         if (prerelease && !prereleaseRegExp.test(prerelease))
2218             return undefined;
2219         if (build && !buildRegExp.test(build))
2220             return undefined;
2221         return {
2222             major: parseInt(major, 10),
2223             minor: parseInt(minor, 10),
2224             patch: parseInt(patch, 10),
2225             prerelease: prerelease,
2226             build: build
2227         };
2228     }
2229     function comparePrerelaseIdentifiers(left, right) {
2230         if (left === right)
2231             return 0;
2232         if (left.length === 0)
2233             return right.length === 0 ? 0 : 1;
2234         if (right.length === 0)
2235             return -1;
2236         var length = Math.min(left.length, right.length);
2237         for (var i = 0; i < length; i++) {
2238             var leftIdentifier = left[i];
2239             var rightIdentifier = right[i];
2240             if (leftIdentifier === rightIdentifier)
2241                 continue;
2242             var leftIsNumeric = numericIdentifierRegExp.test(leftIdentifier);
2243             var rightIsNumeric = numericIdentifierRegExp.test(rightIdentifier);
2244             if (leftIsNumeric || rightIsNumeric) {
2245                 if (leftIsNumeric !== rightIsNumeric)
2246                     return leftIsNumeric ? -1 : 1;
2247                 var result = ts.compareValues(+leftIdentifier, +rightIdentifier);
2248                 if (result)
2249                     return result;
2250             }
2251             else {
2252                 var result = ts.compareStringsCaseSensitive(leftIdentifier, rightIdentifier);
2253                 if (result)
2254                     return result;
2255             }
2256         }
2257         return ts.compareValues(left.length, right.length);
2258     }
2259     var VersionRange = (function () {
2260         function VersionRange(spec) {
2261             this._alternatives = spec ? ts.Debug.checkDefined(parseRange(spec), "Invalid range spec.") : ts.emptyArray;
2262         }
2263         VersionRange.tryParse = function (text) {
2264             var sets = parseRange(text);
2265             if (sets) {
2266                 var range = new VersionRange("");
2267                 range._alternatives = sets;
2268                 return range;
2269             }
2270             return undefined;
2271         };
2272         VersionRange.prototype.test = function (version) {
2273             if (typeof version === "string")
2274                 version = new Version(version);
2275             return testDisjunction(version, this._alternatives);
2276         };
2277         VersionRange.prototype.toString = function () {
2278             return formatDisjunction(this._alternatives);
2279         };
2280         return VersionRange;
2281     }());
2282     ts.VersionRange = VersionRange;
2283     var logicalOrRegExp = /\s*\|\|\s*/g;
2284     var whitespaceRegExp = /\s+/g;
2285     var partialRegExp = /^([xX*0]|[1-9]\d*)(?:\.([xX*0]|[1-9]\d*)(?:\.([xX*0]|[1-9]\d*)(?:-([a-z0-9-.]+))?(?:\+([a-z0-9-.]+))?)?)?$/i;
2286     var hyphenRegExp = /^\s*([a-z0-9-+.*]+)\s+-\s+([a-z0-9-+.*]+)\s*$/i;
2287     var rangeRegExp = /^\s*(~|\^|<|<=|>|>=|=)?\s*([a-z0-9-+.*]+)$/i;
2288     function parseRange(text) {
2289         var alternatives = [];
2290         for (var _i = 0, _a = text.trim().split(logicalOrRegExp); _i < _a.length; _i++) {
2291             var range = _a[_i];
2292             if (!range)
2293                 continue;
2294             var comparators = [];
2295             var match = hyphenRegExp.exec(range);
2296             if (match) {
2297                 if (!parseHyphen(match[1], match[2], comparators))
2298                     return undefined;
2299             }
2300             else {
2301                 for (var _b = 0, _c = range.split(whitespaceRegExp); _b < _c.length; _b++) {
2302                     var simple = _c[_b];
2303                     var match_1 = rangeRegExp.exec(simple);
2304                     if (!match_1 || !parseComparator(match_1[1], match_1[2], comparators))
2305                         return undefined;
2306                 }
2307             }
2308             alternatives.push(comparators);
2309         }
2310         return alternatives;
2311     }
2312     function parsePartial(text) {
2313         var match = partialRegExp.exec(text);
2314         if (!match)
2315             return undefined;
2316         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];
2317         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);
2318         return { version: version, major: major, minor: minor, patch: patch };
2319     }
2320     function parseHyphen(left, right, comparators) {
2321         var leftResult = parsePartial(left);
2322         if (!leftResult)
2323             return false;
2324         var rightResult = parsePartial(right);
2325         if (!rightResult)
2326             return false;
2327         if (!isWildcard(leftResult.major)) {
2328             comparators.push(createComparator(">=", leftResult.version));
2329         }
2330         if (!isWildcard(rightResult.major)) {
2331             comparators.push(isWildcard(rightResult.minor) ? createComparator("<", rightResult.version.increment("major")) :
2332                 isWildcard(rightResult.patch) ? createComparator("<", rightResult.version.increment("minor")) :
2333                     createComparator("<=", rightResult.version));
2334         }
2335         return true;
2336     }
2337     function parseComparator(operator, text, comparators) {
2338         var result = parsePartial(text);
2339         if (!result)
2340             return false;
2341         var version = result.version, major = result.major, minor = result.minor, patch = result.patch;
2342         if (!isWildcard(major)) {
2343             switch (operator) {
2344                 case "~":
2345                     comparators.push(createComparator(">=", version));
2346                     comparators.push(createComparator("<", version.increment(isWildcard(minor) ? "major" :
2347                         "minor")));
2348                     break;
2349                 case "^":
2350                     comparators.push(createComparator(">=", version));
2351                     comparators.push(createComparator("<", version.increment(version.major > 0 || isWildcard(minor) ? "major" :
2352                         version.minor > 0 || isWildcard(patch) ? "minor" :
2353                             "patch")));
2354                     break;
2355                 case "<":
2356                 case ">=":
2357                     comparators.push(createComparator(operator, version));
2358                     break;
2359                 case "<=":
2360                 case ">":
2361                     comparators.push(isWildcard(minor) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("major")) :
2362                         isWildcard(patch) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("minor")) :
2363                             createComparator(operator, version));
2364                     break;
2365                 case "=":
2366                 case undefined:
2367                     if (isWildcard(minor) || isWildcard(patch)) {
2368                         comparators.push(createComparator(">=", version));
2369                         comparators.push(createComparator("<", version.increment(isWildcard(minor) ? "major" : "minor")));
2370                     }
2371                     else {
2372                         comparators.push(createComparator("=", version));
2373                     }
2374                     break;
2375                 default:
2376                     return false;
2377             }
2378         }
2379         else if (operator === "<" || operator === ">") {
2380             comparators.push(createComparator("<", Version.zero));
2381         }
2382         return true;
2383     }
2384     function isWildcard(part) {
2385         return part === "*" || part === "x" || part === "X";
2386     }
2387     function createComparator(operator, operand) {
2388         return { operator: operator, operand: operand };
2389     }
2390     function testDisjunction(version, alternatives) {
2391         if (alternatives.length === 0)
2392             return true;
2393         for (var _i = 0, alternatives_1 = alternatives; _i < alternatives_1.length; _i++) {
2394             var alternative = alternatives_1[_i];
2395             if (testAlternative(version, alternative))
2396                 return true;
2397         }
2398         return false;
2399     }
2400     function testAlternative(version, comparators) {
2401         for (var _i = 0, comparators_1 = comparators; _i < comparators_1.length; _i++) {
2402             var comparator = comparators_1[_i];
2403             if (!testComparator(version, comparator.operator, comparator.operand))
2404                 return false;
2405         }
2406         return true;
2407     }
2408     function testComparator(version, operator, operand) {
2409         var cmp = version.compareTo(operand);
2410         switch (operator) {
2411             case "<": return cmp < 0;
2412             case "<=": return cmp <= 0;
2413             case ">": return cmp > 0;
2414             case ">=": return cmp >= 0;
2415             case "=": return cmp === 0;
2416             default: return ts.Debug.assertNever(operator);
2417         }
2418     }
2419     function formatDisjunction(alternatives) {
2420         return ts.map(alternatives, formatAlternative).join(" || ") || "*";
2421     }
2422     function formatAlternative(comparators) {
2423         return ts.map(comparators, formatComparator).join(" ");
2424     }
2425     function formatComparator(comparator) {
2426         return "" + comparator.operator + comparator.operand;
2427     }
2428 })(ts || (ts = {}));
2429 var ts;
2430 (function (ts) {
2431     var OperationCanceledException = (function () {
2432         function OperationCanceledException() {
2433         }
2434         return OperationCanceledException;
2435     }());
2436     ts.OperationCanceledException = OperationCanceledException;
2437     var RefFileKind;
2438     (function (RefFileKind) {
2439         RefFileKind[RefFileKind["Import"] = 0] = "Import";
2440         RefFileKind[RefFileKind["ReferenceFile"] = 1] = "ReferenceFile";
2441         RefFileKind[RefFileKind["TypeReferenceDirective"] = 2] = "TypeReferenceDirective";
2442     })(RefFileKind = ts.RefFileKind || (ts.RefFileKind = {}));
2443     var ExitStatus;
2444     (function (ExitStatus) {
2445         ExitStatus[ExitStatus["Success"] = 0] = "Success";
2446         ExitStatus[ExitStatus["DiagnosticsPresent_OutputsSkipped"] = 1] = "DiagnosticsPresent_OutputsSkipped";
2447         ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated";
2448         ExitStatus[ExitStatus["InvalidProject_OutputsSkipped"] = 3] = "InvalidProject_OutputsSkipped";
2449         ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkipped"] = 4] = "ProjectReferenceCycle_OutputsSkipped";
2450         ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkupped"] = 4] = "ProjectReferenceCycle_OutputsSkupped";
2451     })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {}));
2452     var TypeReferenceSerializationKind;
2453     (function (TypeReferenceSerializationKind) {
2454         TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown";
2455         TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue";
2456         TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidNullableOrNeverType"] = 2] = "VoidNullableOrNeverType";
2457         TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType";
2458         TypeReferenceSerializationKind[TypeReferenceSerializationKind["BigIntLikeType"] = 4] = "BigIntLikeType";
2459         TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 5] = "StringLikeType";
2460         TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 6] = "BooleanType";
2461         TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 7] = "ArrayLikeType";
2462         TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 8] = "ESSymbolType";
2463         TypeReferenceSerializationKind[TypeReferenceSerializationKind["Promise"] = 9] = "Promise";
2464         TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 10] = "TypeWithCallSignature";
2465         TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 11] = "ObjectType";
2466     })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {}));
2467     var DiagnosticCategory;
2468     (function (DiagnosticCategory) {
2469         DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning";
2470         DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error";
2471         DiagnosticCategory[DiagnosticCategory["Suggestion"] = 2] = "Suggestion";
2472         DiagnosticCategory[DiagnosticCategory["Message"] = 3] = "Message";
2473     })(DiagnosticCategory = ts.DiagnosticCategory || (ts.DiagnosticCategory = {}));
2474     function diagnosticCategoryName(d, lowerCase) {
2475         if (lowerCase === void 0) { lowerCase = true; }
2476         var name = DiagnosticCategory[d.category];
2477         return lowerCase ? name.toLowerCase() : name;
2478     }
2479     ts.diagnosticCategoryName = diagnosticCategoryName;
2480     var ModuleResolutionKind;
2481     (function (ModuleResolutionKind) {
2482         ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic";
2483         ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs";
2484     })(ModuleResolutionKind = ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {}));
2485     var WatchFileKind;
2486     (function (WatchFileKind) {
2487         WatchFileKind[WatchFileKind["FixedPollingInterval"] = 0] = "FixedPollingInterval";
2488         WatchFileKind[WatchFileKind["PriorityPollingInterval"] = 1] = "PriorityPollingInterval";
2489         WatchFileKind[WatchFileKind["DynamicPriorityPolling"] = 2] = "DynamicPriorityPolling";
2490         WatchFileKind[WatchFileKind["UseFsEvents"] = 3] = "UseFsEvents";
2491         WatchFileKind[WatchFileKind["UseFsEventsOnParentDirectory"] = 4] = "UseFsEventsOnParentDirectory";
2492     })(WatchFileKind = ts.WatchFileKind || (ts.WatchFileKind = {}));
2493     var WatchDirectoryKind;
2494     (function (WatchDirectoryKind) {
2495         WatchDirectoryKind[WatchDirectoryKind["UseFsEvents"] = 0] = "UseFsEvents";
2496         WatchDirectoryKind[WatchDirectoryKind["FixedPollingInterval"] = 1] = "FixedPollingInterval";
2497         WatchDirectoryKind[WatchDirectoryKind["DynamicPriorityPolling"] = 2] = "DynamicPriorityPolling";
2498     })(WatchDirectoryKind = ts.WatchDirectoryKind || (ts.WatchDirectoryKind = {}));
2499     var PollingWatchKind;
2500     (function (PollingWatchKind) {
2501         PollingWatchKind[PollingWatchKind["FixedInterval"] = 0] = "FixedInterval";
2502         PollingWatchKind[PollingWatchKind["PriorityInterval"] = 1] = "PriorityInterval";
2503         PollingWatchKind[PollingWatchKind["DynamicPriority"] = 2] = "DynamicPriority";
2504     })(PollingWatchKind = ts.PollingWatchKind || (ts.PollingWatchKind = {}));
2505     var ModuleKind;
2506     (function (ModuleKind) {
2507         ModuleKind[ModuleKind["None"] = 0] = "None";
2508         ModuleKind[ModuleKind["CommonJS"] = 1] = "CommonJS";
2509         ModuleKind[ModuleKind["AMD"] = 2] = "AMD";
2510         ModuleKind[ModuleKind["UMD"] = 3] = "UMD";
2511         ModuleKind[ModuleKind["System"] = 4] = "System";
2512         ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015";
2513         ModuleKind[ModuleKind["ES2020"] = 6] = "ES2020";
2514         ModuleKind[ModuleKind["ESNext"] = 99] = "ESNext";
2515     })(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {}));
2516     ts.commentPragmas = {
2517         "reference": {
2518             args: [
2519                 { name: "types", optional: true, captureSpan: true },
2520                 { name: "lib", optional: true, captureSpan: true },
2521                 { name: "path", optional: true, captureSpan: true },
2522                 { name: "no-default-lib", optional: true }
2523             ],
2524             kind: 1
2525         },
2526         "amd-dependency": {
2527             args: [{ name: "path" }, { name: "name", optional: true }],
2528             kind: 1
2529         },
2530         "amd-module": {
2531             args: [{ name: "name" }],
2532             kind: 1
2533         },
2534         "ts-check": {
2535             kind: 2
2536         },
2537         "ts-nocheck": {
2538             kind: 2
2539         },
2540         "jsx": {
2541             args: [{ name: "factory" }],
2542             kind: 4
2543         },
2544     };
2545 })(ts || (ts = {}));
2546 var ts;
2547 (function (ts) {
2548     function generateDjb2Hash(data) {
2549         var acc = 5381;
2550         for (var i = 0; i < data.length; i++) {
2551             acc = ((acc << 5) + acc) + data.charCodeAt(i);
2552         }
2553         return acc.toString();
2554     }
2555     ts.generateDjb2Hash = generateDjb2Hash;
2556     function setStackTraceLimit() {
2557         if (Error.stackTraceLimit < 100) {
2558             Error.stackTraceLimit = 100;
2559         }
2560     }
2561     ts.setStackTraceLimit = setStackTraceLimit;
2562     var FileWatcherEventKind;
2563     (function (FileWatcherEventKind) {
2564         FileWatcherEventKind[FileWatcherEventKind["Created"] = 0] = "Created";
2565         FileWatcherEventKind[FileWatcherEventKind["Changed"] = 1] = "Changed";
2566         FileWatcherEventKind[FileWatcherEventKind["Deleted"] = 2] = "Deleted";
2567     })(FileWatcherEventKind = ts.FileWatcherEventKind || (ts.FileWatcherEventKind = {}));
2568     var PollingInterval;
2569     (function (PollingInterval) {
2570         PollingInterval[PollingInterval["High"] = 2000] = "High";
2571         PollingInterval[PollingInterval["Medium"] = 500] = "Medium";
2572         PollingInterval[PollingInterval["Low"] = 250] = "Low";
2573     })(PollingInterval = ts.PollingInterval || (ts.PollingInterval = {}));
2574     ts.missingFileModifiedTime = new Date(0);
2575     function createPollingIntervalBasedLevels(levels) {
2576         var _a;
2577         return _a = {},
2578             _a[PollingInterval.Low] = levels.Low,
2579             _a[PollingInterval.Medium] = levels.Medium,
2580             _a[PollingInterval.High] = levels.High,
2581             _a;
2582     }
2583     var defaultChunkLevels = { Low: 32, Medium: 64, High: 256 };
2584     var pollingChunkSize = createPollingIntervalBasedLevels(defaultChunkLevels);
2585     ts.unchangedPollThresholds = createPollingIntervalBasedLevels(defaultChunkLevels);
2586     function setCustomPollingValues(system) {
2587         if (!system.getEnvironmentVariable) {
2588             return;
2589         }
2590         var pollingIntervalChanged = setCustomLevels("TSC_WATCH_POLLINGINTERVAL", PollingInterval);
2591         pollingChunkSize = getCustomPollingBasedLevels("TSC_WATCH_POLLINGCHUNKSIZE", defaultChunkLevels) || pollingChunkSize;
2592         ts.unchangedPollThresholds = getCustomPollingBasedLevels("TSC_WATCH_UNCHANGEDPOLLTHRESHOLDS", defaultChunkLevels) || ts.unchangedPollThresholds;
2593         function getLevel(envVar, level) {
2594             return system.getEnvironmentVariable(envVar + "_" + level.toUpperCase());
2595         }
2596         function getCustomLevels(baseVariable) {
2597             var customLevels;
2598             setCustomLevel("Low");
2599             setCustomLevel("Medium");
2600             setCustomLevel("High");
2601             return customLevels;
2602             function setCustomLevel(level) {
2603                 var customLevel = getLevel(baseVariable, level);
2604                 if (customLevel) {
2605                     (customLevels || (customLevels = {}))[level] = Number(customLevel);
2606                 }
2607             }
2608         }
2609         function setCustomLevels(baseVariable, levels) {
2610             var customLevels = getCustomLevels(baseVariable);
2611             if (customLevels) {
2612                 setLevel("Low");
2613                 setLevel("Medium");
2614                 setLevel("High");
2615                 return true;
2616             }
2617             return false;
2618             function setLevel(level) {
2619                 levels[level] = customLevels[level] || levels[level];
2620             }
2621         }
2622         function getCustomPollingBasedLevels(baseVariable, defaultLevels) {
2623             var customLevels = getCustomLevels(baseVariable);
2624             return (pollingIntervalChanged || customLevels) &&
2625                 createPollingIntervalBasedLevels(customLevels ? __assign(__assign({}, defaultLevels), customLevels) : defaultLevels);
2626         }
2627     }
2628     ts.setCustomPollingValues = setCustomPollingValues;
2629     function createDynamicPriorityPollingWatchFile(host) {
2630         var watchedFiles = [];
2631         var changedFilesInLastPoll = [];
2632         var lowPollingIntervalQueue = createPollingIntervalQueue(PollingInterval.Low);
2633         var mediumPollingIntervalQueue = createPollingIntervalQueue(PollingInterval.Medium);
2634         var highPollingIntervalQueue = createPollingIntervalQueue(PollingInterval.High);
2635         return watchFile;
2636         function watchFile(fileName, callback, defaultPollingInterval) {
2637             var file = {
2638                 fileName: fileName,
2639                 callback: callback,
2640                 unchangedPolls: 0,
2641                 mtime: getModifiedTime(fileName)
2642             };
2643             watchedFiles.push(file);
2644             addToPollingIntervalQueue(file, defaultPollingInterval);
2645             return {
2646                 close: function () {
2647                     file.isClosed = true;
2648                     ts.unorderedRemoveItem(watchedFiles, file);
2649                 }
2650             };
2651         }
2652         function createPollingIntervalQueue(pollingInterval) {
2653             var queue = [];
2654             queue.pollingInterval = pollingInterval;
2655             queue.pollIndex = 0;
2656             queue.pollScheduled = false;
2657             return queue;
2658         }
2659         function pollPollingIntervalQueue(queue) {
2660             queue.pollIndex = pollQueue(queue, queue.pollingInterval, queue.pollIndex, pollingChunkSize[queue.pollingInterval]);
2661             if (queue.length) {
2662                 scheduleNextPoll(queue.pollingInterval);
2663             }
2664             else {
2665                 ts.Debug.assert(queue.pollIndex === 0);
2666                 queue.pollScheduled = false;
2667             }
2668         }
2669         function pollLowPollingIntervalQueue(queue) {
2670             pollQueue(changedFilesInLastPoll, PollingInterval.Low, 0, changedFilesInLastPoll.length);
2671             pollPollingIntervalQueue(queue);
2672             if (!queue.pollScheduled && changedFilesInLastPoll.length) {
2673                 scheduleNextPoll(PollingInterval.Low);
2674             }
2675         }
2676         function pollQueue(queue, pollingInterval, pollIndex, chunkSize) {
2677             var needsVisit = queue.length;
2678             var definedValueCopyToIndex = pollIndex;
2679             for (var polled = 0; polled < chunkSize && needsVisit > 0; nextPollIndex(), needsVisit--) {
2680                 var watchedFile = queue[pollIndex];
2681                 if (!watchedFile) {
2682                     continue;
2683                 }
2684                 else if (watchedFile.isClosed) {
2685                     queue[pollIndex] = undefined;
2686                     continue;
2687                 }
2688                 polled++;
2689                 var fileChanged = onWatchedFileStat(watchedFile, getModifiedTime(watchedFile.fileName));
2690                 if (watchedFile.isClosed) {
2691                     queue[pollIndex] = undefined;
2692                 }
2693                 else if (fileChanged) {
2694                     watchedFile.unchangedPolls = 0;
2695                     if (queue !== changedFilesInLastPoll) {
2696                         queue[pollIndex] = undefined;
2697                         addChangedFileToLowPollingIntervalQueue(watchedFile);
2698                     }
2699                 }
2700                 else if (watchedFile.unchangedPolls !== ts.unchangedPollThresholds[pollingInterval]) {
2701                     watchedFile.unchangedPolls++;
2702                 }
2703                 else if (queue === changedFilesInLastPoll) {
2704                     watchedFile.unchangedPolls = 1;
2705                     queue[pollIndex] = undefined;
2706                     addToPollingIntervalQueue(watchedFile, PollingInterval.Low);
2707                 }
2708                 else if (pollingInterval !== PollingInterval.High) {
2709                     watchedFile.unchangedPolls++;
2710                     queue[pollIndex] = undefined;
2711                     addToPollingIntervalQueue(watchedFile, pollingInterval === PollingInterval.Low ? PollingInterval.Medium : PollingInterval.High);
2712                 }
2713                 if (queue[pollIndex]) {
2714                     if (definedValueCopyToIndex < pollIndex) {
2715                         queue[definedValueCopyToIndex] = watchedFile;
2716                         queue[pollIndex] = undefined;
2717                     }
2718                     definedValueCopyToIndex++;
2719                 }
2720             }
2721             return pollIndex;
2722             function nextPollIndex() {
2723                 pollIndex++;
2724                 if (pollIndex === queue.length) {
2725                     if (definedValueCopyToIndex < pollIndex) {
2726                         queue.length = definedValueCopyToIndex;
2727                     }
2728                     pollIndex = 0;
2729                     definedValueCopyToIndex = 0;
2730                 }
2731             }
2732         }
2733         function pollingIntervalQueue(pollingInterval) {
2734             switch (pollingInterval) {
2735                 case PollingInterval.Low:
2736                     return lowPollingIntervalQueue;
2737                 case PollingInterval.Medium:
2738                     return mediumPollingIntervalQueue;
2739                 case PollingInterval.High:
2740                     return highPollingIntervalQueue;
2741             }
2742         }
2743         function addToPollingIntervalQueue(file, pollingInterval) {
2744             pollingIntervalQueue(pollingInterval).push(file);
2745             scheduleNextPollIfNotAlreadyScheduled(pollingInterval);
2746         }
2747         function addChangedFileToLowPollingIntervalQueue(file) {
2748             changedFilesInLastPoll.push(file);
2749             scheduleNextPollIfNotAlreadyScheduled(PollingInterval.Low);
2750         }
2751         function scheduleNextPollIfNotAlreadyScheduled(pollingInterval) {
2752             if (!pollingIntervalQueue(pollingInterval).pollScheduled) {
2753                 scheduleNextPoll(pollingInterval);
2754             }
2755         }
2756         function scheduleNextPoll(pollingInterval) {
2757             pollingIntervalQueue(pollingInterval).pollScheduled = host.setTimeout(pollingInterval === PollingInterval.Low ? pollLowPollingIntervalQueue : pollPollingIntervalQueue, pollingInterval, pollingIntervalQueue(pollingInterval));
2758         }
2759         function getModifiedTime(fileName) {
2760             return host.getModifiedTime(fileName) || ts.missingFileModifiedTime;
2761         }
2762     }
2763     ts.createDynamicPriorityPollingWatchFile = createDynamicPriorityPollingWatchFile;
2764     function createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames) {
2765         var fileWatcherCallbacks = ts.createMultiMap();
2766         var dirWatchers = ts.createMap();
2767         var toCanonicalName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
2768         return nonPollingWatchFile;
2769         function nonPollingWatchFile(fileName, callback, _pollingInterval, fallbackOptions) {
2770             var filePath = toCanonicalName(fileName);
2771             fileWatcherCallbacks.add(filePath, callback);
2772             var dirPath = ts.getDirectoryPath(filePath) || ".";
2773             var watcher = dirWatchers.get(dirPath) ||
2774                 createDirectoryWatcher(ts.getDirectoryPath(fileName) || ".", dirPath, fallbackOptions);
2775             watcher.referenceCount++;
2776             return {
2777                 close: function () {
2778                     if (watcher.referenceCount === 1) {
2779                         watcher.close();
2780                         dirWatchers.delete(dirPath);
2781                     }
2782                     else {
2783                         watcher.referenceCount--;
2784                     }
2785                     fileWatcherCallbacks.remove(filePath, callback);
2786                 }
2787             };
2788         }
2789         function createDirectoryWatcher(dirName, dirPath, fallbackOptions) {
2790             var watcher = fsWatch(dirName, 1, function (_eventName, relativeFileName) {
2791                 if (!ts.isString(relativeFileName)) {
2792                     return;
2793                 }
2794                 var fileName = ts.getNormalizedAbsolutePath(relativeFileName, dirName);
2795                 var callbacks = fileName && fileWatcherCallbacks.get(toCanonicalName(fileName));
2796                 if (callbacks) {
2797                     for (var _i = 0, callbacks_1 = callbacks; _i < callbacks_1.length; _i++) {
2798                         var fileCallback = callbacks_1[_i];
2799                         fileCallback(fileName, FileWatcherEventKind.Changed);
2800                     }
2801                 }
2802             }, false, PollingInterval.Medium, fallbackOptions);
2803             watcher.referenceCount = 0;
2804             dirWatchers.set(dirPath, watcher);
2805             return watcher;
2806         }
2807     }
2808     function createSingleFileWatcherPerName(watchFile, useCaseSensitiveFileNames) {
2809         var cache = ts.createMap();
2810         var callbacksCache = ts.createMultiMap();
2811         var toCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
2812         return function (fileName, callback, pollingInterval, options) {
2813             var path = toCanonicalFileName(fileName);
2814             var existing = cache.get(path);
2815             if (existing) {
2816                 existing.refCount++;
2817             }
2818             else {
2819                 cache.set(path, {
2820                     watcher: watchFile(fileName, function (fileName, eventKind) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind); }); }, pollingInterval, options),
2821                     refCount: 1
2822                 });
2823             }
2824             callbacksCache.add(path, callback);
2825             return {
2826                 close: function () {
2827                     var watcher = ts.Debug.checkDefined(cache.get(path));
2828                     callbacksCache.remove(path, callback);
2829                     watcher.refCount--;
2830                     if (watcher.refCount)
2831                         return;
2832                     cache.delete(path);
2833                     ts.closeFileWatcherOf(watcher);
2834                 }
2835             };
2836         };
2837     }
2838     ts.createSingleFileWatcherPerName = createSingleFileWatcherPerName;
2839     function onWatchedFileStat(watchedFile, modifiedTime) {
2840         var oldTime = watchedFile.mtime.getTime();
2841         var newTime = modifiedTime.getTime();
2842         if (oldTime !== newTime) {
2843             watchedFile.mtime = modifiedTime;
2844             watchedFile.callback(watchedFile.fileName, getFileWatcherEventKind(oldTime, newTime));
2845             return true;
2846         }
2847         return false;
2848     }
2849     ts.onWatchedFileStat = onWatchedFileStat;
2850     function getFileWatcherEventKind(oldTime, newTime) {
2851         return oldTime === 0
2852             ? FileWatcherEventKind.Created
2853             : newTime === 0
2854                 ? FileWatcherEventKind.Deleted
2855                 : FileWatcherEventKind.Changed;
2856     }
2857     ts.getFileWatcherEventKind = getFileWatcherEventKind;
2858     ts.ignoredPaths = ["/node_modules/.", "/.git", "/.#"];
2859     ts.sysLog = ts.noop;
2860     function setSysLog(logger) {
2861         ts.sysLog = logger;
2862     }
2863     ts.setSysLog = setSysLog;
2864     function createDirectoryWatcherSupportingRecursive(host) {
2865         var cache = ts.createMap();
2866         var callbackCache = ts.createMultiMap();
2867         var cacheToUpdateChildWatches = ts.createMap();
2868         var timerToUpdateChildWatches;
2869         var filePathComparer = ts.getStringComparer(!host.useCaseSensitiveFileNames);
2870         var toCanonicalFilePath = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames);
2871         return function (dirName, callback, recursive, options) { return recursive ?
2872             createDirectoryWatcher(dirName, options, callback) :
2873             host.watchDirectory(dirName, callback, recursive, options); };
2874         function createDirectoryWatcher(dirName, options, callback) {
2875             var dirPath = toCanonicalFilePath(dirName);
2876             var directoryWatcher = cache.get(dirPath);
2877             if (directoryWatcher) {
2878                 directoryWatcher.refCount++;
2879             }
2880             else {
2881                 directoryWatcher = {
2882                     watcher: host.watchDirectory(dirName, function (fileName) {
2883                         if (isIgnoredPath(fileName))
2884                             return;
2885                         if (options === null || options === void 0 ? void 0 : options.synchronousWatchDirectory) {
2886                             invokeCallbacks(dirPath, fileName);
2887                             updateChildWatches(dirName, dirPath, options);
2888                         }
2889                         else {
2890                             nonSyncUpdateChildWatches(dirName, dirPath, fileName, options);
2891                         }
2892                     }, false, options),
2893                     refCount: 1,
2894                     childWatches: ts.emptyArray
2895                 };
2896                 cache.set(dirPath, directoryWatcher);
2897                 updateChildWatches(dirName, dirPath, options);
2898             }
2899             var callbackToAdd = callback && { dirName: dirName, callback: callback };
2900             if (callbackToAdd) {
2901                 callbackCache.add(dirPath, callbackToAdd);
2902             }
2903             return {
2904                 dirName: dirName,
2905                 close: function () {
2906                     var directoryWatcher = ts.Debug.checkDefined(cache.get(dirPath));
2907                     if (callbackToAdd)
2908                         callbackCache.remove(dirPath, callbackToAdd);
2909                     directoryWatcher.refCount--;
2910                     if (directoryWatcher.refCount)
2911                         return;
2912                     cache.delete(dirPath);
2913                     ts.closeFileWatcherOf(directoryWatcher);
2914                     directoryWatcher.childWatches.forEach(ts.closeFileWatcher);
2915                 }
2916             };
2917         }
2918         function invokeCallbacks(dirPath, fileNameOrInvokeMap) {
2919             var fileName;
2920             var invokeMap;
2921             if (ts.isString(fileNameOrInvokeMap)) {
2922                 fileName = fileNameOrInvokeMap;
2923             }
2924             else {
2925                 invokeMap = fileNameOrInvokeMap;
2926             }
2927             callbackCache.forEach(function (callbacks, rootDirName) {
2928                 if (invokeMap && invokeMap.has(rootDirName))
2929                     return;
2930                 if (rootDirName === dirPath || (ts.startsWith(dirPath, rootDirName) && dirPath[rootDirName.length] === ts.directorySeparator)) {
2931                     if (invokeMap) {
2932                         invokeMap.set(rootDirName, true);
2933                     }
2934                     else {
2935                         callbacks.forEach(function (_a) {
2936                             var callback = _a.callback;
2937                             return callback(fileName);
2938                         });
2939                     }
2940                 }
2941             });
2942         }
2943         function nonSyncUpdateChildWatches(dirName, dirPath, fileName, options) {
2944             var parentWatcher = cache.get(dirPath);
2945             if (parentWatcher && host.directoryExists(dirName)) {
2946                 scheduleUpdateChildWatches(dirName, dirPath, options);
2947                 return;
2948             }
2949             invokeCallbacks(dirPath, fileName);
2950             removeChildWatches(parentWatcher);
2951         }
2952         function scheduleUpdateChildWatches(dirName, dirPath, options) {
2953             if (!cacheToUpdateChildWatches.has(dirPath)) {
2954                 cacheToUpdateChildWatches.set(dirPath, { dirName: dirName, options: options });
2955             }
2956             if (timerToUpdateChildWatches) {
2957                 host.clearTimeout(timerToUpdateChildWatches);
2958                 timerToUpdateChildWatches = undefined;
2959             }
2960             timerToUpdateChildWatches = host.setTimeout(onTimerToUpdateChildWatches, 1000);
2961         }
2962         function onTimerToUpdateChildWatches() {
2963             timerToUpdateChildWatches = undefined;
2964             ts.sysLog("sysLog:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size);
2965             var start = ts.timestamp();
2966             var invokeMap = ts.createMap();
2967             while (!timerToUpdateChildWatches && cacheToUpdateChildWatches.size) {
2968                 var _a = cacheToUpdateChildWatches.entries().next(), _b = _a.value, dirPath = _b[0], _c = _b[1], dirName = _c.dirName, options = _c.options, done = _a.done;
2969                 ts.Debug.assert(!done);
2970                 cacheToUpdateChildWatches.delete(dirPath);
2971                 invokeCallbacks(dirPath, invokeMap);
2972                 updateChildWatches(dirName, dirPath, options);
2973             }
2974             ts.sysLog("sysLog:: invokingWatchers:: " + (ts.timestamp() - start) + "ms:: " + cacheToUpdateChildWatches.size);
2975             callbackCache.forEach(function (callbacks, rootDirName) {
2976                 if (invokeMap.has(rootDirName)) {
2977                     callbacks.forEach(function (_a) {
2978                         var callback = _a.callback, dirName = _a.dirName;
2979                         return callback(dirName);
2980                     });
2981                 }
2982             });
2983             var elapsed = ts.timestamp() - start;
2984             ts.sysLog("sysLog:: Elapsed " + elapsed + "ms:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size + " " + timerToUpdateChildWatches);
2985         }
2986         function removeChildWatches(parentWatcher) {
2987             if (!parentWatcher)
2988                 return;
2989             var existingChildWatches = parentWatcher.childWatches;
2990             parentWatcher.childWatches = ts.emptyArray;
2991             for (var _i = 0, existingChildWatches_1 = existingChildWatches; _i < existingChildWatches_1.length; _i++) {
2992                 var childWatcher = existingChildWatches_1[_i];
2993                 childWatcher.close();
2994                 removeChildWatches(cache.get(toCanonicalFilePath(childWatcher.dirName)));
2995             }
2996         }
2997         function updateChildWatches(dirName, dirPath, options) {
2998             var parentWatcher = cache.get(dirPath);
2999             if (parentWatcher) {
3000                 parentWatcher.childWatches = watchChildDirectories(dirName, parentWatcher.childWatches, options);
3001             }
3002         }
3003         function watchChildDirectories(parentDir, existingChildWatches, options) {
3004             var newChildWatches;
3005             ts.enumerateInsertsAndDeletes(host.directoryExists(parentDir) ? ts.mapDefined(host.getAccessibleSortedChildDirectories(parentDir), function (child) {
3006                 var childFullName = ts.getNormalizedAbsolutePath(child, parentDir);
3007                 return !isIgnoredPath(childFullName) && filePathComparer(childFullName, ts.normalizePath(host.realpath(childFullName))) === 0 ? childFullName : undefined;
3008             }) : ts.emptyArray, existingChildWatches, function (child, childWatcher) { return filePathComparer(child, childWatcher.dirName); }, createAndAddChildDirectoryWatcher, ts.closeFileWatcher, addChildDirectoryWatcher);
3009             return newChildWatches || ts.emptyArray;
3010             function createAndAddChildDirectoryWatcher(childName) {
3011                 var result = createDirectoryWatcher(childName, options);
3012                 addChildDirectoryWatcher(result);
3013             }
3014             function addChildDirectoryWatcher(childWatcher) {
3015                 (newChildWatches || (newChildWatches = [])).push(childWatcher);
3016             }
3017         }
3018         function isIgnoredPath(path) {
3019             return ts.some(ts.ignoredPaths, function (searchPath) { return isInPath(path, searchPath); });
3020         }
3021         function isInPath(path, searchPath) {
3022             if (ts.stringContains(path, searchPath))
3023                 return true;
3024             if (host.useCaseSensitiveFileNames)
3025                 return false;
3026             return ts.stringContains(toCanonicalFilePath(path), searchPath);
3027         }
3028     }
3029     ts.createDirectoryWatcherSupportingRecursive = createDirectoryWatcherSupportingRecursive;
3030     function createFileWatcherCallback(callback) {
3031         return function (_fileName, eventKind) { return callback(eventKind === FileWatcherEventKind.Changed ? "change" : "rename", ""); };
3032     }
3033     ts.createFileWatcherCallback = createFileWatcherCallback;
3034     function createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists) {
3035         return function (eventName) {
3036             if (eventName === "rename") {
3037                 callback(fileName, fileExists(fileName) ? FileWatcherEventKind.Created : FileWatcherEventKind.Deleted);
3038             }
3039             else {
3040                 callback(fileName, FileWatcherEventKind.Changed);
3041             }
3042         };
3043     }
3044     function createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback) {
3045         return function (eventName, relativeFileName) {
3046             if (eventName === "rename") {
3047                 callback(!relativeFileName ? directoryName : ts.normalizePath(ts.combinePaths(directoryName, relativeFileName)));
3048             }
3049         };
3050     }
3051     function createSystemWatchFunctions(_a) {
3052         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;
3053         var dynamicPollingWatchFile;
3054         var nonPollingWatchFile;
3055         var hostRecursiveDirectoryWatcher;
3056         return {
3057             watchFile: watchFile,
3058             watchDirectory: watchDirectory
3059         };
3060         function watchFile(fileName, callback, pollingInterval, options) {
3061             options = updateOptionsForWatchFile(options, useNonPollingWatchers);
3062             var watchFileKind = ts.Debug.checkDefined(options.watchFile);
3063             switch (watchFileKind) {
3064                 case ts.WatchFileKind.FixedPollingInterval:
3065                     return pollingWatchFile(fileName, callback, PollingInterval.Low, undefined);
3066                 case ts.WatchFileKind.PriorityPollingInterval:
3067                     return pollingWatchFile(fileName, callback, pollingInterval, undefined);
3068                 case ts.WatchFileKind.DynamicPriorityPolling:
3069                     return ensureDynamicPollingWatchFile()(fileName, callback, pollingInterval, undefined);
3070                 case ts.WatchFileKind.UseFsEvents:
3071                     return fsWatch(fileName, 0, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists), false, pollingInterval, ts.getFallbackOptions(options));
3072                 case ts.WatchFileKind.UseFsEventsOnParentDirectory:
3073                     if (!nonPollingWatchFile) {
3074                         nonPollingWatchFile = createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames);
3075                     }
3076                     return nonPollingWatchFile(fileName, callback, pollingInterval, ts.getFallbackOptions(options));
3077                 default:
3078                     ts.Debug.assertNever(watchFileKind);
3079             }
3080         }
3081         function ensureDynamicPollingWatchFile() {
3082             return dynamicPollingWatchFile ||
3083                 (dynamicPollingWatchFile = createDynamicPriorityPollingWatchFile({ getModifiedTime: getModifiedTime, setTimeout: setTimeout }));
3084         }
3085         function updateOptionsForWatchFile(options, useNonPollingWatchers) {
3086             if (options && options.watchFile !== undefined)
3087                 return options;
3088             switch (tscWatchFile) {
3089                 case "PriorityPollingInterval":
3090                     return { watchFile: ts.WatchFileKind.PriorityPollingInterval };
3091                 case "DynamicPriorityPolling":
3092                     return { watchFile: ts.WatchFileKind.DynamicPriorityPolling };
3093                 case "UseFsEvents":
3094                     return generateWatchFileOptions(ts.WatchFileKind.UseFsEvents, ts.PollingWatchKind.PriorityInterval, options);
3095                 case "UseFsEventsWithFallbackDynamicPolling":
3096                     return generateWatchFileOptions(ts.WatchFileKind.UseFsEvents, ts.PollingWatchKind.DynamicPriority, options);
3097                 case "UseFsEventsOnParentDirectory":
3098                     useNonPollingWatchers = true;
3099                 default:
3100                     return useNonPollingWatchers ?
3101                         generateWatchFileOptions(ts.WatchFileKind.UseFsEventsOnParentDirectory, ts.PollingWatchKind.PriorityInterval, options) :
3102                         { watchFile: ts.WatchFileKind.FixedPollingInterval };
3103             }
3104         }
3105         function generateWatchFileOptions(watchFile, fallbackPolling, options) {
3106             var defaultFallbackPolling = options === null || options === void 0 ? void 0 : options.fallbackPolling;
3107             return {
3108                 watchFile: watchFile,
3109                 fallbackPolling: defaultFallbackPolling === undefined ?
3110                     fallbackPolling :
3111                     defaultFallbackPolling
3112             };
3113         }
3114         function watchDirectory(directoryName, callback, recursive, options) {
3115             if (fsSupportsRecursiveFsWatch) {
3116                 return fsWatch(directoryName, 1, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback), recursive, PollingInterval.Medium, ts.getFallbackOptions(options));
3117             }
3118             if (!hostRecursiveDirectoryWatcher) {
3119                 hostRecursiveDirectoryWatcher = createDirectoryWatcherSupportingRecursive({
3120                     useCaseSensitiveFileNames: useCaseSensitiveFileNames,
3121                     directoryExists: directoryExists,
3122                     getAccessibleSortedChildDirectories: getAccessibleSortedChildDirectories,
3123                     watchDirectory: nonRecursiveWatchDirectory,
3124                     realpath: realpath,
3125                     setTimeout: setTimeout,
3126                     clearTimeout: clearTimeout
3127                 });
3128             }
3129             return hostRecursiveDirectoryWatcher(directoryName, callback, recursive, options);
3130         }
3131         function nonRecursiveWatchDirectory(directoryName, callback, recursive, options) {
3132             ts.Debug.assert(!recursive);
3133             options = updateOptionsForWatchDirectory(options);
3134             var watchDirectoryKind = ts.Debug.checkDefined(options.watchDirectory);
3135             switch (watchDirectoryKind) {
3136                 case ts.WatchDirectoryKind.FixedPollingInterval:
3137                     return pollingWatchFile(directoryName, function () { return callback(directoryName); }, PollingInterval.Medium, undefined);
3138                 case ts.WatchDirectoryKind.DynamicPriorityPolling:
3139                     return ensureDynamicPollingWatchFile()(directoryName, function () { return callback(directoryName); }, PollingInterval.Medium, undefined);
3140                 case ts.WatchDirectoryKind.UseFsEvents:
3141                     return fsWatch(directoryName, 1, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback), recursive, PollingInterval.Medium, ts.getFallbackOptions(options));
3142                 default:
3143                     ts.Debug.assertNever(watchDirectoryKind);
3144             }
3145         }
3146         function updateOptionsForWatchDirectory(options) {
3147             if (options && options.watchDirectory !== undefined)
3148                 return options;
3149             switch (tscWatchDirectory) {
3150                 case "RecursiveDirectoryUsingFsWatchFile":
3151                     return { watchDirectory: ts.WatchDirectoryKind.FixedPollingInterval };
3152                 case "RecursiveDirectoryUsingDynamicPriorityPolling":
3153                     return { watchDirectory: ts.WatchDirectoryKind.DynamicPriorityPolling };
3154                 default:
3155                     var defaultFallbackPolling = options === null || options === void 0 ? void 0 : options.fallbackPolling;
3156                     return {
3157                         watchDirectory: ts.WatchDirectoryKind.UseFsEvents,
3158                         fallbackPolling: defaultFallbackPolling !== undefined ?
3159                             defaultFallbackPolling :
3160                             undefined
3161                     };
3162             }
3163         }
3164     }
3165     ts.createSystemWatchFunctions = createSystemWatchFunctions;
3166     function patchWriteFileEnsuringDirectory(sys) {
3167         var originalWriteFile = sys.writeFile;
3168         sys.writeFile = function (path, data, writeBom) {
3169             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); });
3170         };
3171     }
3172     ts.patchWriteFileEnsuringDirectory = patchWriteFileEnsuringDirectory;
3173     function getNodeMajorVersion() {
3174         if (typeof process === "undefined") {
3175             return undefined;
3176         }
3177         var version = process.version;
3178         if (!version) {
3179             return undefined;
3180         }
3181         var dot = version.indexOf(".");
3182         if (dot === -1) {
3183             return undefined;
3184         }
3185         return parseInt(version.substring(1, dot));
3186     }
3187     ts.getNodeMajorVersion = getNodeMajorVersion;
3188     ts.sys = (function () {
3189         var byteOrderMarkIndicator = "\uFEFF";
3190         function getNodeSystem() {
3191             var nativePattern = /^native |^\([^)]+\)$|^(internal[\\/]|[a-zA-Z0-9_\s]+(\.js)?$)/;
3192             var _fs = require("fs");
3193             var _path = require("path");
3194             var _os = require("os");
3195             var _crypto;
3196             try {
3197                 _crypto = require("crypto");
3198             }
3199             catch (_a) {
3200                 _crypto = undefined;
3201             }
3202             var activeSession;
3203             var profilePath = "./profile.cpuprofile";
3204             var Buffer = require("buffer").Buffer;
3205             var nodeVersion = getNodeMajorVersion();
3206             var isNode4OrLater = nodeVersion >= 4;
3207             var isLinuxOrMacOs = process.platform === "linux" || process.platform === "darwin";
3208             var platform = _os.platform();
3209             var useCaseSensitiveFileNames = isFileSystemCaseSensitive();
3210             var fsSupportsRecursiveFsWatch = isNode4OrLater && (process.platform === "win32" || process.platform === "darwin");
3211             var _b = createSystemWatchFunctions({
3212                 pollingWatchFile: createSingleFileWatcherPerName(fsWatchFileWorker, useCaseSensitiveFileNames),
3213                 getModifiedTime: getModifiedTime,
3214                 setTimeout: setTimeout,
3215                 clearTimeout: clearTimeout,
3216                 fsWatch: fsWatch,
3217                 useCaseSensitiveFileNames: useCaseSensitiveFileNames,
3218                 fileExists: fileExists,
3219                 fsSupportsRecursiveFsWatch: fsSupportsRecursiveFsWatch,
3220                 directoryExists: directoryExists,
3221                 getAccessibleSortedChildDirectories: function (path) { return getAccessibleFileSystemEntries(path).directories; },
3222                 realpath: realpath,
3223                 tscWatchFile: process.env.TSC_WATCHFILE,
3224                 useNonPollingWatchers: process.env.TSC_NONPOLLING_WATCHER,
3225                 tscWatchDirectory: process.env.TSC_WATCHDIRECTORY,
3226             }), watchFile = _b.watchFile, watchDirectory = _b.watchDirectory;
3227             var nodeSystem = {
3228                 args: process.argv.slice(2),
3229                 newLine: _os.EOL,
3230                 useCaseSensitiveFileNames: useCaseSensitiveFileNames,
3231                 write: function (s) {
3232                     process.stdout.write(s);
3233                 },
3234                 writeOutputIsTTY: function () {
3235                     return process.stdout.isTTY;
3236                 },
3237                 readFile: readFile,
3238                 writeFile: writeFile,
3239                 watchFile: watchFile,
3240                 watchDirectory: watchDirectory,
3241                 resolvePath: function (path) { return _path.resolve(path); },
3242                 fileExists: fileExists,
3243                 directoryExists: directoryExists,
3244                 createDirectory: function (directoryName) {
3245                     if (!nodeSystem.directoryExists(directoryName)) {
3246                         try {
3247                             _fs.mkdirSync(directoryName);
3248                         }
3249                         catch (e) {
3250                             if (e.code !== "EEXIST") {
3251                                 throw e;
3252                             }
3253                         }
3254                     }
3255                 },
3256                 getExecutingFilePath: function () {
3257                     return __filename;
3258                 },
3259                 getCurrentDirectory: function () {
3260                     return process.cwd();
3261                 },
3262                 getDirectories: getDirectories,
3263                 getEnvironmentVariable: function (name) {
3264                     return process.env[name] || "";
3265                 },
3266                 readDirectory: readDirectory,
3267                 getModifiedTime: getModifiedTime,
3268                 setModifiedTime: setModifiedTime,
3269                 deleteFile: deleteFile,
3270                 createHash: _crypto ? createSHA256Hash : generateDjb2Hash,
3271                 createSHA256Hash: _crypto ? createSHA256Hash : undefined,
3272                 getMemoryUsage: function () {
3273                     if (global.gc) {
3274                         global.gc();
3275                     }
3276                     return process.memoryUsage().heapUsed;
3277                 },
3278                 getFileSize: function (path) {
3279                     try {
3280                         var stat = _fs.statSync(path);
3281                         if (stat.isFile()) {
3282                             return stat.size;
3283                         }
3284                     }
3285                     catch (_a) { }
3286                     return 0;
3287                 },
3288                 exit: function (exitCode) {
3289                     disableCPUProfiler(function () { return process.exit(exitCode); });
3290                 },
3291                 enableCPUProfiler: enableCPUProfiler,
3292                 disableCPUProfiler: disableCPUProfiler,
3293                 realpath: realpath,
3294                 debugMode: !!process.env.NODE_INSPECTOR_IPC || ts.some(process.execArgv, function (arg) { return /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg); }),
3295                 tryEnableSourceMapsForHost: function () {
3296                     try {
3297                         require("source-map-support").install();
3298                     }
3299                     catch (_a) {
3300                     }
3301                 },
3302                 setTimeout: setTimeout,
3303                 clearTimeout: clearTimeout,
3304                 clearScreen: function () {
3305                     process.stdout.write("\x1Bc");
3306                 },
3307                 setBlocking: function () {
3308                     if (process.stdout && process.stdout._handle && process.stdout._handle.setBlocking) {
3309                         process.stdout._handle.setBlocking(true);
3310                     }
3311                 },
3312                 bufferFrom: bufferFrom,
3313                 base64decode: function (input) { return bufferFrom(input, "base64").toString("utf8"); },
3314                 base64encode: function (input) { return bufferFrom(input).toString("base64"); },
3315                 require: function (baseDir, moduleName) {
3316                     try {
3317                         var modulePath = ts.resolveJSModule(moduleName, baseDir, nodeSystem);
3318                         return { module: require(modulePath), modulePath: modulePath, error: undefined };
3319                     }
3320                     catch (error) {
3321                         return { module: undefined, modulePath: undefined, error: error };
3322                     }
3323                 }
3324             };
3325             return nodeSystem;
3326             function enableCPUProfiler(path, cb) {
3327                 if (activeSession) {
3328                     cb();
3329                     return false;
3330                 }
3331                 var inspector = require("inspector");
3332                 if (!inspector || !inspector.Session) {
3333                     cb();
3334                     return false;
3335                 }
3336                 var session = new inspector.Session();
3337                 session.connect();
3338                 session.post("Profiler.enable", function () {
3339                     session.post("Profiler.start", function () {
3340                         activeSession = session;
3341                         profilePath = path;
3342                         cb();
3343                     });
3344                 });
3345                 return true;
3346             }
3347             function cleanupPaths(profile) {
3348                 var externalFileCounter = 0;
3349                 var remappedPaths = ts.createMap();
3350                 var normalizedDir = ts.normalizeSlashes(__dirname);
3351                 var fileUrlRoot = "file://" + (ts.getRootLength(normalizedDir) === 1 ? "" : "/") + normalizedDir;
3352                 for (var _i = 0, _a = profile.nodes; _i < _a.length; _i++) {
3353                     var node = _a[_i];
3354                     if (node.callFrame.url) {
3355                         var url = ts.normalizeSlashes(node.callFrame.url);
3356                         if (ts.containsPath(fileUrlRoot, url, useCaseSensitiveFileNames)) {
3357                             node.callFrame.url = ts.getRelativePathToDirectoryOrUrl(fileUrlRoot, url, fileUrlRoot, ts.createGetCanonicalFileName(useCaseSensitiveFileNames), true);
3358                         }
3359                         else if (!nativePattern.test(url)) {
3360                             node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external" + externalFileCounter + ".js")).get(url);
3361                             externalFileCounter++;
3362                         }
3363                     }
3364                 }
3365                 return profile;
3366             }
3367             function disableCPUProfiler(cb) {
3368                 if (activeSession && activeSession !== "stopping") {
3369                     var s_1 = activeSession;
3370                     activeSession.post("Profiler.stop", function (err, _a) {
3371                         var profile = _a.profile;
3372                         if (!err) {
3373                             try {
3374                                 if (_fs.statSync(profilePath).isDirectory()) {
3375                                     profilePath = _path.join(profilePath, (new Date()).toISOString().replace(/:/g, "-") + "+P" + process.pid + ".cpuprofile");
3376                                 }
3377                             }
3378                             catch (_b) {
3379                             }
3380                             try {
3381                                 _fs.mkdirSync(_path.dirname(profilePath), { recursive: true });
3382                             }
3383                             catch (_c) {
3384                             }
3385                             _fs.writeFileSync(profilePath, JSON.stringify(cleanupPaths(profile)));
3386                         }
3387                         activeSession = undefined;
3388                         s_1.disconnect();
3389                         cb();
3390                     });
3391                     activeSession = "stopping";
3392                     return true;
3393                 }
3394                 else {
3395                     cb();
3396                     return false;
3397                 }
3398             }
3399             function bufferFrom(input, encoding) {
3400                 return Buffer.from && Buffer.from !== Int8Array.from
3401                     ? Buffer.from(input, encoding)
3402                     : new Buffer(input, encoding);
3403             }
3404             function isFileSystemCaseSensitive() {
3405                 if (platform === "win32" || platform === "win64") {
3406                     return false;
3407                 }
3408                 return !fileExists(swapCase(__filename));
3409             }
3410             function swapCase(s) {
3411                 return s.replace(/\w/g, function (ch) {
3412                     var up = ch.toUpperCase();
3413                     return ch === up ? ch.toLowerCase() : up;
3414                 });
3415             }
3416             function fsWatchFileWorker(fileName, callback, pollingInterval) {
3417                 _fs.watchFile(fileName, { persistent: true, interval: pollingInterval }, fileChanged);
3418                 var eventKind;
3419                 return {
3420                     close: function () { return _fs.unwatchFile(fileName, fileChanged); }
3421                 };
3422                 function fileChanged(curr, prev) {
3423                     var isPreviouslyDeleted = +prev.mtime === 0 || eventKind === FileWatcherEventKind.Deleted;
3424                     if (+curr.mtime === 0) {
3425                         if (isPreviouslyDeleted) {
3426                             return;
3427                         }
3428                         eventKind = FileWatcherEventKind.Deleted;
3429                     }
3430                     else if (isPreviouslyDeleted) {
3431                         eventKind = FileWatcherEventKind.Created;
3432                     }
3433                     else if (+curr.mtime === +prev.mtime) {
3434                         return;
3435                     }
3436                     else {
3437                         eventKind = FileWatcherEventKind.Changed;
3438                     }
3439                     callback(fileName, eventKind);
3440                 }
3441             }
3442             function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingInterval, fallbackOptions) {
3443                 var options;
3444                 var lastDirectoryPartWithDirectorySeparator;
3445                 var lastDirectoryPart;
3446                 if (isLinuxOrMacOs) {
3447                     lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substr(fileOrDirectory.lastIndexOf(ts.directorySeparator));
3448                     lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length);
3449                 }
3450                 var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ?
3451                     watchMissingFileSystemEntry() :
3452                     watchPresentFileSystemEntry();
3453                 return {
3454                     close: function () {
3455                         watcher.close();
3456                         watcher = undefined;
3457                     }
3458                 };
3459                 function invokeCallbackAndUpdateWatcher(createWatcher) {
3460                     ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
3461                     callback("rename", "");
3462                     if (watcher) {
3463                         watcher.close();
3464                         watcher = createWatcher();
3465                     }
3466                 }
3467                 function watchPresentFileSystemEntry() {
3468                     if (options === undefined) {
3469                         if (fsSupportsRecursiveFsWatch) {
3470                             options = { persistent: true, recursive: !!recursive };
3471                         }
3472                         else {
3473                             options = { persistent: true };
3474                         }
3475                     }
3476                     try {
3477                         var presentWatcher = _fs.watch(fileOrDirectory, options, isLinuxOrMacOs ?
3478                             callbackChangingToMissingFileSystemEntry :
3479                             callback);
3480                         presentWatcher.on("error", function () { return invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry); });
3481                         return presentWatcher;
3482                     }
3483                     catch (e) {
3484                         return watchPresentFileSystemEntryWithFsWatchFile();
3485                     }
3486                 }
3487                 function callbackChangingToMissingFileSystemEntry(event, relativeName) {
3488                     return event === "rename" &&
3489                         (!relativeName ||
3490                             relativeName === lastDirectoryPart ||
3491                             relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length) &&
3492                         !fileSystemEntryExists(fileOrDirectory, entryKind) ?
3493                         invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) :
3494                         callback(event, relativeName);
3495                 }
3496                 function watchPresentFileSystemEntryWithFsWatchFile() {
3497                     ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile");
3498                     return watchFile(fileOrDirectory, createFileWatcherCallback(callback), fallbackPollingInterval, fallbackOptions);
3499                 }
3500                 function watchMissingFileSystemEntry() {
3501                     return watchFile(fileOrDirectory, function (_fileName, eventKind) {
3502                         if (eventKind === FileWatcherEventKind.Created && fileSystemEntryExists(fileOrDirectory, entryKind)) {
3503                             invokeCallbackAndUpdateWatcher(watchPresentFileSystemEntry);
3504                         }
3505                     }, fallbackPollingInterval, fallbackOptions);
3506                 }
3507             }
3508             function readFileWorker(fileName, _encoding) {
3509                 var buffer;
3510                 try {
3511                     buffer = _fs.readFileSync(fileName);
3512                 }
3513                 catch (e) {
3514                     return undefined;
3515                 }
3516                 var len = buffer.length;
3517                 if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) {
3518                     len &= ~1;
3519                     for (var i = 0; i < len; i += 2) {
3520                         var temp = buffer[i];
3521                         buffer[i] = buffer[i + 1];
3522                         buffer[i + 1] = temp;
3523                     }
3524                     return buffer.toString("utf16le", 2);
3525                 }
3526                 if (len >= 2 && buffer[0] === 0xFF && buffer[1] === 0xFE) {
3527                     return buffer.toString("utf16le", 2);
3528                 }
3529                 if (len >= 3 && buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) {
3530                     return buffer.toString("utf8", 3);
3531                 }
3532                 return buffer.toString("utf8");
3533             }
3534             function readFile(fileName, _encoding) {
3535                 ts.perfLogger.logStartReadFile(fileName);
3536                 var file = readFileWorker(fileName, _encoding);
3537                 ts.perfLogger.logStopReadFile();
3538                 return file;
3539             }
3540             function writeFile(fileName, data, writeByteOrderMark) {
3541                 ts.perfLogger.logEvent("WriteFile: " + fileName);
3542                 if (writeByteOrderMark) {
3543                     data = byteOrderMarkIndicator + data;
3544                 }
3545                 var fd;
3546                 try {
3547                     fd = _fs.openSync(fileName, "w");
3548                     _fs.writeSync(fd, data, undefined, "utf8");
3549                 }
3550                 finally {
3551                     if (fd !== undefined) {
3552                         _fs.closeSync(fd);
3553                     }
3554                 }
3555             }
3556             function getAccessibleFileSystemEntries(path) {
3557                 ts.perfLogger.logEvent("ReadDir: " + (path || "."));
3558                 try {
3559                     var entries = _fs.readdirSync(path || ".", { withFileTypes: true });
3560                     var files = [];
3561                     var directories = [];
3562                     for (var _i = 0, entries_2 = entries; _i < entries_2.length; _i++) {
3563                         var dirent = entries_2[_i];
3564                         var entry = typeof dirent === "string" ? dirent : dirent.name;
3565                         if (entry === "." || entry === "..") {
3566                             continue;
3567                         }
3568                         var stat = void 0;
3569                         if (typeof dirent === "string" || dirent.isSymbolicLink()) {
3570                             var name = ts.combinePaths(path, entry);
3571                             try {
3572                                 stat = _fs.statSync(name);
3573                             }
3574                             catch (e) {
3575                                 continue;
3576                             }
3577                         }
3578                         else {
3579                             stat = dirent;
3580                         }
3581                         if (stat.isFile()) {
3582                             files.push(entry);
3583                         }
3584                         else if (stat.isDirectory()) {
3585                             directories.push(entry);
3586                         }
3587                     }
3588                     files.sort();
3589                     directories.sort();
3590                     return { files: files, directories: directories };
3591                 }
3592                 catch (e) {
3593                     return ts.emptyFileSystemEntries;
3594                 }
3595             }
3596             function readDirectory(path, extensions, excludes, includes, depth) {
3597                 return ts.matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), depth, getAccessibleFileSystemEntries, realpath);
3598             }
3599             function fileSystemEntryExists(path, entryKind) {
3600                 try {
3601                     var stat = _fs.statSync(path);
3602                     switch (entryKind) {
3603                         case 0: return stat.isFile();
3604                         case 1: return stat.isDirectory();
3605                         default: return false;
3606                     }
3607                 }
3608                 catch (e) {
3609                     return false;
3610                 }
3611             }
3612             function fileExists(path) {
3613                 return fileSystemEntryExists(path, 0);
3614             }
3615             function directoryExists(path) {
3616                 return fileSystemEntryExists(path, 1);
3617             }
3618             function getDirectories(path) {
3619                 return getAccessibleFileSystemEntries(path).directories.slice();
3620             }
3621             function realpath(path) {
3622                 try {
3623                     return _fs.realpathSync(path);
3624                 }
3625                 catch (_a) {
3626                     return path;
3627                 }
3628             }
3629             function getModifiedTime(path) {
3630                 try {
3631                     return _fs.statSync(path).mtime;
3632                 }
3633                 catch (e) {
3634                     return undefined;
3635                 }
3636             }
3637             function setModifiedTime(path, time) {
3638                 try {
3639                     _fs.utimesSync(path, time, time);
3640                 }
3641                 catch (e) {
3642                     return;
3643                 }
3644             }
3645             function deleteFile(path) {
3646                 try {
3647                     return _fs.unlinkSync(path);
3648                 }
3649                 catch (e) {
3650                     return;
3651                 }
3652             }
3653             function createSHA256Hash(data) {
3654                 var hash = _crypto.createHash("sha256");
3655                 hash.update(data);
3656                 return hash.digest("hex");
3657             }
3658         }
3659         var sys;
3660         if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") {
3661             sys = getNodeSystem();
3662         }
3663         if (sys) {
3664             patchWriteFileEnsuringDirectory(sys);
3665         }
3666         return sys;
3667     })();
3668     if (ts.sys && ts.sys.getEnvironmentVariable) {
3669         setCustomPollingValues(ts.sys);
3670         ts.Debug.setAssertionLevel(/^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV"))
3671             ? 1
3672             : 0);
3673     }
3674     if (ts.sys && ts.sys.debugMode) {
3675         ts.Debug.isDebugging = true;
3676     }
3677 })(ts || (ts = {}));
3678 var ts;
3679 (function (ts) {
3680     ts.directorySeparator = "/";
3681     var altDirectorySeparator = "\\";
3682     var urlSchemeSeparator = "://";
3683     var backslashRegExp = /\\/g;
3684     function isAnyDirectorySeparator(charCode) {
3685         return charCode === 47 || charCode === 92;
3686     }
3687     ts.isAnyDirectorySeparator = isAnyDirectorySeparator;
3688     function isUrl(path) {
3689         return getEncodedRootLength(path) < 0;
3690     }
3691     ts.isUrl = isUrl;
3692     function isRootedDiskPath(path) {
3693         return getEncodedRootLength(path) > 0;
3694     }
3695     ts.isRootedDiskPath = isRootedDiskPath;
3696     function isDiskPathRoot(path) {
3697         var rootLength = getEncodedRootLength(path);
3698         return rootLength > 0 && rootLength === path.length;
3699     }
3700     ts.isDiskPathRoot = isDiskPathRoot;
3701     function pathIsAbsolute(path) {
3702         return getEncodedRootLength(path) !== 0;
3703     }
3704     ts.pathIsAbsolute = pathIsAbsolute;
3705     function pathIsRelative(path) {
3706         return /^\.\.?($|[\\/])/.test(path);
3707     }
3708     ts.pathIsRelative = pathIsRelative;
3709     function hasExtension(fileName) {
3710         return ts.stringContains(getBaseFileName(fileName), ".");
3711     }
3712     ts.hasExtension = hasExtension;
3713     function fileExtensionIs(path, extension) {
3714         return path.length > extension.length && ts.endsWith(path, extension);
3715     }
3716     ts.fileExtensionIs = fileExtensionIs;
3717     function fileExtensionIsOneOf(path, extensions) {
3718         for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) {
3719             var extension = extensions_1[_i];
3720             if (fileExtensionIs(path, extension)) {
3721                 return true;
3722             }
3723         }
3724         return false;
3725     }
3726     ts.fileExtensionIsOneOf = fileExtensionIsOneOf;
3727     function hasTrailingDirectorySeparator(path) {
3728         return path.length > 0 && isAnyDirectorySeparator(path.charCodeAt(path.length - 1));
3729     }
3730     ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator;
3731     function isVolumeCharacter(charCode) {
3732         return (charCode >= 97 && charCode <= 122) ||
3733             (charCode >= 65 && charCode <= 90);
3734     }
3735     function getFileUrlVolumeSeparatorEnd(url, start) {
3736         var ch0 = url.charCodeAt(start);
3737         if (ch0 === 58)
3738             return start + 1;
3739         if (ch0 === 37 && url.charCodeAt(start + 1) === 51) {
3740             var ch2 = url.charCodeAt(start + 2);
3741             if (ch2 === 97 || ch2 === 65)
3742                 return start + 3;
3743         }
3744         return -1;
3745     }
3746     function getEncodedRootLength(path) {
3747         if (!path)
3748             return 0;
3749         var ch0 = path.charCodeAt(0);
3750         if (ch0 === 47 || ch0 === 92) {
3751             if (path.charCodeAt(1) !== ch0)
3752                 return 1;
3753             var p1 = path.indexOf(ch0 === 47 ? ts.directorySeparator : altDirectorySeparator, 2);
3754             if (p1 < 0)
3755                 return path.length;
3756             return p1 + 1;
3757         }
3758         if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58) {
3759             var ch2 = path.charCodeAt(2);
3760             if (ch2 === 47 || ch2 === 92)
3761                 return 3;
3762             if (path.length === 2)
3763                 return 2;
3764         }
3765         var schemeEnd = path.indexOf(urlSchemeSeparator);
3766         if (schemeEnd !== -1) {
3767             var authorityStart = schemeEnd + urlSchemeSeparator.length;
3768             var authorityEnd = path.indexOf(ts.directorySeparator, authorityStart);
3769             if (authorityEnd !== -1) {
3770                 var scheme = path.slice(0, schemeEnd);
3771                 var authority = path.slice(authorityStart, authorityEnd);
3772                 if (scheme === "file" && (authority === "" || authority === "localhost") &&
3773                     isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) {
3774                     var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2);
3775                     if (volumeSeparatorEnd !== -1) {
3776                         if (path.charCodeAt(volumeSeparatorEnd) === 47) {
3777                             return ~(volumeSeparatorEnd + 1);
3778                         }
3779                         if (volumeSeparatorEnd === path.length) {
3780                             return ~volumeSeparatorEnd;
3781                         }
3782                     }
3783                 }
3784                 return ~(authorityEnd + 1);
3785             }
3786             return ~path.length;
3787         }
3788         return 0;
3789     }
3790     function getRootLength(path) {
3791         var rootLength = getEncodedRootLength(path);
3792         return rootLength < 0 ? ~rootLength : rootLength;
3793     }
3794     ts.getRootLength = getRootLength;
3795     function getDirectoryPath(path) {
3796         path = normalizeSlashes(path);
3797         var rootLength = getRootLength(path);
3798         if (rootLength === path.length)
3799             return path;
3800         path = removeTrailingDirectorySeparator(path);
3801         return path.slice(0, Math.max(rootLength, path.lastIndexOf(ts.directorySeparator)));
3802     }
3803     ts.getDirectoryPath = getDirectoryPath;
3804     function getBaseFileName(path, extensions, ignoreCase) {
3805         path = normalizeSlashes(path);
3806         var rootLength = getRootLength(path);
3807         if (rootLength === path.length)
3808             return "";
3809         path = removeTrailingDirectorySeparator(path);
3810         var name = path.slice(Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator) + 1));
3811         var extension = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(name, extensions, ignoreCase) : undefined;
3812         return extension ? name.slice(0, name.length - extension.length) : name;
3813     }
3814     ts.getBaseFileName = getBaseFileName;
3815     function tryGetExtensionFromPath(path, extension, stringEqualityComparer) {
3816         if (!ts.startsWith(extension, "."))
3817             extension = "." + extension;
3818         if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46) {
3819             var pathExtension = path.slice(path.length - extension.length);
3820             if (stringEqualityComparer(pathExtension, extension)) {
3821                 return pathExtension;
3822             }
3823         }
3824     }
3825     function getAnyExtensionFromPathWorker(path, extensions, stringEqualityComparer) {
3826         if (typeof extensions === "string") {
3827             return tryGetExtensionFromPath(path, extensions, stringEqualityComparer) || "";
3828         }
3829         for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) {
3830             var extension = extensions_2[_i];
3831             var result = tryGetExtensionFromPath(path, extension, stringEqualityComparer);
3832             if (result)
3833                 return result;
3834         }
3835         return "";
3836     }
3837     function getAnyExtensionFromPath(path, extensions, ignoreCase) {
3838         if (extensions) {
3839             return getAnyExtensionFromPathWorker(removeTrailingDirectorySeparator(path), extensions, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive);
3840         }
3841         var baseFileName = getBaseFileName(path);
3842         var extensionIndex = baseFileName.lastIndexOf(".");
3843         if (extensionIndex >= 0) {
3844             return baseFileName.substring(extensionIndex);
3845         }
3846         return "";
3847     }
3848     ts.getAnyExtensionFromPath = getAnyExtensionFromPath;
3849     function pathComponents(path, rootLength) {
3850         var root = path.substring(0, rootLength);
3851         var rest = path.substring(rootLength).split(ts.directorySeparator);
3852         if (rest.length && !ts.lastOrUndefined(rest))
3853             rest.pop();
3854         return __spreadArrays([root], rest);
3855     }
3856     function getPathComponents(path, currentDirectory) {
3857         if (currentDirectory === void 0) { currentDirectory = ""; }
3858         path = combinePaths(currentDirectory, path);
3859         return pathComponents(path, getRootLength(path));
3860     }
3861     ts.getPathComponents = getPathComponents;
3862     function getPathFromPathComponents(pathComponents) {
3863         if (pathComponents.length === 0)
3864             return "";
3865         var root = pathComponents[0] && ensureTrailingDirectorySeparator(pathComponents[0]);
3866         return root + pathComponents.slice(1).join(ts.directorySeparator);
3867     }
3868     ts.getPathFromPathComponents = getPathFromPathComponents;
3869     function normalizeSlashes(path) {
3870         return path.replace(backslashRegExp, ts.directorySeparator);
3871     }
3872     ts.normalizeSlashes = normalizeSlashes;
3873     function reducePathComponents(components) {
3874         if (!ts.some(components))
3875             return [];
3876         var reduced = [components[0]];
3877         for (var i = 1; i < components.length; i++) {
3878             var component = components[i];
3879             if (!component)
3880                 continue;
3881             if (component === ".")
3882                 continue;
3883             if (component === "..") {
3884                 if (reduced.length > 1) {
3885                     if (reduced[reduced.length - 1] !== "..") {
3886                         reduced.pop();
3887                         continue;
3888                     }
3889                 }
3890                 else if (reduced[0])
3891                     continue;
3892             }
3893             reduced.push(component);
3894         }
3895         return reduced;
3896     }
3897     ts.reducePathComponents = reducePathComponents;
3898     function combinePaths(path) {
3899         var paths = [];
3900         for (var _i = 1; _i < arguments.length; _i++) {
3901             paths[_i - 1] = arguments[_i];
3902         }
3903         if (path)
3904             path = normalizeSlashes(path);
3905         for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) {
3906             var relativePath = paths_1[_a];
3907             if (!relativePath)
3908                 continue;
3909             relativePath = normalizeSlashes(relativePath);
3910             if (!path || getRootLength(relativePath) !== 0) {
3911                 path = relativePath;
3912             }
3913             else {
3914                 path = ensureTrailingDirectorySeparator(path) + relativePath;
3915             }
3916         }
3917         return path;
3918     }
3919     ts.combinePaths = combinePaths;
3920     function resolvePath(path) {
3921         var paths = [];
3922         for (var _i = 1; _i < arguments.length; _i++) {
3923             paths[_i - 1] = arguments[_i];
3924         }
3925         return normalizePath(ts.some(paths) ? combinePaths.apply(void 0, __spreadArrays([path], paths)) : normalizeSlashes(path));
3926     }
3927     ts.resolvePath = resolvePath;
3928     function getNormalizedPathComponents(path, currentDirectory) {
3929         return reducePathComponents(getPathComponents(path, currentDirectory));
3930     }
3931     ts.getNormalizedPathComponents = getNormalizedPathComponents;
3932     function getNormalizedAbsolutePath(fileName, currentDirectory) {
3933         return getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory));
3934     }
3935     ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath;
3936     function normalizePath(path) {
3937         path = normalizeSlashes(path);
3938         var normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path)));
3939         return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized;
3940     }
3941     ts.normalizePath = normalizePath;
3942     function getPathWithoutRoot(pathComponents) {
3943         if (pathComponents.length === 0)
3944             return "";
3945         return pathComponents.slice(1).join(ts.directorySeparator);
3946     }
3947     function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) {
3948         return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory));
3949     }
3950     ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot;
3951     function toPath(fileName, basePath, getCanonicalFileName) {
3952         var nonCanonicalizedPath = isRootedDiskPath(fileName)
3953             ? normalizePath(fileName)
3954             : getNormalizedAbsolutePath(fileName, basePath);
3955         return getCanonicalFileName(nonCanonicalizedPath);
3956     }
3957     ts.toPath = toPath;
3958     function normalizePathAndParts(path) {
3959         path = normalizeSlashes(path);
3960         var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1);
3961         if (parts.length) {
3962             var joinedParts = root + parts.join(ts.directorySeparator);
3963             return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts };
3964         }
3965         else {
3966             return { path: root, parts: parts };
3967         }
3968     }
3969     ts.normalizePathAndParts = normalizePathAndParts;
3970     function removeTrailingDirectorySeparator(path) {
3971         if (hasTrailingDirectorySeparator(path)) {
3972             return path.substr(0, path.length - 1);
3973         }
3974         return path;
3975     }
3976     ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator;
3977     function ensureTrailingDirectorySeparator(path) {
3978         if (!hasTrailingDirectorySeparator(path)) {
3979             return path + ts.directorySeparator;
3980         }
3981         return path;
3982     }
3983     ts.ensureTrailingDirectorySeparator = ensureTrailingDirectorySeparator;
3984     function ensurePathIsNonModuleName(path) {
3985         return !pathIsAbsolute(path) && !pathIsRelative(path) ? "./" + path : path;
3986     }
3987     ts.ensurePathIsNonModuleName = ensurePathIsNonModuleName;
3988     function changeAnyExtension(path, ext, extensions, ignoreCase) {
3989         var pathext = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(path, extensions, ignoreCase) : getAnyExtensionFromPath(path);
3990         return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path;
3991     }
3992     ts.changeAnyExtension = changeAnyExtension;
3993     var relativePathSegmentRegExp = /(^|\/)\.{0,2}($|\/)/;
3994     function comparePathsWorker(a, b, componentComparer) {
3995         if (a === b)
3996             return 0;
3997         if (a === undefined)
3998             return -1;
3999         if (b === undefined)
4000             return 1;
4001         var aRoot = a.substring(0, getRootLength(a));
4002         var bRoot = b.substring(0, getRootLength(b));
4003         var result = ts.compareStringsCaseInsensitive(aRoot, bRoot);
4004         if (result !== 0) {
4005             return result;
4006         }
4007         var aRest = a.substring(aRoot.length);
4008         var bRest = b.substring(bRoot.length);
4009         if (!relativePathSegmentRegExp.test(aRest) && !relativePathSegmentRegExp.test(bRest)) {
4010             return componentComparer(aRest, bRest);
4011         }
4012         var aComponents = reducePathComponents(getPathComponents(a));
4013         var bComponents = reducePathComponents(getPathComponents(b));
4014         var sharedLength = Math.min(aComponents.length, bComponents.length);
4015         for (var i = 1; i < sharedLength; i++) {
4016             var result_1 = componentComparer(aComponents[i], bComponents[i]);
4017             if (result_1 !== 0) {
4018                 return result_1;
4019             }
4020         }
4021         return ts.compareValues(aComponents.length, bComponents.length);
4022     }
4023     function comparePathsCaseSensitive(a, b) {
4024         return comparePathsWorker(a, b, ts.compareStringsCaseSensitive);
4025     }
4026     ts.comparePathsCaseSensitive = comparePathsCaseSensitive;
4027     function comparePathsCaseInsensitive(a, b) {
4028         return comparePathsWorker(a, b, ts.compareStringsCaseInsensitive);
4029     }
4030     ts.comparePathsCaseInsensitive = comparePathsCaseInsensitive;
4031     function comparePaths(a, b, currentDirectory, ignoreCase) {
4032         if (typeof currentDirectory === "string") {
4033             a = combinePaths(currentDirectory, a);
4034             b = combinePaths(currentDirectory, b);
4035         }
4036         else if (typeof currentDirectory === "boolean") {
4037             ignoreCase = currentDirectory;
4038         }
4039         return comparePathsWorker(a, b, ts.getStringComparer(ignoreCase));
4040     }
4041     ts.comparePaths = comparePaths;
4042     function containsPath(parent, child, currentDirectory, ignoreCase) {
4043         if (typeof currentDirectory === "string") {
4044             parent = combinePaths(currentDirectory, parent);
4045             child = combinePaths(currentDirectory, child);
4046         }
4047         else if (typeof currentDirectory === "boolean") {
4048             ignoreCase = currentDirectory;
4049         }
4050         if (parent === undefined || child === undefined)
4051             return false;
4052         if (parent === child)
4053             return true;
4054         var parentComponents = reducePathComponents(getPathComponents(parent));
4055         var childComponents = reducePathComponents(getPathComponents(child));
4056         if (childComponents.length < parentComponents.length) {
4057             return false;
4058         }
4059         var componentEqualityComparer = ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive;
4060         for (var i = 0; i < parentComponents.length; i++) {
4061             var equalityComparer = i === 0 ? ts.equateStringsCaseInsensitive : componentEqualityComparer;
4062             if (!equalityComparer(parentComponents[i], childComponents[i])) {
4063                 return false;
4064             }
4065         }
4066         return true;
4067     }
4068     ts.containsPath = containsPath;
4069     function startsWithDirectory(fileName, directoryName, getCanonicalFileName) {
4070         var canonicalFileName = getCanonicalFileName(fileName);
4071         var canonicalDirectoryName = getCanonicalFileName(directoryName);
4072         return ts.startsWith(canonicalFileName, canonicalDirectoryName + "/") || ts.startsWith(canonicalFileName, canonicalDirectoryName + "\\");
4073     }
4074     ts.startsWithDirectory = startsWithDirectory;
4075     function getPathComponentsRelativeTo(from, to, stringEqualityComparer, getCanonicalFileName) {
4076         var fromComponents = reducePathComponents(getPathComponents(from));
4077         var toComponents = reducePathComponents(getPathComponents(to));
4078         var start;
4079         for (start = 0; start < fromComponents.length && start < toComponents.length; start++) {
4080             var fromComponent = getCanonicalFileName(fromComponents[start]);
4081             var toComponent = getCanonicalFileName(toComponents[start]);
4082             var comparer = start === 0 ? ts.equateStringsCaseInsensitive : stringEqualityComparer;
4083             if (!comparer(fromComponent, toComponent))
4084                 break;
4085         }
4086         if (start === 0) {
4087             return toComponents;
4088         }
4089         var components = toComponents.slice(start);
4090         var relative = [];
4091         for (; start < fromComponents.length; start++) {
4092             relative.push("..");
4093         }
4094         return __spreadArrays([""], relative, components);
4095     }
4096     ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo;
4097     function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) {
4098         ts.Debug.assert((getRootLength(fromDirectory) > 0) === (getRootLength(to) > 0), "Paths must either both be absolute or both be relative");
4099         var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity;
4100         var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false;
4101         var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName);
4102         return getPathFromPathComponents(pathComponents);
4103     }
4104     ts.getRelativePathFromDirectory = getRelativePathFromDirectory;
4105     function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) {
4106         return !isRootedDiskPath(absoluteOrRelativePath)
4107             ? absoluteOrRelativePath
4108             : getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, false);
4109     }
4110     ts.convertToRelativePath = convertToRelativePath;
4111     function getRelativePathFromFile(from, to, getCanonicalFileName) {
4112         return ensurePathIsNonModuleName(getRelativePathFromDirectory(getDirectoryPath(from), to, getCanonicalFileName));
4113     }
4114     ts.getRelativePathFromFile = getRelativePathFromFile;
4115     function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) {
4116         var pathComponents = getPathComponentsRelativeTo(resolvePath(currentDirectory, directoryPathOrUrl), resolvePath(currentDirectory, relativeOrAbsolutePath), ts.equateStringsCaseSensitive, getCanonicalFileName);
4117         var firstComponent = pathComponents[0];
4118         if (isAbsolutePathAnUrl && isRootedDiskPath(firstComponent)) {
4119             var prefix = firstComponent.charAt(0) === ts.directorySeparator ? "file://" : "file:///";
4120             pathComponents[0] = prefix + firstComponent;
4121         }
4122         return getPathFromPathComponents(pathComponents);
4123     }
4124     ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl;
4125     function forEachAncestorDirectory(directory, callback) {
4126         while (true) {
4127             var result = callback(directory);
4128             if (result !== undefined) {
4129                 return result;
4130             }
4131             var parentPath = getDirectoryPath(directory);
4132             if (parentPath === directory) {
4133                 return undefined;
4134             }
4135             directory = parentPath;
4136         }
4137     }
4138     ts.forEachAncestorDirectory = forEachAncestorDirectory;
4139     function isNodeModulesDirectory(dirPath) {
4140         return ts.endsWith(dirPath, "/node_modules");
4141     }
4142     ts.isNodeModulesDirectory = isNodeModulesDirectory;
4143 })(ts || (ts = {}));
4144 var ts;
4145 (function (ts) {
4146     function diag(code, category, key, message, reportsUnnecessary, elidedInCompatabilityPyramid) {
4147         return { code: code, category: category, key: key, message: message, reportsUnnecessary: reportsUnnecessary, elidedInCompatabilityPyramid: elidedInCompatabilityPyramid };
4148     }
4149     ts.Diagnostics = {
4150         Unterminated_string_literal: diag(1002, ts.DiagnosticCategory.Error, "Unterminated_string_literal_1002", "Unterminated string literal."),
4151         Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."),
4152         _0_expected: diag(1005, ts.DiagnosticCategory.Error, "_0_expected_1005", "'{0}' expected."),
4153         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."),
4154         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."),
4155         Trailing_comma_not_allowed: diag(1009, ts.DiagnosticCategory.Error, "Trailing_comma_not_allowed_1009", "Trailing comma not allowed."),
4156         Asterisk_Slash_expected: diag(1010, ts.DiagnosticCategory.Error, "Asterisk_Slash_expected_1010", "'*/' expected."),
4157         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."),
4158         Unexpected_token: diag(1012, ts.DiagnosticCategory.Error, "Unexpected_token_1012", "Unexpected token."),
4159         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."),
4160         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."),
4161         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."),
4162         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."),
4163         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."),
4164         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."),
4165         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."),
4166         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."),
4167         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."),
4168         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."),
4169         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'."),
4170         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."),
4171         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."),
4172         Accessibility_modifier_already_seen: diag(1028, ts.DiagnosticCategory.Error, "Accessibility_modifier_already_seen_1028", "Accessibility modifier already seen."),
4173         _0_modifier_must_precede_1_modifier: diag(1029, ts.DiagnosticCategory.Error, "_0_modifier_must_precede_1_modifier_1029", "'{0}' modifier must precede '{1}' modifier."),
4174         _0_modifier_already_seen: diag(1030, ts.DiagnosticCategory.Error, "_0_modifier_already_seen_1030", "'{0}' modifier already seen."),
4175         _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."),
4176         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."),
4177         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."),
4178         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."),
4179         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."),
4180         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."),
4181         _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."),
4182         _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."),
4183         _0_modifier_cannot_be_used_here: diag(1042, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_here_1042", "'{0}' modifier cannot be used here."),
4184         _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."),
4185         _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."),
4186         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."),
4187         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."),
4188         A_rest_parameter_cannot_be_optional: diag(1047, ts.DiagnosticCategory.Error, "A_rest_parameter_cannot_be_optional_1047", "A rest parameter cannot be optional."),
4189         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."),
4190         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."),
4191         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."),
4192         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."),
4193         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."),
4194         A_get_accessor_cannot_have_parameters: diag(1054, ts.DiagnosticCategory.Error, "A_get_accessor_cannot_have_parameters_1054", "A 'get' accessor cannot have parameters."),
4195         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."),
4196         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."),
4197         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."),
4198         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."),
4199         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."),
4200         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."),
4201         Enum_member_must_have_initializer: diag(1061, ts.DiagnosticCategory.Error, "Enum_member_must_have_initializer_1061", "Enum member must have initializer."),
4202         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."),
4203         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."),
4204         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."),
4205         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."),
4206         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."),
4207         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."),
4208         _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."),
4209         _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."),
4210         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."),
4211         Invalid_reference_directive_syntax: diag(1084, ts.DiagnosticCategory.Error, "Invalid_reference_directive_syntax_1084", "Invalid 'reference' directive syntax."),
4212         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}'."),
4213         _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."),
4214         _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."),
4215         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."),
4216         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."),
4217         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."),
4218         An_accessor_cannot_have_type_parameters: diag(1094, ts.DiagnosticCategory.Error, "An_accessor_cannot_have_type_parameters_1094", "An accessor cannot have type parameters."),
4219         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."),
4220         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."),
4221         _0_list_cannot_be_empty: diag(1097, ts.DiagnosticCategory.Error, "_0_list_cannot_be_empty_1097", "'{0}' list cannot be empty."),
4222         Type_parameter_list_cannot_be_empty: diag(1098, ts.DiagnosticCategory.Error, "Type_parameter_list_cannot_be_empty_1098", "Type parameter list cannot be empty."),
4223         Type_argument_list_cannot_be_empty: diag(1099, ts.DiagnosticCategory.Error, "Type_argument_list_cannot_be_empty_1099", "Type argument list cannot be empty."),
4224         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."),
4225         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."),
4226         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."),
4227         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."),
4228         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."),
4229         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."),
4230         Jump_target_cannot_cross_function_boundary: diag(1107, ts.DiagnosticCategory.Error, "Jump_target_cannot_cross_function_boundary_1107", "Jump target cannot cross function boundary."),
4231         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."),
4232         Expression_expected: diag(1109, ts.DiagnosticCategory.Error, "Expression_expected_1109", "Expression expected."),
4233         Type_expected: diag(1110, ts.DiagnosticCategory.Error, "Type_expected_1110", "Type expected."),
4234         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."),
4235         Duplicate_label_0: diag(1114, ts.DiagnosticCategory.Error, "Duplicate_label_0_1114", "Duplicate label '{0}'."),
4236         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."),
4237         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."),
4238         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."),
4239         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."),
4240         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."),
4241         An_export_assignment_cannot_have_modifiers: diag(1120, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_have_modifiers_1120", "An export assignment cannot have modifiers."),
4242         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."),
4243         Variable_declaration_list_cannot_be_empty: diag(1123, ts.DiagnosticCategory.Error, "Variable_declaration_list_cannot_be_empty_1123", "Variable declaration list cannot be empty."),
4244         Digit_expected: diag(1124, ts.DiagnosticCategory.Error, "Digit_expected_1124", "Digit expected."),
4245         Hexadecimal_digit_expected: diag(1125, ts.DiagnosticCategory.Error, "Hexadecimal_digit_expected_1125", "Hexadecimal digit expected."),
4246         Unexpected_end_of_text: diag(1126, ts.DiagnosticCategory.Error, "Unexpected_end_of_text_1126", "Unexpected end of text."),
4247         Invalid_character: diag(1127, ts.DiagnosticCategory.Error, "Invalid_character_1127", "Invalid character."),
4248         Declaration_or_statement_expected: diag(1128, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_1128", "Declaration or statement expected."),
4249         Statement_expected: diag(1129, ts.DiagnosticCategory.Error, "Statement_expected_1129", "Statement expected."),
4250         case_or_default_expected: diag(1130, ts.DiagnosticCategory.Error, "case_or_default_expected_1130", "'case' or 'default' expected."),
4251         Property_or_signature_expected: diag(1131, ts.DiagnosticCategory.Error, "Property_or_signature_expected_1131", "Property or signature expected."),
4252         Enum_member_expected: diag(1132, ts.DiagnosticCategory.Error, "Enum_member_expected_1132", "Enum member expected."),
4253         Variable_declaration_expected: diag(1134, ts.DiagnosticCategory.Error, "Variable_declaration_expected_1134", "Variable declaration expected."),
4254         Argument_expression_expected: diag(1135, ts.DiagnosticCategory.Error, "Argument_expression_expected_1135", "Argument expression expected."),
4255         Property_assignment_expected: diag(1136, ts.DiagnosticCategory.Error, "Property_assignment_expected_1136", "Property assignment expected."),
4256         Expression_or_comma_expected: diag(1137, ts.DiagnosticCategory.Error, "Expression_or_comma_expected_1137", "Expression or comma expected."),
4257         Parameter_declaration_expected: diag(1138, ts.DiagnosticCategory.Error, "Parameter_declaration_expected_1138", "Parameter declaration expected."),
4258         Type_parameter_declaration_expected: diag(1139, ts.DiagnosticCategory.Error, "Type_parameter_declaration_expected_1139", "Type parameter declaration expected."),
4259         Type_argument_expected: diag(1140, ts.DiagnosticCategory.Error, "Type_argument_expected_1140", "Type argument expected."),
4260         String_literal_expected: diag(1141, ts.DiagnosticCategory.Error, "String_literal_expected_1141", "String literal expected."),
4261         Line_break_not_permitted_here: diag(1142, ts.DiagnosticCategory.Error, "Line_break_not_permitted_here_1142", "Line break not permitted here."),
4262         or_expected: diag(1144, ts.DiagnosticCategory.Error, "or_expected_1144", "'{' or ';' expected."),
4263         Declaration_expected: diag(1146, ts.DiagnosticCategory.Error, "Declaration_expected_1146", "Declaration expected."),
4264         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."),
4265         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'."),
4266         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."),
4267         const_declarations_must_be_initialized: diag(1155, ts.DiagnosticCategory.Error, "const_declarations_must_be_initialized_1155", "'const' declarations must be initialized."),
4268         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."),
4269         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."),
4270         Unterminated_template_literal: diag(1160, ts.DiagnosticCategory.Error, "Unterminated_template_literal_1160", "Unterminated template literal."),
4271         Unterminated_regular_expression_literal: diag(1161, ts.DiagnosticCategory.Error, "Unterminated_regular_expression_literal_1161", "Unterminated regular expression literal."),
4272         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."),
4273         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."),
4274         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."),
4275         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."),
4276         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."),
4277         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."),
4278         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."),
4279         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."),
4280         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."),
4281         extends_clause_already_seen: diag(1172, ts.DiagnosticCategory.Error, "extends_clause_already_seen_1172", "'extends' clause already seen."),
4282         extends_clause_must_precede_implements_clause: diag(1173, ts.DiagnosticCategory.Error, "extends_clause_must_precede_implements_clause_1173", "'extends' clause must precede 'implements' clause."),
4283         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."),
4284         implements_clause_already_seen: diag(1175, ts.DiagnosticCategory.Error, "implements_clause_already_seen_1175", "'implements' clause already seen."),
4285         Interface_declaration_cannot_have_implements_clause: diag(1176, ts.DiagnosticCategory.Error, "Interface_declaration_cannot_have_implements_clause_1176", "Interface declaration cannot have 'implements' clause."),
4286         Binary_digit_expected: diag(1177, ts.DiagnosticCategory.Error, "Binary_digit_expected_1177", "Binary digit expected."),
4287         Octal_digit_expected: diag(1178, ts.DiagnosticCategory.Error, "Octal_digit_expected_1178", "Octal digit expected."),
4288         Unexpected_token_expected: diag(1179, ts.DiagnosticCategory.Error, "Unexpected_token_expected_1179", "Unexpected token. '{' expected."),
4289         Property_destructuring_pattern_expected: diag(1180, ts.DiagnosticCategory.Error, "Property_destructuring_pattern_expected_1180", "Property destructuring pattern expected."),
4290         Array_element_destructuring_pattern_expected: diag(1181, ts.DiagnosticCategory.Error, "Array_element_destructuring_pattern_expected_1181", "Array element destructuring pattern expected."),
4291         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."),
4292         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."),
4293         Modifiers_cannot_appear_here: diag(1184, ts.DiagnosticCategory.Error, "Modifiers_cannot_appear_here_1184", "Modifiers cannot appear here."),
4294         Merge_conflict_marker_encountered: diag(1185, ts.DiagnosticCategory.Error, "Merge_conflict_marker_encountered_1185", "Merge conflict marker encountered."),
4295         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."),
4296         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."),
4297         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."),
4298         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."),
4299         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."),
4300         An_import_declaration_cannot_have_modifiers: diag(1191, ts.DiagnosticCategory.Error, "An_import_declaration_cannot_have_modifiers_1191", "An import declaration cannot have modifiers."),
4301         Module_0_has_no_default_export: diag(1192, ts.DiagnosticCategory.Error, "Module_0_has_no_default_export_1192", "Module '{0}' has no default export."),
4302         An_export_declaration_cannot_have_modifiers: diag(1193, ts.DiagnosticCategory.Error, "An_export_declaration_cannot_have_modifiers_1193", "An export declaration cannot have modifiers."),
4303         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."),
4304         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."),
4305         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."),
4306         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."),
4307         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."),
4308         Unterminated_Unicode_escape_sequence: diag(1199, ts.DiagnosticCategory.Error, "Unterminated_Unicode_escape_sequence_1199", "Unterminated Unicode escape sequence."),
4309         Line_terminator_not_permitted_before_arrow: diag(1200, ts.DiagnosticCategory.Error, "Line_terminator_not_permitted_before_arrow_1200", "Line terminator not permitted before arrow."),
4310         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."),
4311         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."),
4312         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'."),
4313         Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."),
4314         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."),
4315         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."),
4316         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."),
4317         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."),
4318         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."),
4319         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."),
4320         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."),
4321         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."),
4322         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."),
4323         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'."),
4324         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."),
4325         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."),
4326         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."),
4327         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."),
4328         _0_tag_already_specified: diag(1223, ts.DiagnosticCategory.Error, "_0_tag_already_specified_1223", "'{0}' tag already specified."),
4329         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."),
4330         Cannot_find_parameter_0: diag(1225, ts.DiagnosticCategory.Error, "Cannot_find_parameter_0_1225", "Cannot find parameter '{0}'."),
4331         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}'."),
4332         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}'."),
4333         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."),
4334         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."),
4335         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."),
4336         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."),
4337         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."),
4338         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."),
4339         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."),
4340         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."),
4341         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'."),
4342         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'."),
4343         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."),
4344         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."),
4345         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."),
4346         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."),
4347         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."),
4348         _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."),
4349         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."),
4350         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."),
4351         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."),
4352         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."),
4353         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."),
4354         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."),
4355         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'."),
4356         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."),
4357         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."),
4358         _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."),
4359         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."),
4360         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."),
4361         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."),
4362         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."),
4363         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."),
4364         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"),
4365         Keywords_cannot_contain_escape_characters: diag(1260, ts.DiagnosticCategory.Error, "Keywords_cannot_contain_escape_characters_1260", "Keywords cannot contain escape characters."),
4366         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."),
4367         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."),
4368         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."),
4369         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."),
4370         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."),
4371         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."),
4372         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."),
4373         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."),
4374         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."),
4375         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."),
4376         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."),
4377         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."),
4378         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."),
4379         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."),
4380         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'."),
4381         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."),
4382         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."),
4383         Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments"),
4384         String_literal_with_double_quotes_expected: diag(1327, ts.DiagnosticCategory.Error, "String_literal_with_double_quotes_expected_1327", "String literal with double quotes expected."),
4385         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."),
4386         _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}()'?"),
4387         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'."),
4388         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'."),
4389         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'."),
4390         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."),
4391         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."),
4392         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."),
4393         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."),
4394         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."),
4395         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."),
4396         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."),
4397         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}')'?"),
4398         Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."),
4399         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'."),
4400         A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."),
4401         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"),
4402         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."),
4403         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."),
4404         Non_simple_parameter_declared_here: diag(1348, ts.DiagnosticCategory.Error, "Non_simple_parameter_declared_here_1348", "Non-simple parameter declared here."),
4405         use_strict_directive_used_here: diag(1349, ts.DiagnosticCategory.Error, "use_strict_directive_used_here_1349", "'use strict' directive used here."),
4406         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."),
4407         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."),
4408         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."),
4409         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."),
4410         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."),
4411         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."),
4412         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'?"),
4413         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 '}'."),
4414         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."),
4415         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."),
4416         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?"),
4417         _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'."),
4418         _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'."),
4419         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."),
4420         Convert_to_type_only_export: diag(1364, ts.DiagnosticCategory.Message, "Convert_to_type_only_export_1364", "Convert to type-only export"),
4421         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"),
4422         Split_into_two_separate_import_declarations: diag(1366, ts.DiagnosticCategory.Message, "Split_into_two_separate_import_declarations_1366", "Split into two separate import declarations"),
4423         Split_all_invalid_type_only_imports: diag(1367, ts.DiagnosticCategory.Message, "Split_all_invalid_type_only_imports_1367", "Split all invalid type-only imports"),
4424         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"),
4425         Did_you_mean_0: diag(1369, ts.DiagnosticCategory.Message, "Did_you_mean_0_1369", "Did you mean '{0}'?"),
4426         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'."),
4427         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'."),
4428         Convert_to_type_only_import: diag(1373, ts.DiagnosticCategory.Message, "Convert_to_type_only_import_1373", "Convert to type-only import"),
4429         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"),
4430         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."),
4431         _0_was_imported_here: diag(1376, ts.DiagnosticCategory.Message, "_0_was_imported_here_1376", "'{0}' was imported here."),
4432         _0_was_exported_here: diag(1377, ts.DiagnosticCategory.Message, "_0_was_exported_here_1377", "'{0}' was exported here."),
4433         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."),
4434         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'."),
4435         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'."),
4436         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;`?"),
4437         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;`?"),
4438         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'."),
4439         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."),
4440         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."),
4441         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."),
4442         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),
4443         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),
4444         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),
4445         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),
4446         Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
4447         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."),
4448         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."),
4449         Circular_definition_of_import_alias_0: diag(2303, ts.DiagnosticCategory.Error, "Circular_definition_of_import_alias_0_2303", "Circular definition of import alias '{0}'."),
4450         Cannot_find_name_0: diag(2304, ts.DiagnosticCategory.Error, "Cannot_find_name_0_2304", "Cannot find name '{0}'."),
4451         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}'."),
4452         File_0_is_not_a_module: diag(2306, ts.DiagnosticCategory.Error, "File_0_is_not_a_module_2306", "File '{0}' is not a module."),
4453         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."),
4454         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."),
4455         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."),
4456         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."),
4457         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."),
4458         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."),
4459         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."),
4460         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)."),
4461         Type_0_is_not_generic: diag(2315, ts.DiagnosticCategory.Error, "Type_0_is_not_generic_2315", "Type '{0}' is not generic."),
4462         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."),
4463         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)."),
4464         Cannot_find_global_type_0: diag(2318, ts.DiagnosticCategory.Error, "Cannot_find_global_type_0_2318", "Cannot find global type '{0}'."),
4465         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."),
4466         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}'."),
4467         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}'."),
4468         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}'."),
4469         Cannot_redeclare_exported_variable_0: diag(2323, ts.DiagnosticCategory.Error, "Cannot_redeclare_exported_variable_0_2323", "Cannot redeclare exported variable '{0}'."),
4470         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}'."),
4471         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}'."),
4472         Types_of_property_0_are_incompatible: diag(2326, ts.DiagnosticCategory.Error, "Types_of_property_0_are_incompatible_2326", "Types of property '{0}' are incompatible."),
4473         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}'."),
4474         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."),
4475         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}'."),
4476         Index_signatures_are_incompatible: diag(2330, ts.DiagnosticCategory.Error, "Index_signatures_are_incompatible_2330", "Index signatures are incompatible."),
4477         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."),
4478         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."),
4479         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."),
4480         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."),
4481         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."),
4482         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."),
4483         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."),
4484         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."),
4485         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}'."),
4486         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."),
4487         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}'."),
4488         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'."),
4489         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}'."),
4490         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}'."),
4491         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}'."),
4492         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."),
4493         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."),
4494         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'?"),
4495         This_expression_is_not_callable: diag(2349, ts.DiagnosticCategory.Error, "This_expression_is_not_callable_2349", "This expression is not callable."),
4496         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."),
4497         This_expression_is_not_constructable: diag(2351, ts.DiagnosticCategory.Error, "This_expression_is_not_constructable_2351", "This expression is not constructable."),
4498         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."),
4499         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}'."),
4500         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."),
4501         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."),
4502         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."),
4503         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."),
4504         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."),
4505         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."),
4506         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'."),
4507         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."),
4508         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."),
4509         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."),
4510         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."),
4511         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}'."),
4512         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'."),
4513         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."),
4514         Type_parameter_name_cannot_be_0: diag(2368, ts.DiagnosticCategory.Error, "Type_parameter_name_cannot_be_0_2368", "Type parameter name cannot be '{0}'."),
4515         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."),
4516         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."),
4517         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."),
4518         Parameter_0_cannot_reference_itself: diag(2372, ts.DiagnosticCategory.Error, "Parameter_0_cannot_reference_itself_2372", "Parameter '{0}' cannot reference itself."),
4519         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."),
4520         Duplicate_string_index_signature: diag(2374, ts.DiagnosticCategory.Error, "Duplicate_string_index_signature_2374", "Duplicate string index signature."),
4521         Duplicate_number_index_signature: diag(2375, ts.DiagnosticCategory.Error, "Duplicate_number_index_signature_2375", "Duplicate number index signature."),
4522         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."),
4523         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."),
4524         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."),
4525         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."),
4526         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."),
4527         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."),
4528         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."),
4529         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."),
4530         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."),
4531         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."),
4532         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."),
4533         Function_overload_must_be_static: diag(2387, ts.DiagnosticCategory.Error, "Function_overload_must_be_static_2387", "Function overload must be static."),
4534         Function_overload_must_not_be_static: diag(2388, ts.DiagnosticCategory.Error, "Function_overload_must_not_be_static_2388", "Function overload must not be static."),
4535         Function_implementation_name_must_be_0: diag(2389, ts.DiagnosticCategory.Error, "Function_implementation_name_must_be_0_2389", "Function implementation name must be '{0}'."),
4536         Constructor_implementation_is_missing: diag(2390, ts.DiagnosticCategory.Error, "Constructor_implementation_is_missing_2390", "Constructor implementation is missing."),
4537         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."),
4538         Multiple_constructor_implementations_are_not_allowed: diag(2392, ts.DiagnosticCategory.Error, "Multiple_constructor_implementations_are_not_allowed_2392", "Multiple constructor implementations are not allowed."),
4539         Duplicate_function_implementation: diag(2393, ts.DiagnosticCategory.Error, "Duplicate_function_implementation_2393", "Duplicate function implementation."),
4540         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."),
4541         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."),
4542         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."),
4543         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}'."),
4544         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."),
4545         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."),
4546         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."),
4547         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."),
4548         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."),
4549         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}'."),
4550         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."),
4551         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'."),
4552         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."),
4553         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}'."),
4554         Setters_cannot_return_a_value: diag(2408, ts.DiagnosticCategory.Error, "Setters_cannot_return_a_value_2408", "Setters cannot return a value."),
4555         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."),
4556         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'."),
4557         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}'."),
4558         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}'."),
4559         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}'."),
4560         Class_name_cannot_be_0: diag(2414, ts.DiagnosticCategory.Error, "Class_name_cannot_be_0_2414", "Class name cannot be '{0}'."),
4561         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}'."),
4562         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}'."),
4563         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}'."),
4564         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}'."),
4565         Class_0_incorrectly_implements_interface_1: diag(2420, ts.DiagnosticCategory.Error, "Class_0_incorrectly_implements_interface_1_2420", "Class '{0}' incorrectly implements interface '{1}'."),
4566         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."),
4567         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."),
4568         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."),
4569         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."),
4570         Interface_name_cannot_be_0: diag(2427, ts.DiagnosticCategory.Error, "Interface_name_cannot_be_0_2427", "Interface name cannot be '{0}'."),
4571         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."),
4572         Interface_0_incorrectly_extends_interface_1: diag(2430, ts.DiagnosticCategory.Error, "Interface_0_incorrectly_extends_interface_1_2430", "Interface '{0}' incorrectly extends interface '{1}'."),
4573         Enum_name_cannot_be_0: diag(2431, ts.DiagnosticCategory.Error, "Enum_name_cannot_be_0_2431", "Enum name cannot be '{0}'."),
4574         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."),
4575         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."),
4576         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."),
4577         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."),
4578         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."),
4579         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."),
4580         Import_name_cannot_be_0: diag(2438, ts.DiagnosticCategory.Error, "Import_name_cannot_be_0_2438", "Import name cannot be '{0}'."),
4581         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."),
4582         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}'."),
4583         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."),
4584         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}'."),
4585         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}'."),
4586         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}'."),
4587         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."),
4588         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}'."),
4589         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."),
4590         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."),
4591         Class_0_used_before_its_declaration: diag(2449, ts.DiagnosticCategory.Error, "Class_0_used_before_its_declaration_2449", "Class '{0}' used before its declaration."),
4592         Enum_0_used_before_its_declaration: diag(2450, ts.DiagnosticCategory.Error, "Enum_0_used_before_its_declaration_2450", "Enum '{0}' used before its declaration."),
4593         Cannot_redeclare_block_scoped_variable_0: diag(2451, ts.DiagnosticCategory.Error, "Cannot_redeclare_block_scoped_variable_0_2451", "Cannot redeclare block-scoped variable '{0}'."),
4594         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."),
4595         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."),
4596         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."),
4597         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}'."),
4598         Type_alias_0_circularly_references_itself: diag(2456, ts.DiagnosticCategory.Error, "Type_alias_0_circularly_references_itself_2456", "Type alias '{0}' circularly references itself."),
4599         Type_alias_name_cannot_be_0: diag(2457, ts.DiagnosticCategory.Error, "Type_alias_name_cannot_be_0_2457", "Type alias name cannot be '{0}'."),
4600         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."),
4601         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."),
4602         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}'."),
4603         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."),
4604         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."),
4605         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."),
4606         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'."),
4607         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."),
4608         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."),
4609         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."),
4610         Cannot_find_global_value_0: diag(2468, ts.DiagnosticCategory.Error, "Cannot_find_global_value_0_2468", "Cannot find global value '{0}'."),
4611         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'."),
4612         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."),
4613         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'."),
4614         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."),
4615         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."),
4616         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."),
4617         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."),
4618         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."),
4619         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."),
4620         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'."),
4621         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}'."),
4622         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."),
4623         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}'."),
4624         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."),
4625         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}'."),
4626         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."),
4627         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."),
4628         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."),
4629         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."),
4630         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."),
4631         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."),
4632         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}'."),
4633         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."),
4634         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."),
4635         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."),
4636         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."),
4637         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 *'."),
4638         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."),
4639         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."),
4640         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."),
4641         _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."),
4642         Cannot_find_namespace_0: diag(2503, ts.DiagnosticCategory.Error, "Cannot_find_namespace_0_2503", "Cannot find namespace '{0}'."),
4643         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."),
4644         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."),
4645         _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."),
4646         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."),
4647         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."),
4648         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."),
4649         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."),
4650         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."),
4651         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."),
4652         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."),
4653         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."),
4654         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}'."),
4655         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."),
4656         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."),
4657         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."),
4658         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."),
4659         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."),
4660         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."),
4661         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."),
4662         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."),
4663         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."),
4664         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."),
4665         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."),
4666         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."),
4667         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."),
4668         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."),
4669         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."),
4670         Object_is_possibly_null: diag(2531, ts.DiagnosticCategory.Error, "Object_is_possibly_null_2531", "Object is possibly 'null'."),
4671         Object_is_possibly_undefined: diag(2532, ts.DiagnosticCategory.Error, "Object_is_possibly_undefined_2532", "Object is possibly 'undefined'."),
4672         Object_is_possibly_null_or_undefined: diag(2533, ts.DiagnosticCategory.Error, "Object_is_possibly_null_or_undefined_2533", "Object is possibly 'null' or 'undefined'."),
4673         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."),
4674         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."),
4675         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}'."),
4676         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}'."),
4677         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."),
4678         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."),
4679         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."),
4680         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."),
4681         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."),
4682         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."),
4683         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."),
4684         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[]'."),
4685         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."),
4686         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."),
4687         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."),
4688         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}'?"),
4689         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}'?"),
4690         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."),
4691         Expected_0_arguments_but_got_1: diag(2554, ts.DiagnosticCategory.Error, "Expected_0_arguments_but_got_1_2554", "Expected {0} arguments, but got {1}."),
4692         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}."),
4693         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."),
4694         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."),
4695         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}."),
4696         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}'."),
4697         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?"),
4698         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}'?"),
4699         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."),
4700         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."),
4701         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."),
4702         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."),
4703         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."),
4704         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."),
4705         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."),
4706         Object_is_of_type_unknown: diag(2571, ts.DiagnosticCategory.Error, "Object_is_of_type_unknown_2571", "Object is of type 'unknown'."),
4707         Rest_signatures_are_incompatible: diag(2572, ts.DiagnosticCategory.Error, "Rest_signatures_are_incompatible_2572", "Rest signatures are incompatible."),
4708         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."),
4709         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."),
4710         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."),
4711         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}'"),
4712         Return_type_annotation_circularly_references_itself: diag(2577, ts.DiagnosticCategory.Error, "Return_type_annotation_circularly_references_itself_2577", "Return type annotation circularly references itself."),
4713         Unused_ts_expect_error_directive: diag(2578, ts.DiagnosticCategory.Error, "Unused_ts_expect_error_directive_2578", "Unused '@ts-expect-error' directive."),
4714         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`."),
4715         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`."),
4716         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`."),
4717         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."),
4718         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'."),
4719         _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."),
4720         Enum_type_0_circularly_references_itself: diag(2586, ts.DiagnosticCategory.Error, "Enum_type_0_circularly_references_itself_2586", "Enum type '{0}' circularly references itself."),
4721         JSDoc_type_0_circularly_references_itself: diag(2587, ts.DiagnosticCategory.Error, "JSDoc_type_0_circularly_references_itself_2587", "JSDoc type '{0}' circularly references itself."),
4722         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."),
4723         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."),
4724         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."),
4725         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."),
4726         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."),
4727         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."),
4728         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."),
4729         _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."),
4730         _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."),
4731         _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."),
4732         _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."),
4733         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."),
4734         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."),
4735         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."),
4736         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}'."),
4737         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."),
4738         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."),
4739         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."),
4740         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."),
4741         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."),
4742         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."),
4743         _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."),
4744         _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."),
4745         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."),
4746         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?"),
4747         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?"),
4748         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}'."),
4749         _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."),
4750         _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."),
4751         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."),
4752         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."),
4753         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."),
4754         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}'."),
4755         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."),
4756         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."),
4757         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."),
4758         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}'."),
4759         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."),
4760         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."),
4761         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."),
4762         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}'?"),
4763         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}'?"),
4764         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."),
4765         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."),
4766         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."),
4767         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."),
4768         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."),
4769         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."),
4770         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."),
4771         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."),
4772         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."),
4773         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."),
4774         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."),
4775         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."),
4776         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."),
4777         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."),
4778         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}'."),
4779         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'."),
4780         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."),
4781         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."),
4782         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."),
4783         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."),
4784         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}'."),
4785         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."),
4786         _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."),
4787         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."),
4788         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}'."),
4789         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'?"),
4790         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."),
4791         _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."),
4792         _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."),
4793         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}'."),
4794         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),
4795         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?"),
4796         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."),
4797         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."),
4798         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}'."),
4799         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."),
4800         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."),
4801         _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."),
4802         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."),
4803         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."),
4804         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."),
4805         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."),
4806         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."),
4807         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."),
4808         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."),
4809         _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."),
4810         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."),
4811         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."),
4812         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}\"]'?"),
4813         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."),
4814         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."),
4815         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."),
4816         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}'."),
4817         Duplicate_property_0: diag(2718, ts.DiagnosticCategory.Error, "Duplicate_property_0_2718", "Duplicate property '{0}'."),
4818         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."),
4819         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?"),
4820         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'."),
4821         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'."),
4822         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'."),
4823         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}'?"),
4824         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}."),
4825         Cannot_find_lib_definition_for_0: diag(2726, ts.DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_2726", "Cannot find lib definition for '{0}'."),
4826         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}'?"),
4827         _0_is_declared_here: diag(2728, ts.DiagnosticCategory.Message, "_0_is_declared_here_2728", "'{0}' is declared here."),
4828         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."),
4829         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."),
4830         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(...)'."),
4831         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"),
4832         Property_0_was_also_declared_here: diag(2733, ts.DiagnosticCategory.Error, "Property_0_was_also_declared_here_2733", "Property '{0}' was also declared here."),
4833         Are_you_missing_a_semicolon: diag(2734, ts.DiagnosticCategory.Error, "Are_you_missing_a_semicolon_2734", "Are you missing a semicolon?"),
4834         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}'?"),
4835         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}'."),
4836         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."),
4837         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."),
4838         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}"),
4839         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."),
4840         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}'."),
4841         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."),
4842         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."),
4843         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."),
4844         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."),
4845         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."),
4846         _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}'."),
4847         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."),
4848         _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}'?"),
4849         The_implementation_signature_is_declared_here: diag(2750, ts.DiagnosticCategory.Error, "The_implementation_signature_is_declared_here_2750", "The implementation signature is declared here."),
4850         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."),
4851         The_first_export_default_is_here: diag(2752, ts.DiagnosticCategory.Error, "The_first_export_default_is_here_2752", "The first export default is here."),
4852         Another_export_default_is_here: diag(2753, ts.DiagnosticCategory.Error, "Another_export_default_is_here_2753", "Another export default is here."),
4853         super_may_not_use_type_arguments: diag(2754, ts.DiagnosticCategory.Error, "super_may_not_use_type_arguments_2754", "'super' may not use type arguments."),
4854         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."),
4855         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."),
4856         Type_0_has_no_call_signatures: diag(2757, ts.DiagnosticCategory.Error, "Type_0_has_no_call_signatures_2757", "Type '{0}' has no call signatures."),
4857         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."),
4858         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."),
4859         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."),
4860         Type_0_has_no_construct_signatures: diag(2761, ts.DiagnosticCategory.Error, "Type_0_has_no_construct_signatures_2761", "Type '{0}' has no construct signatures."),
4861         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."),
4862         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}'."),
4863         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}'."),
4864         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}'."),
4865         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}'."),
4866         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."),
4867         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."),
4868         No_overload_matches_this_call: diag(2769, ts.DiagnosticCategory.Error, "No_overload_matches_this_call_2769", "No overload matches this call."),
4869         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."),
4870         The_last_overload_is_declared_here: diag(2771, ts.DiagnosticCategory.Error, "The_last_overload_is_declared_here_2771", "The last overload is declared here."),
4871         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."),
4872         Did_you_forget_to_use_await: diag(2773, ts.DiagnosticCategory.Error, "Did_you_forget_to_use_await_2773", "Did you forget to use 'await'?"),
4873         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?"),
4874         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."),
4875         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."),
4876         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."),
4877         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."),
4878         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."),
4879         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."),
4880         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."),
4881         _0_needs_an_explicit_type_annotation: diag(2782, ts.DiagnosticCategory.Message, "_0_needs_an_explicit_type_annotation_2782", "'{0}' needs an explicit type annotation."),
4882         _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."),
4883         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."),
4884         This_spread_always_overwrites_this_property: diag(2785, ts.DiagnosticCategory.Error, "This_spread_always_overwrites_this_property_2785", "This spread always overwrites this property."),
4885         _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."),
4886         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."),
4887         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."),
4888         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."),
4889         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}'."),
4890         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}'."),
4891         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}'."),
4892         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}'."),
4893         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}'."),
4894         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}'."),
4895         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}'."),
4896         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}'."),
4897         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}'."),
4898         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}'."),
4899         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}'."),
4900         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}'."),
4901         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."),
4902         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}'."),
4903         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}'."),
4904         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."),
4905         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}'."),
4906         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}'."),
4907         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."),
4908         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}'."),
4909         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}'."),
4910         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}'."),
4911         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}'."),
4912         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}'."),
4913         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}'."),
4914         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}'."),
4915         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}'."),
4916         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."),
4917         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}'."),
4918         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}'."),
4919         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."),
4920         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}'."),
4921         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}'."),
4922         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}'."),
4923         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}'."),
4924         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}'."),
4925         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}'."),
4926         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}'."),
4927         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}'."),
4928         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."),
4929         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}'."),
4930         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}'."),
4931         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."),
4932         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}'."),
4933         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}'."),
4934         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}'."),
4935         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}'."),
4936         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."),
4937         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}'."),
4938         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}'."),
4939         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."),
4940         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}'."),
4941         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}'."),
4942         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}'."),
4943         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}'."),
4944         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}'."),
4945         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}'."),
4946         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."),
4947         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}'."),
4948         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}'."),
4949         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."),
4950         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}'."),
4951         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}'."),
4952         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}'."),
4953         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}'."),
4954         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."),
4955         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}'."),
4956         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}'."),
4957         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}'."),
4958         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}'."),
4959         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}'."),
4960         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."),
4961         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}'."),
4962         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}'."),
4963         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."),
4964         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."),
4965         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}'."),
4966         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}'."),
4967         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."),
4968         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}'."),
4969         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}'."),
4970         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}'."),
4971         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}'."),
4972         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}'."),
4973         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}'."),
4974         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."),
4975         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}'."),
4976         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}'."),
4977         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."),
4978         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."),
4979         Tuple_type_arguments_circularly_reference_themselves: diag(4110, ts.DiagnosticCategory.Error, "Tuple_type_arguments_circularly_reference_themselves_4110", "Tuple type arguments circularly reference themselves."),
4980         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."),
4981         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."),
4982         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}'."),
4983         Cannot_read_file_0_Colon_1: diag(5012, ts.DiagnosticCategory.Error, "Cannot_read_file_0_Colon_1_5012", "Cannot read file '{0}': {1}."),
4984         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}."),
4985         Unknown_compiler_option_0: diag(5023, ts.DiagnosticCategory.Error, "Unknown_compiler_option_0_5023", "Unknown compiler option '{0}'."),
4986         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}."),
4987         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}'?"),
4988         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}."),
4989         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."),
4990         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."),
4991         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'."),
4992         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."),
4993         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}'."),
4994         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}'."),
4995         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}'."),
4996         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."),
4997         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."),
4998         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}'."),
4999         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}'."),
5000         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."),
5001         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."),
5002         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."),
5003         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."),
5004         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."),
5005         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}'."),
5006         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}'."),
5007         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."),
5008         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."),
5009         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."),
5010         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}'."),
5011         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."),
5012         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'."),
5013         Unknown_build_option_0: diag(5072, ts.DiagnosticCategory.Error, "Unknown_build_option_0_5072", "Unknown build option '{0}'."),
5014         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}."),
5015         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."),
5016         _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}'."),
5017         _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."),
5018         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}'?"),
5019         Unknown_watch_option_0: diag(5078, ts.DiagnosticCategory.Error, "Unknown_watch_option_0_5078", "Unknown watch option '{0}'."),
5020         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}'?"),
5021         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}."),
5022         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}."),
5023         _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}'."),
5024         Cannot_read_file_0: diag(5083, ts.DiagnosticCategory.Error, "Cannot_read_file_0_5083", "Cannot read file '{0}'."),
5025         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."),
5026         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."),
5027         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."),
5028         Generates_corresponding_d_ts_file: diag(6002, ts.DiagnosticCategory.Message, "Generates_corresponding_d_ts_file_6002", "Generates corresponding '.d.ts' file."),
5029         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."),
5030         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."),
5031         Watch_input_files: diag(6005, ts.DiagnosticCategory.Message, "Watch_input_files_6005", "Watch input files."),
5032         Redirect_output_structure_to_the_directory: diag(6006, ts.DiagnosticCategory.Message, "Redirect_output_structure_to_the_directory_6006", "Redirect output structure to the directory."),
5033         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."),
5034         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."),
5035         Do_not_emit_comments_to_output: diag(6009, ts.DiagnosticCategory.Message, "Do_not_emit_comments_to_output_6009", "Do not emit comments to output."),
5036         Do_not_emit_outputs: diag(6010, ts.DiagnosticCategory.Message, "Do_not_emit_outputs_6010", "Do not emit outputs."),
5037         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."),
5038         Skip_type_checking_of_declaration_files: diag(6012, ts.DiagnosticCategory.Message, "Skip_type_checking_of_declaration_files_6012", "Skip type checking of declaration files."),
5039         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."),
5040         Only_emit_d_ts_declaration_files: diag(6014, ts.DiagnosticCategory.Message, "Only_emit_d_ts_declaration_files_6014", "Only emit '.d.ts' declaration files."),
5041         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'."),
5042         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'."),
5043         Print_this_message: diag(6017, ts.DiagnosticCategory.Message, "Print_this_message_6017", "Print this message."),
5044         Print_the_compiler_s_version: diag(6019, ts.DiagnosticCategory.Message, "Print_the_compiler_s_version_6019", "Print the compiler's version."),
5045         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'."),
5046         Syntax_Colon_0: diag(6023, ts.DiagnosticCategory.Message, "Syntax_Colon_0_6023", "Syntax: {0}"),
5047         options: diag(6024, ts.DiagnosticCategory.Message, "options_6024", "options"),
5048         file: diag(6025, ts.DiagnosticCategory.Message, "file_6025", "file"),
5049         Examples_Colon_0: diag(6026, ts.DiagnosticCategory.Message, "Examples_Colon_0_6026", "Examples: {0}"),
5050         Options_Colon: diag(6027, ts.DiagnosticCategory.Message, "Options_Colon_6027", "Options:"),
5051         Version_0: diag(6029, ts.DiagnosticCategory.Message, "Version_0_6029", "Version {0}"),
5052         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."),
5053         Starting_compilation_in_watch_mode: diag(6031, ts.DiagnosticCategory.Message, "Starting_compilation_in_watch_mode_6031", "Starting compilation in watch mode..."),
5054         File_change_detected_Starting_incremental_compilation: diag(6032, ts.DiagnosticCategory.Message, "File_change_detected_Starting_incremental_compilation_6032", "File change detected. Starting incremental compilation..."),
5055         KIND: diag(6034, ts.DiagnosticCategory.Message, "KIND_6034", "KIND"),
5056         FILE: diag(6035, ts.DiagnosticCategory.Message, "FILE_6035", "FILE"),
5057         VERSION: diag(6036, ts.DiagnosticCategory.Message, "VERSION_6036", "VERSION"),
5058         LOCATION: diag(6037, ts.DiagnosticCategory.Message, "LOCATION_6037", "LOCATION"),
5059         DIRECTORY: diag(6038, ts.DiagnosticCategory.Message, "DIRECTORY_6038", "DIRECTORY"),
5060         STRATEGY: diag(6039, ts.DiagnosticCategory.Message, "STRATEGY_6039", "STRATEGY"),
5061         FILE_OR_DIRECTORY: diag(6040, ts.DiagnosticCategory.Message, "FILE_OR_DIRECTORY_6040", "FILE OR DIRECTORY"),
5062         Generates_corresponding_map_file: diag(6043, ts.DiagnosticCategory.Message, "Generates_corresponding_map_file_6043", "Generates corresponding '.map' file."),
5063         Compiler_option_0_expects_an_argument: diag(6044, ts.DiagnosticCategory.Error, "Compiler_option_0_expects_an_argument_6044", "Compiler option '{0}' expects an argument."),
5064         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}'."),
5065         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}."),
5066         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}'."),
5067         Unsupported_locale_0: diag(6049, ts.DiagnosticCategory.Error, "Unsupported_locale_0_6049", "Unsupported locale '{0}'."),
5068         Unable_to_open_file_0: diag(6050, ts.DiagnosticCategory.Error, "Unable_to_open_file_0_6050", "Unable to open file '{0}'."),
5069         Corrupted_locale_file_0: diag(6051, ts.DiagnosticCategory.Error, "Corrupted_locale_file_0_6051", "Corrupted locale file {0}."),
5070         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."),
5071         File_0_not_found: diag(6053, ts.DiagnosticCategory.Error, "File_0_not_found_6053", "File '{0}' not found."),
5072         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}."),
5073         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."),
5074         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."),
5075         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."),
5076         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."),
5077         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)."),
5078         NEWLINE: diag(6061, ts.DiagnosticCategory.Message, "NEWLINE_6061", "NEWLINE"),
5079         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."),
5080         Enables_experimental_support_for_ES7_decorators: diag(6065, ts.DiagnosticCategory.Message, "Enables_experimental_support_for_ES7_decorators_6065", "Enables experimental support for ES7 decorators."),
5081         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."),
5082         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."),
5083         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)."),
5084         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."),
5085         Successfully_created_a_tsconfig_json_file: diag(6071, ts.DiagnosticCategory.Message, "Successfully_created_a_tsconfig_json_file_6071", "Successfully created a tsconfig.json file."),
5086         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."),
5087         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)."),
5088         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."),
5089         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."),
5090         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."),
5091         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."),
5092         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."),
5093         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."),
5094         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'."),
5095         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."),
5096         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}."),
5097         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."),
5098         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"),
5099         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."),
5100         Resolving_module_0_from_1: diag(6086, ts.DiagnosticCategory.Message, "Resolving_module_0_from_1_6086", "======== Resolving module '{0}' from '{1}'. ========"),
5101         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}'."),
5102         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}'."),
5103         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}'. ========"),
5104         Module_name_0_was_not_resolved: diag(6090, ts.DiagnosticCategory.Message, "Module_name_0_was_not_resolved_6090", "======== Module name '{0}' was not resolved. ========"),
5105         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}'."),
5106         Module_name_0_matched_pattern_1: diag(6092, ts.DiagnosticCategory.Message, "Module_name_0_matched_pattern_1_6092", "Module name '{0}', matched pattern '{1}'."),
5107         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}'."),
5108         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}'."),
5109         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}'."),
5110         File_0_does_not_exist: diag(6096, ts.DiagnosticCategory.Message, "File_0_does_not_exist_6096", "File '{0}' does not exist."),
5111         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."),
5112         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}'."),
5113         Found_package_json_at_0: diag(6099, ts.DiagnosticCategory.Message, "Found_package_json_at_0_6099", "Found 'package.json' at '{0}'."),
5114         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."),
5115         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}'."),
5116         Allow_javascript_files_to_be_compiled: diag(6102, ts.DiagnosticCategory.Message, "Allow_javascript_files_to_be_compiled_6102", "Allow javascript files to be compiled."),
5117         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."),
5118         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}'."),
5119         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}'."),
5120         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}'."),
5121         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}'."),
5122         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}'."),
5123         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}'."),
5124         Trying_other_entries_in_rootDirs: diag(6110, ts.DiagnosticCategory.Message, "Trying_other_entries_in_rootDirs_6110", "Trying other entries in 'rootDirs'."),
5125         Module_resolution_using_rootDirs_has_failed: diag(6111, ts.DiagnosticCategory.Message, "Module_resolution_using_rootDirs_has_failed_6111", "Module resolution using 'rootDirs' has failed."),
5126         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."),
5127         Enable_strict_null_checks: diag(6113, ts.DiagnosticCategory.Message, "Enable_strict_null_checks_6113", "Enable strict null checks."),
5128         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'?"),
5129         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."),
5130         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}'. ========"),
5131         Resolving_using_primary_search_paths: diag(6117, ts.DiagnosticCategory.Message, "Resolving_using_primary_search_paths_6117", "Resolving using primary search paths..."),
5132         Resolving_from_node_modules_folder: diag(6118, ts.DiagnosticCategory.Message, "Resolving_from_node_modules_folder_6118", "Resolving from node_modules folder..."),
5133         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}. ========"),
5134         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. ========"),
5135         Resolving_with_primary_search_path_0: diag(6121, ts.DiagnosticCategory.Message, "Resolving_with_primary_search_path_0_6121", "Resolving with primary search path '{0}'."),
5136         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."),
5137         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. ========"),
5138         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."),
5139         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}'."),
5140         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."),
5141         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}'. ========"),
5142         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. ========"),
5143         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}'."),
5144         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'."),
5145         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."),
5146         _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),
5147         Report_errors_on_unused_locals: diag(6134, ts.DiagnosticCategory.Message, "Report_errors_on_unused_locals_6134", "Report errors on unused locals."),
5148         Report_errors_on_unused_parameters: diag(6135, ts.DiagnosticCategory.Message, "Report_errors_on_unused_parameters_6135", "Report errors on unused parameters."),
5149         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."),
5150         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}'."),
5151         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),
5152         Import_emit_helpers_from_tslib: diag(6139, ts.DiagnosticCategory.Message, "Import_emit_helpers_from_tslib_6139", "Import emit helpers from 'tslib'."),
5153         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}'."),
5154         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."),
5155         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."),
5156         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}'."),
5157         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."),
5158         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'."),
5159         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}'."),
5160         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."),
5161         Show_diagnostic_information: diag(6149, ts.DiagnosticCategory.Message, "Show_diagnostic_information_6149", "Show diagnostic information."),
5162         Show_verbose_diagnostic_information: diag(6150, ts.DiagnosticCategory.Message, "Show_verbose_diagnostic_information_6150", "Show verbose diagnostic information."),
5163         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."),
5164         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."),
5165         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')."),
5166         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."),
5167         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."),
5168         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')"),
5169         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."),
5170         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)."),
5171         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."),
5172         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."),
5173         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."),
5174         Disable_size_limitations_on_JavaScript_projects: diag(6162, ts.DiagnosticCategory.Message, "Disable_size_limitations_on_JavaScript_projects_6162", "Disable size limitations on JavaScript projects."),
5175         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."),
5176         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."),
5177         Do_not_truncate_error_messages: diag(6165, ts.DiagnosticCategory.Message, "Do_not_truncate_error_messages_6165", "Do not truncate error messages."),
5178         Output_directory_for_generated_declaration_files: diag(6166, ts.DiagnosticCategory.Message, "Output_directory_for_generated_declaration_files_6166", "Output directory for generated declaration files."),
5179         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'."),
5180         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."),
5181         Show_all_compiler_options: diag(6169, ts.DiagnosticCategory.Message, "Show_all_compiler_options_6169", "Show all compiler options."),
5182         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"),
5183         Command_line_Options: diag(6171, ts.DiagnosticCategory.Message, "Command_line_Options_6171", "Command-line Options"),
5184         Basic_Options: diag(6172, ts.DiagnosticCategory.Message, "Basic_Options_6172", "Basic Options"),
5185         Strict_Type_Checking_Options: diag(6173, ts.DiagnosticCategory.Message, "Strict_Type_Checking_Options_6173", "Strict Type-Checking Options"),
5186         Module_Resolution_Options: diag(6174, ts.DiagnosticCategory.Message, "Module_Resolution_Options_6174", "Module Resolution Options"),
5187         Source_Map_Options: diag(6175, ts.DiagnosticCategory.Message, "Source_Map_Options_6175", "Source Map Options"),
5188         Additional_Checks: diag(6176, ts.DiagnosticCategory.Message, "Additional_Checks_6176", "Additional Checks"),
5189         Experimental_Options: diag(6177, ts.DiagnosticCategory.Message, "Experimental_Options_6177", "Experimental Options"),
5190         Advanced_Options: diag(6178, ts.DiagnosticCategory.Message, "Advanced_Options_6178", "Advanced Options"),
5191         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'."),
5192         Enable_all_strict_type_checking_options: diag(6180, ts.DiagnosticCategory.Message, "Enable_all_strict_type_checking_options_6180", "Enable all strict type-checking options."),
5193         List_of_language_service_plugins: diag(6181, ts.DiagnosticCategory.Message, "List_of_language_service_plugins_6181", "List of language service plugins."),
5194         Scoped_package_detected_looking_in_0: diag(6182, ts.DiagnosticCategory.Message, "Scoped_package_detected_looking_in_0_6182", "Scoped package detected, looking in '{0}'"),
5195         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."),
5196         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."),
5197         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."),
5198         Enable_strict_checking_of_function_types: diag(6186, ts.DiagnosticCategory.Message, "Enable_strict_checking_of_function_types_6186", "Enable strict checking of function types."),
5199         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."),
5200         Numeric_separators_are_not_allowed_here: diag(6188, ts.DiagnosticCategory.Error, "Numeric_separators_are_not_allowed_here_6188", "Numeric separators are not allowed here."),
5201         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."),
5202         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."),
5203         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),
5204         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."),
5205         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."),
5206         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)."),
5207         _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),
5208         Include_modules_imported_with_json_extension: diag(6197, ts.DiagnosticCategory.Message, "Include_modules_imported_with_json_extension_6197", "Include modules imported with '.json' extension"),
5209         All_destructured_elements_are_unused: diag(6198, ts.DiagnosticCategory.Error, "All_destructured_elements_are_unused_6198", "All destructured elements are unused.", true),
5210         All_variables_are_unused: diag(6199, ts.DiagnosticCategory.Error, "All_variables_are_unused_6199", "All variables are unused.", true),
5211         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}"),
5212         Conflicts_are_in_this_file: diag(6201, ts.DiagnosticCategory.Message, "Conflicts_are_in_this_file_6201", "Conflicts are in this file."),
5213         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}"),
5214         _0_was_also_declared_here: diag(6203, ts.DiagnosticCategory.Message, "_0_was_also_declared_here_6203", "'{0}' was also declared here."),
5215         and_here: diag(6204, ts.DiagnosticCategory.Message, "and_here_6204", "and here."),
5216         All_type_parameters_are_unused: diag(6205, ts.DiagnosticCategory.Error, "All_type_parameters_are_unused_6205", "All type parameters are unused"),
5217         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."),
5218         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}'."),
5219         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}'."),
5220         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."),
5221         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."),
5222         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."),
5223         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?"),
5224         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?"),
5225         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."),
5226         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}'."),
5227         Found_1_error: diag(6216, ts.DiagnosticCategory.Message, "Found_1_error_6216", "Found 1 error."),
5228         Found_0_errors: diag(6217, ts.DiagnosticCategory.Message, "Found_0_errors_6217", "Found {0} errors."),
5229         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}'. ========"),
5230         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}. ========"),
5231         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."),
5232         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."),
5233         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."),
5234         Generates_a_CPU_profile: diag(6223, ts.DiagnosticCategory.Message, "Generates_a_CPU_profile_6223", "Generates a CPU profile."),
5235         Disable_solution_searching_for_this_project: diag(6224, ts.DiagnosticCategory.Message, "Disable_solution_searching_for_this_project_6224", "Disable solution searching for this project."),
5236         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'."),
5237         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'."),
5238         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'."),
5239         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."),
5240         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}'."),
5241         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."),
5242         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}."),
5243         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."),
5244         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."),
5245         Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"),
5246         Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"),
5247         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."),
5248         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}'."),
5249         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."),
5250         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."),
5251         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"),
5252         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"),
5253         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}'"),
5254         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}'"),
5255         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"),
5256         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"),
5257         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"),
5258         Projects_in_this_build_Colon_0: diag(6355, ts.DiagnosticCategory.Message, "Projects_in_this_build_Colon_0_6355", "Projects in this build: {0}"),
5259         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}"),
5260         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}'"),
5261         Building_project_0: diag(6358, ts.DiagnosticCategory.Message, "Building_project_0_6358", "Building project '{0}'..."),
5262         Updating_output_timestamps_of_project_0: diag(6359, ts.DiagnosticCategory.Message, "Updating_output_timestamps_of_project_0_6359", "Updating output timestamps of project '{0}'..."),
5263         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"),
5264         Project_0_is_up_to_date: diag(6361, ts.DiagnosticCategory.Message, "Project_0_is_up_to_date_6361", "Project '{0}' is up to date"),
5265         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"),
5266         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"),
5267         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"),
5268         Delete_the_outputs_of_all_projects: diag(6365, ts.DiagnosticCategory.Message, "Delete_the_outputs_of_all_projects_6365", "Delete the outputs of all projects"),
5269         Enable_verbose_logging: diag(6366, ts.DiagnosticCategory.Message, "Enable_verbose_logging_6366", "Enable verbose logging"),
5270         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')"),
5271         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"),
5272         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."),
5273         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."),
5274         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}'..."),
5275         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"),
5276         Updating_output_of_project_0: diag(6373, ts.DiagnosticCategory.Message, "Updating_output_of_project_0_6373", "Updating output of project '{0}'..."),
5277         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}'"),
5278         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}'"),
5279         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}'"),
5280         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}'"),
5281         Enable_incremental_compilation: diag(6378, ts.DiagnosticCategory.Message, "Enable_incremental_compilation_6378", "Enable incremental compilation"),
5282         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."),
5283         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"),
5284         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}'"),
5285         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"),
5286         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"),
5287         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."),
5288         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}'"),
5289         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."),
5290         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."),
5291         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."),
5292         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?"),
5293         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."),
5294         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."),
5295         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."),
5296         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."),
5297         _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."),
5298         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."),
5299         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."),
5300         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."),
5301         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'."),
5302         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."),
5303         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."),
5304         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."),
5305         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."),
5306         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."),
5307         _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."),
5308         _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."),
5309         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."),
5310         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."),
5311         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."),
5312         Unreachable_code_detected: diag(7027, ts.DiagnosticCategory.Error, "Unreachable_code_detected_7027", "Unreachable code detected.", true),
5313         Unused_label: diag(7028, ts.DiagnosticCategory.Error, "Unused_label_7028", "Unused label.", true),
5314         Fallthrough_case_in_switch: diag(7029, ts.DiagnosticCategory.Error, "Fallthrough_case_in_switch_7029", "Fallthrough case in switch."),
5315         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."),
5316         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."),
5317         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."),
5318         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."),
5319         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."),
5320         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}';`"),
5321         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}'."),
5322         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'."),
5323         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."),
5324         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."),
5325         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}`"),
5326         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'."),
5327         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."),
5328         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."),
5329         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."),
5330         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."),
5331         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."),
5332         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."),
5333         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."),
5334         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."),
5335         _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."),
5336         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}'?"),
5337         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}'?"),
5338         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}'."),
5339         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}'."),
5340         _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."),
5341         You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."),
5342         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."),
5343         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."),
5344         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."),
5345         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."),
5346         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."),
5347         _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."),
5348         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."),
5349         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."),
5350         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."),
5351         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."),
5352         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."),
5353         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."),
5354         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."),
5355         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}'."),
5356         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}'."),
5357         Report_errors_in_js_files: diag(8019, ts.DiagnosticCategory.Message, "Report_errors_in_js_files_8019", "Report errors in .js files."),
5358         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."),
5359         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."),
5360         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."),
5361         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."),
5362         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."),
5363         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."),
5364         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."),
5365         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."),
5366         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."),
5367         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."),
5368         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."),
5369         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."),
5370         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}'."),
5371         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."),
5372         class_expressions_are_not_currently_supported: diag(9003, ts.DiagnosticCategory.Error, "class_expressions_are_not_currently_supported_9003", "'class' expressions are not currently supported."),
5373         Language_service_is_disabled: diag(9004, ts.DiagnosticCategory.Error, "Language_service_is_disabled_9004", "Language service is disabled."),
5374         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."),
5375         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."),
5376         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'."),
5377         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."),
5378         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}'."),
5379         JSX_attribute_expected: diag(17003, ts.DiagnosticCategory.Error, "JSX_attribute_expected_17003", "JSX attribute expected."),
5380         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."),
5381         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'."),
5382         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."),
5383         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."),
5384         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."),
5385         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."),
5386         Unknown_type_acquisition_option_0: diag(17010, ts.DiagnosticCategory.Error, "Unknown_type_acquisition_option_0_17010", "Unknown type acquisition option '{0}'."),
5387         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."),
5388         _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}'?"),
5389         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."),
5390         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."),
5391         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."),
5392         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"),
5393         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"),
5394         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}'?"),
5395         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}"),
5396         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."),
5397         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."),
5398         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}'."),
5399         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."),
5400         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."),
5401         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."),
5402         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."),
5403         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."),
5404         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."),
5405         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."),
5406         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."),
5407         Add_missing_super_call: diag(90001, ts.DiagnosticCategory.Message, "Add_missing_super_call_90001", "Add missing 'super()' call"),
5408         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"),
5409         Change_extends_to_implements: diag(90003, ts.DiagnosticCategory.Message, "Change_extends_to_implements_90003", "Change 'extends' to 'implements'"),
5410         Remove_unused_declaration_for_Colon_0: diag(90004, ts.DiagnosticCategory.Message, "Remove_unused_declaration_for_Colon_0_90004", "Remove unused declaration for: '{0}'"),
5411         Remove_import_from_0: diag(90005, ts.DiagnosticCategory.Message, "Remove_import_from_0_90005", "Remove import from '{0}'"),
5412         Implement_interface_0: diag(90006, ts.DiagnosticCategory.Message, "Implement_interface_0_90006", "Implement interface '{0}'"),
5413         Implement_inherited_abstract_class: diag(90007, ts.DiagnosticCategory.Message, "Implement_inherited_abstract_class_90007", "Implement inherited abstract class"),
5414         Add_0_to_unresolved_variable: diag(90008, ts.DiagnosticCategory.Message, "Add_0_to_unresolved_variable_90008", "Add '{0}.' to unresolved variable"),
5415         Remove_destructuring: diag(90009, ts.DiagnosticCategory.Message, "Remove_destructuring_90009", "Remove destructuring"),
5416         Remove_variable_statement: diag(90010, ts.DiagnosticCategory.Message, "Remove_variable_statement_90010", "Remove variable statement"),
5417         Remove_template_tag: diag(90011, ts.DiagnosticCategory.Message, "Remove_template_tag_90011", "Remove template tag"),
5418         Remove_type_parameters: diag(90012, ts.DiagnosticCategory.Message, "Remove_type_parameters_90012", "Remove type parameters"),
5419         Import_0_from_module_1: diag(90013, ts.DiagnosticCategory.Message, "Import_0_from_module_1_90013", "Import '{0}' from module \"{1}\""),
5420         Change_0_to_1: diag(90014, ts.DiagnosticCategory.Message, "Change_0_to_1_90014", "Change '{0}' to '{1}'"),
5421         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}\""),
5422         Declare_property_0: diag(90016, ts.DiagnosticCategory.Message, "Declare_property_0_90016", "Declare property '{0}'"),
5423         Add_index_signature_for_property_0: diag(90017, ts.DiagnosticCategory.Message, "Add_index_signature_for_property_0_90017", "Add index signature for property '{0}'"),
5424         Disable_checking_for_this_file: diag(90018, ts.DiagnosticCategory.Message, "Disable_checking_for_this_file_90018", "Disable checking for this file"),
5425         Ignore_this_error_message: diag(90019, ts.DiagnosticCategory.Message, "Ignore_this_error_message_90019", "Ignore this error message"),
5426         Initialize_property_0_in_the_constructor: diag(90020, ts.DiagnosticCategory.Message, "Initialize_property_0_in_the_constructor_90020", "Initialize property '{0}' in the constructor"),
5427         Initialize_static_property_0: diag(90021, ts.DiagnosticCategory.Message, "Initialize_static_property_0_90021", "Initialize static property '{0}'"),
5428         Change_spelling_to_0: diag(90022, ts.DiagnosticCategory.Message, "Change_spelling_to_0_90022", "Change spelling to '{0}'"),
5429         Declare_method_0: diag(90023, ts.DiagnosticCategory.Message, "Declare_method_0_90023", "Declare method '{0}'"),
5430         Declare_static_method_0: diag(90024, ts.DiagnosticCategory.Message, "Declare_static_method_0_90024", "Declare static method '{0}'"),
5431         Prefix_0_with_an_underscore: diag(90025, ts.DiagnosticCategory.Message, "Prefix_0_with_an_underscore_90025", "Prefix '{0}' with an underscore"),
5432         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}'"),
5433         Declare_static_property_0: diag(90027, ts.DiagnosticCategory.Message, "Declare_static_property_0_90027", "Declare static property '{0}'"),
5434         Call_decorator_expression: diag(90028, ts.DiagnosticCategory.Message, "Call_decorator_expression_90028", "Call decorator expression"),
5435         Add_async_modifier_to_containing_function: diag(90029, ts.DiagnosticCategory.Message, "Add_async_modifier_to_containing_function_90029", "Add async modifier to containing function"),
5436         Replace_infer_0_with_unknown: diag(90030, ts.DiagnosticCategory.Message, "Replace_infer_0_with_unknown_90030", "Replace 'infer {0}' with 'unknown'"),
5437         Replace_all_unused_infer_with_unknown: diag(90031, ts.DiagnosticCategory.Message, "Replace_all_unused_infer_with_unknown_90031", "Replace all unused 'infer' with 'unknown'"),
5438         Import_default_0_from_module_1: diag(90032, ts.DiagnosticCategory.Message, "Import_default_0_from_module_1_90032", "Import default '{0}' from module \"{1}\""),
5439         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}\""),
5440         Add_parameter_name: diag(90034, ts.DiagnosticCategory.Message, "Add_parameter_name_90034", "Add parameter name"),
5441         Declare_private_property_0: diag(90035, ts.DiagnosticCategory.Message, "Declare_private_property_0_90035", "Declare private property '{0}'"),
5442         Declare_a_private_field_named_0: diag(90053, ts.DiagnosticCategory.Message, "Declare_a_private_field_named_0_90053", "Declare a private field named '{0}'."),
5443         Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
5444         Convert_function_0_to_class: diag(95002, ts.DiagnosticCategory.Message, "Convert_function_0_to_class_95002", "Convert function '{0}' to class"),
5445         Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
5446         Extract_function: diag(95005, ts.DiagnosticCategory.Message, "Extract_function_95005", "Extract function"),
5447         Extract_constant: diag(95006, ts.DiagnosticCategory.Message, "Extract_constant_95006", "Extract constant"),
5448         Extract_to_0_in_enclosing_scope: diag(95007, ts.DiagnosticCategory.Message, "Extract_to_0_in_enclosing_scope_95007", "Extract to {0} in enclosing scope"),
5449         Extract_to_0_in_1_scope: diag(95008, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_scope_95008", "Extract to {0} in {1} scope"),
5450         Annotate_with_type_from_JSDoc: diag(95009, ts.DiagnosticCategory.Message, "Annotate_with_type_from_JSDoc_95009", "Annotate with type from JSDoc"),
5451         Annotate_with_types_from_JSDoc: diag(95010, ts.DiagnosticCategory.Message, "Annotate_with_types_from_JSDoc_95010", "Annotate with types from JSDoc"),
5452         Infer_type_of_0_from_usage: diag(95011, ts.DiagnosticCategory.Message, "Infer_type_of_0_from_usage_95011", "Infer type of '{0}' from usage"),
5453         Infer_parameter_types_from_usage: diag(95012, ts.DiagnosticCategory.Message, "Infer_parameter_types_from_usage_95012", "Infer parameter types from usage"),
5454         Convert_to_default_import: diag(95013, ts.DiagnosticCategory.Message, "Convert_to_default_import_95013", "Convert to default import"),
5455         Install_0: diag(95014, ts.DiagnosticCategory.Message, "Install_0_95014", "Install '{0}'"),
5456         Replace_import_with_0: diag(95015, ts.DiagnosticCategory.Message, "Replace_import_with_0_95015", "Replace import with '{0}'."),
5457         Use_synthetic_default_member: diag(95016, ts.DiagnosticCategory.Message, "Use_synthetic_default_member_95016", "Use synthetic 'default' member."),
5458         Convert_to_ES6_module: diag(95017, ts.DiagnosticCategory.Message, "Convert_to_ES6_module_95017", "Convert to ES6 module"),
5459         Add_undefined_type_to_property_0: diag(95018, ts.DiagnosticCategory.Message, "Add_undefined_type_to_property_0_95018", "Add 'undefined' type to property '{0}'"),
5460         Add_initializer_to_property_0: diag(95019, ts.DiagnosticCategory.Message, "Add_initializer_to_property_0_95019", "Add initializer to property '{0}'"),
5461         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}'"),
5462         Add_all_missing_members: diag(95022, ts.DiagnosticCategory.Message, "Add_all_missing_members_95022", "Add all missing members"),
5463         Infer_all_types_from_usage: diag(95023, ts.DiagnosticCategory.Message, "Infer_all_types_from_usage_95023", "Infer all types from usage"),
5464         Delete_all_unused_declarations: diag(95024, ts.DiagnosticCategory.Message, "Delete_all_unused_declarations_95024", "Delete all unused declarations"),
5465         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"),
5466         Fix_all_detected_spelling_errors: diag(95026, ts.DiagnosticCategory.Message, "Fix_all_detected_spelling_errors_95026", "Fix all detected spelling errors"),
5467         Add_initializers_to_all_uninitialized_properties: diag(95027, ts.DiagnosticCategory.Message, "Add_initializers_to_all_uninitialized_properties_95027", "Add initializers to all uninitialized properties"),
5468         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"),
5469         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"),
5470         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"),
5471         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)"),
5472         Implement_all_unimplemented_interfaces: diag(95032, ts.DiagnosticCategory.Message, "Implement_all_unimplemented_interfaces_95032", "Implement all unimplemented interfaces"),
5473         Install_all_missing_types_packages: diag(95033, ts.DiagnosticCategory.Message, "Install_all_missing_types_packages_95033", "Install all missing types packages"),
5474         Rewrite_all_as_indexed_access_types: diag(95034, ts.DiagnosticCategory.Message, "Rewrite_all_as_indexed_access_types_95034", "Rewrite all as indexed access types"),
5475         Convert_all_to_default_imports: diag(95035, ts.DiagnosticCategory.Message, "Convert_all_to_default_imports_95035", "Convert all to default imports"),
5476         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"),
5477         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"),
5478         Change_all_extended_interfaces_to_implements: diag(95038, ts.DiagnosticCategory.Message, "Change_all_extended_interfaces_to_implements_95038", "Change all extended interfaces to 'implements'"),
5479         Add_all_missing_super_calls: diag(95039, ts.DiagnosticCategory.Message, "Add_all_missing_super_calls_95039", "Add all missing super calls"),
5480         Implement_all_inherited_abstract_classes: diag(95040, ts.DiagnosticCategory.Message, "Implement_all_inherited_abstract_classes_95040", "Implement all inherited abstract classes"),
5481         Add_all_missing_async_modifiers: diag(95041, ts.DiagnosticCategory.Message, "Add_all_missing_async_modifiers_95041", "Add all missing 'async' modifiers"),
5482         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"),
5483         Annotate_everything_with_types_from_JSDoc: diag(95043, ts.DiagnosticCategory.Message, "Annotate_everything_with_types_from_JSDoc_95043", "Annotate everything with types from JSDoc"),
5484         Add_to_all_uncalled_decorators: diag(95044, ts.DiagnosticCategory.Message, "Add_to_all_uncalled_decorators_95044", "Add '()' to all uncalled decorators"),
5485         Convert_all_constructor_functions_to_classes: diag(95045, ts.DiagnosticCategory.Message, "Convert_all_constructor_functions_to_classes_95045", "Convert all constructor functions to classes"),
5486         Generate_get_and_set_accessors: diag(95046, ts.DiagnosticCategory.Message, "Generate_get_and_set_accessors_95046", "Generate 'get' and 'set' accessors"),
5487         Convert_require_to_import: diag(95047, ts.DiagnosticCategory.Message, "Convert_require_to_import_95047", "Convert 'require' to 'import'"),
5488         Convert_all_require_to_import: diag(95048, ts.DiagnosticCategory.Message, "Convert_all_require_to_import_95048", "Convert all 'require' to 'import'"),
5489         Move_to_a_new_file: diag(95049, ts.DiagnosticCategory.Message, "Move_to_a_new_file_95049", "Move to a new file"),
5490         Remove_unreachable_code: diag(95050, ts.DiagnosticCategory.Message, "Remove_unreachable_code_95050", "Remove unreachable code"),
5491         Remove_all_unreachable_code: diag(95051, ts.DiagnosticCategory.Message, "Remove_all_unreachable_code_95051", "Remove all unreachable code"),
5492         Add_missing_typeof: diag(95052, ts.DiagnosticCategory.Message, "Add_missing_typeof_95052", "Add missing 'typeof'"),
5493         Remove_unused_label: diag(95053, ts.DiagnosticCategory.Message, "Remove_unused_label_95053", "Remove unused label"),
5494         Remove_all_unused_labels: diag(95054, ts.DiagnosticCategory.Message, "Remove_all_unused_labels_95054", "Remove all unused labels"),
5495         Convert_0_to_mapped_object_type: diag(95055, ts.DiagnosticCategory.Message, "Convert_0_to_mapped_object_type_95055", "Convert '{0}' to mapped object type"),
5496         Convert_namespace_import_to_named_imports: diag(95056, ts.DiagnosticCategory.Message, "Convert_namespace_import_to_named_imports_95056", "Convert namespace import to named imports"),
5497         Convert_named_imports_to_namespace_import: diag(95057, ts.DiagnosticCategory.Message, "Convert_named_imports_to_namespace_import_95057", "Convert named imports to namespace import"),
5498         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"),
5499         Add_braces_to_arrow_function: diag(95059, ts.DiagnosticCategory.Message, "Add_braces_to_arrow_function_95059", "Add braces to arrow function"),
5500         Remove_braces_from_arrow_function: diag(95060, ts.DiagnosticCategory.Message, "Remove_braces_from_arrow_function_95060", "Remove braces from arrow function"),
5501         Convert_default_export_to_named_export: diag(95061, ts.DiagnosticCategory.Message, "Convert_default_export_to_named_export_95061", "Convert default export to named export"),
5502         Convert_named_export_to_default_export: diag(95062, ts.DiagnosticCategory.Message, "Convert_named_export_to_default_export_95062", "Convert named export to default export"),
5503         Add_missing_enum_member_0: diag(95063, ts.DiagnosticCategory.Message, "Add_missing_enum_member_0_95063", "Add missing enum member '{0}'"),
5504         Add_all_missing_imports: diag(95064, ts.DiagnosticCategory.Message, "Add_all_missing_imports_95064", "Add all missing imports"),
5505         Convert_to_async_function: diag(95065, ts.DiagnosticCategory.Message, "Convert_to_async_function_95065", "Convert to async function"),
5506         Convert_all_to_async_functions: diag(95066, ts.DiagnosticCategory.Message, "Convert_all_to_async_functions_95066", "Convert all to async functions"),
5507         Add_missing_call_parentheses: diag(95067, ts.DiagnosticCategory.Message, "Add_missing_call_parentheses_95067", "Add missing call parentheses"),
5508         Add_all_missing_call_parentheses: diag(95068, ts.DiagnosticCategory.Message, "Add_all_missing_call_parentheses_95068", "Add all missing call parentheses"),
5509         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"),
5510         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"),
5511         Add_missing_new_operator_to_call: diag(95071, ts.DiagnosticCategory.Message, "Add_missing_new_operator_to_call_95071", "Add missing 'new' operator to call"),
5512         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"),
5513         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"),
5514         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"),
5515         Convert_parameters_to_destructured_object: diag(95075, ts.DiagnosticCategory.Message, "Convert_parameters_to_destructured_object_95075", "Convert parameters to destructured object"),
5516         Allow_accessing_UMD_globals_from_modules: diag(95076, ts.DiagnosticCategory.Message, "Allow_accessing_UMD_globals_from_modules_95076", "Allow accessing UMD globals from modules."),
5517         Extract_type: diag(95077, ts.DiagnosticCategory.Message, "Extract_type_95077", "Extract type"),
5518         Extract_to_type_alias: diag(95078, ts.DiagnosticCategory.Message, "Extract_to_type_alias_95078", "Extract to type alias"),
5519         Extract_to_typedef: diag(95079, ts.DiagnosticCategory.Message, "Extract_to_typedef_95079", "Extract to typedef"),
5520         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"),
5521         Add_const_to_unresolved_variable: diag(95081, ts.DiagnosticCategory.Message, "Add_const_to_unresolved_variable_95081", "Add 'const' to unresolved variable"),
5522         Add_const_to_all_unresolved_variables: diag(95082, ts.DiagnosticCategory.Message, "Add_const_to_all_unresolved_variables_95082", "Add 'const' to all unresolved variables"),
5523         Add_await: diag(95083, ts.DiagnosticCategory.Message, "Add_await_95083", "Add 'await'"),
5524         Add_await_to_initializer_for_0: diag(95084, ts.DiagnosticCategory.Message, "Add_await_to_initializer_for_0_95084", "Add 'await' to initializer for '{0}'"),
5525         Fix_all_expressions_possibly_missing_await: diag(95085, ts.DiagnosticCategory.Message, "Fix_all_expressions_possibly_missing_await_95085", "Fix all expressions possibly missing 'await'"),
5526         Remove_unnecessary_await: diag(95086, ts.DiagnosticCategory.Message, "Remove_unnecessary_await_95086", "Remove unnecessary 'await'"),
5527         Remove_all_unnecessary_uses_of_await: diag(95087, ts.DiagnosticCategory.Message, "Remove_all_unnecessary_uses_of_await_95087", "Remove all unnecessary uses of 'await'"),
5528         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"),
5529         Add_await_to_initializers: diag(95089, ts.DiagnosticCategory.Message, "Add_await_to_initializers_95089", "Add 'await' to initializers"),
5530         Extract_to_interface: diag(95090, ts.DiagnosticCategory.Message, "Extract_to_interface_95090", "Extract to interface"),
5531         Convert_to_a_bigint_numeric_literal: diag(95091, ts.DiagnosticCategory.Message, "Convert_to_a_bigint_numeric_literal_95091", "Convert to a bigint numeric literal"),
5532         Convert_all_to_bigint_numeric_literals: diag(95092, ts.DiagnosticCategory.Message, "Convert_all_to_bigint_numeric_literals_95092", "Convert all to bigint numeric literals"),
5533         Convert_const_to_let: diag(95093, ts.DiagnosticCategory.Message, "Convert_const_to_let_95093", "Convert 'const' to 'let'"),
5534         Prefix_with_declare: diag(95094, ts.DiagnosticCategory.Message, "Prefix_with_declare_95094", "Prefix with 'declare'"),
5535         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'"),
5536         Convert_to_template_string: diag(95096, ts.DiagnosticCategory.Message, "Convert_to_template_string_95096", "Convert to template string"),
5537         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"),
5538         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}'"),
5539         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}'"),
5540         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"),
5541         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"),
5542         Add_class_tag: diag(95102, ts.DiagnosticCategory.Message, "Add_class_tag_95102", "Add '@class' tag"),
5543         Add_this_tag: diag(95103, ts.DiagnosticCategory.Message, "Add_this_tag_95103", "Add '@this' tag"),
5544         Add_this_parameter: diag(95104, ts.DiagnosticCategory.Message, "Add_this_parameter_95104", "Add 'this' parameter."),
5545         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"),
5546         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"),
5547         Fix_all_implicit_this_errors: diag(95107, ts.DiagnosticCategory.Message, "Fix_all_implicit_this_errors_95107", "Fix all implicit-'this' errors"),
5548         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"),
5549         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"),
5550         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"),
5551         Add_a_return_statement: diag(95111, ts.DiagnosticCategory.Message, "Add_a_return_statement_95111", "Add a return statement"),
5552         Remove_block_body_braces: diag(95112, ts.DiagnosticCategory.Message, "Remove_block_body_braces_95112", "Remove block body braces"),
5553         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"),
5554         Add_all_missing_return_statement: diag(95114, ts.DiagnosticCategory.Message, "Add_all_missing_return_statement_95114", "Add all missing return statement"),
5555         Remove_all_incorrect_body_block_braces: diag(95115, ts.DiagnosticCategory.Message, "Remove_all_incorrect_body_block_braces_95115", "Remove all incorrect body block braces"),
5556         Wrap_all_object_literal_with_parentheses: diag(95116, ts.DiagnosticCategory.Message, "Wrap_all_object_literal_with_parentheses_95116", "Wrap all object literal with parentheses"),
5557         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."),
5558         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'."),
5559         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?"),
5560         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"),
5561         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."),
5562         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."),
5563         constructor_is_a_reserved_word: diag(18012, ts.DiagnosticCategory.Error, "constructor_is_a_reserved_word_18012", "'#constructor' is a reserved word."),
5564         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."),
5565         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."),
5566         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}'."),
5567         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."),
5568         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"),
5569         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"),
5570         _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"),
5571         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."),
5572         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."),
5573         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."),
5574         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."),
5575         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."),
5576         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."),
5577         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."),
5578         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."),
5579         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."),
5580         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."),
5581         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."),
5582     };
5583 })(ts || (ts = {}));
5584 var ts;
5585 (function (ts) {
5586     var _a;
5587     function tokenIsIdentifierOrKeyword(token) {
5588         return token >= 75;
5589     }
5590     ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword;
5591     function tokenIsIdentifierOrKeywordOrGreaterThan(token) {
5592         return token === 31 || tokenIsIdentifierOrKeyword(token);
5593     }
5594     ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan;
5595     var textToKeywordObj = (_a = {
5596             abstract: 122,
5597             any: 125,
5598             as: 123,
5599             asserts: 124,
5600             bigint: 151,
5601             boolean: 128,
5602             break: 77,
5603             case: 78,
5604             catch: 79,
5605             class: 80,
5606             continue: 82,
5607             const: 81
5608         },
5609         _a["" + "constructor"] = 129,
5610         _a.debugger = 83,
5611         _a.declare = 130,
5612         _a.default = 84,
5613         _a.delete = 85,
5614         _a.do = 86,
5615         _a.else = 87,
5616         _a.enum = 88,
5617         _a.export = 89,
5618         _a.extends = 90,
5619         _a.false = 91,
5620         _a.finally = 92,
5621         _a.for = 93,
5622         _a.from = 149,
5623         _a.function = 94,
5624         _a.get = 131,
5625         _a.if = 95,
5626         _a.implements = 113,
5627         _a.import = 96,
5628         _a.in = 97,
5629         _a.infer = 132,
5630         _a.instanceof = 98,
5631         _a.interface = 114,
5632         _a.is = 133,
5633         _a.keyof = 134,
5634         _a.let = 115,
5635         _a.module = 135,
5636         _a.namespace = 136,
5637         _a.never = 137,
5638         _a.new = 99,
5639         _a.null = 100,
5640         _a.number = 140,
5641         _a.object = 141,
5642         _a.package = 116,
5643         _a.private = 117,
5644         _a.protected = 118,
5645         _a.public = 119,
5646         _a.readonly = 138,
5647         _a.require = 139,
5648         _a.global = 150,
5649         _a.return = 101,
5650         _a.set = 142,
5651         _a.static = 120,
5652         _a.string = 143,
5653         _a.super = 102,
5654         _a.switch = 103,
5655         _a.symbol = 144,
5656         _a.this = 104,
5657         _a.throw = 105,
5658         _a.true = 106,
5659         _a.try = 107,
5660         _a.type = 145,
5661         _a.typeof = 108,
5662         _a.undefined = 146,
5663         _a.unique = 147,
5664         _a.unknown = 148,
5665         _a.var = 109,
5666         _a.void = 110,
5667         _a.while = 111,
5668         _a.with = 112,
5669         _a.yield = 121,
5670         _a.async = 126,
5671         _a.await = 127,
5672         _a.of = 152,
5673         _a);
5674     var textToKeyword = ts.createMapFromTemplate(textToKeywordObj);
5675     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 }));
5676     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,];
5677     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,];
5678     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,];
5679     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,];
5680     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];
5681     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];
5682     var commentDirectiveRegExSingleLine = /^\s*\/\/\/?\s*@(ts-expect-error|ts-ignore)/;
5683     var commentDirectiveRegExMultiLine = /^\s*(?:\/|\*)*\s*@(ts-expect-error|ts-ignore)/;
5684     function lookupInUnicodeMap(code, map) {
5685         if (code < map[0]) {
5686             return false;
5687         }
5688         var lo = 0;
5689         var hi = map.length;
5690         var mid;
5691         while (lo + 1 < hi) {
5692             mid = lo + (hi - lo) / 2;
5693             mid -= mid % 2;
5694             if (map[mid] <= code && code <= map[mid + 1]) {
5695                 return true;
5696             }
5697             if (code < map[mid]) {
5698                 hi = mid;
5699             }
5700             else {
5701                 lo = mid + 2;
5702             }
5703         }
5704         return false;
5705     }
5706     function isUnicodeIdentifierStart(code, languageVersion) {
5707         return languageVersion >= 2 ?
5708             lookupInUnicodeMap(code, unicodeESNextIdentifierStart) :
5709             languageVersion === 1 ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) :
5710                 lookupInUnicodeMap(code, unicodeES3IdentifierStart);
5711     }
5712     ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart;
5713     function isUnicodeIdentifierPart(code, languageVersion) {
5714         return languageVersion >= 2 ?
5715             lookupInUnicodeMap(code, unicodeESNextIdentifierPart) :
5716             languageVersion === 1 ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) :
5717                 lookupInUnicodeMap(code, unicodeES3IdentifierPart);
5718     }
5719     function makeReverseMap(source) {
5720         var result = [];
5721         source.forEach(function (value, name) {
5722             result[value] = name;
5723         });
5724         return result;
5725     }
5726     var tokenStrings = makeReverseMap(textToToken);
5727     function tokenToString(t) {
5728         return tokenStrings[t];
5729     }
5730     ts.tokenToString = tokenToString;
5731     function stringToToken(s) {
5732         return textToToken.get(s);
5733     }
5734     ts.stringToToken = stringToToken;
5735     function computeLineStarts(text) {
5736         var result = new Array();
5737         var pos = 0;
5738         var lineStart = 0;
5739         while (pos < text.length) {
5740             var ch = text.charCodeAt(pos);
5741             pos++;
5742             switch (ch) {
5743                 case 13:
5744                     if (text.charCodeAt(pos) === 10) {
5745                         pos++;
5746                     }
5747                 case 10:
5748                     result.push(lineStart);
5749                     lineStart = pos;
5750                     break;
5751                 default:
5752                     if (ch > 127 && isLineBreak(ch)) {
5753                         result.push(lineStart);
5754                         lineStart = pos;
5755                     }
5756                     break;
5757             }
5758         }
5759         result.push(lineStart);
5760         return result;
5761     }
5762     ts.computeLineStarts = computeLineStarts;
5763     function getPositionOfLineAndCharacter(sourceFile, line, character, allowEdits) {
5764         return sourceFile.getPositionOfLineAndCharacter ?
5765             sourceFile.getPositionOfLineAndCharacter(line, character, allowEdits) :
5766             computePositionOfLineAndCharacter(getLineStarts(sourceFile), line, character, sourceFile.text, allowEdits);
5767     }
5768     ts.getPositionOfLineAndCharacter = getPositionOfLineAndCharacter;
5769     function computePositionOfLineAndCharacter(lineStarts, line, character, debugText, allowEdits) {
5770         if (line < 0 || line >= lineStarts.length) {
5771             if (allowEdits) {
5772                 line = line < 0 ? 0 : line >= lineStarts.length ? lineStarts.length - 1 : line;
5773             }
5774             else {
5775                 ts.Debug.fail("Bad line number. Line: " + line + ", lineStarts.length: " + lineStarts.length + " , line map is correct? " + (debugText !== undefined ? ts.arraysEqual(lineStarts, computeLineStarts(debugText)) : "unknown"));
5776             }
5777         }
5778         var res = lineStarts[line] + character;
5779         if (allowEdits) {
5780             return res > lineStarts[line + 1] ? lineStarts[line + 1] : typeof debugText === "string" && res > debugText.length ? debugText.length : res;
5781         }
5782         if (line < lineStarts.length - 1) {
5783             ts.Debug.assert(res < lineStarts[line + 1]);
5784         }
5785         else if (debugText !== undefined) {
5786             ts.Debug.assert(res <= debugText.length);
5787         }
5788         return res;
5789     }
5790     ts.computePositionOfLineAndCharacter = computePositionOfLineAndCharacter;
5791     function getLineStarts(sourceFile) {
5792         return sourceFile.lineMap || (sourceFile.lineMap = computeLineStarts(sourceFile.text));
5793     }
5794     ts.getLineStarts = getLineStarts;
5795     function computeLineAndCharacterOfPosition(lineStarts, position) {
5796         var lineNumber = computeLineOfPosition(lineStarts, position);
5797         return {
5798             line: lineNumber,
5799             character: position - lineStarts[lineNumber]
5800         };
5801     }
5802     ts.computeLineAndCharacterOfPosition = computeLineAndCharacterOfPosition;
5803     function computeLineOfPosition(lineStarts, position, lowerBound) {
5804         var lineNumber = ts.binarySearch(lineStarts, position, ts.identity, ts.compareValues, lowerBound);
5805         if (lineNumber < 0) {
5806             lineNumber = ~lineNumber - 1;
5807             ts.Debug.assert(lineNumber !== -1, "position cannot precede the beginning of the file");
5808         }
5809         return lineNumber;
5810     }
5811     ts.computeLineOfPosition = computeLineOfPosition;
5812     function getLinesBetweenPositions(sourceFile, pos1, pos2) {
5813         if (pos1 === pos2)
5814             return 0;
5815         var lineStarts = getLineStarts(sourceFile);
5816         var lower = Math.min(pos1, pos2);
5817         var isNegative = lower === pos2;
5818         var upper = isNegative ? pos1 : pos2;
5819         var lowerLine = computeLineOfPosition(lineStarts, lower);
5820         var upperLine = computeLineOfPosition(lineStarts, upper, lowerLine);
5821         return isNegative ? lowerLine - upperLine : upperLine - lowerLine;
5822     }
5823     ts.getLinesBetweenPositions = getLinesBetweenPositions;
5824     function getLineAndCharacterOfPosition(sourceFile, position) {
5825         return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position);
5826     }
5827     ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition;
5828     function isWhiteSpaceLike(ch) {
5829         return isWhiteSpaceSingleLine(ch) || isLineBreak(ch);
5830     }
5831     ts.isWhiteSpaceLike = isWhiteSpaceLike;
5832     function isWhiteSpaceSingleLine(ch) {
5833         return ch === 32 ||
5834             ch === 9 ||
5835             ch === 11 ||
5836             ch === 12 ||
5837             ch === 160 ||
5838             ch === 133 ||
5839             ch === 5760 ||
5840             ch >= 8192 && ch <= 8203 ||
5841             ch === 8239 ||
5842             ch === 8287 ||
5843             ch === 12288 ||
5844             ch === 65279;
5845     }
5846     ts.isWhiteSpaceSingleLine = isWhiteSpaceSingleLine;
5847     function isLineBreak(ch) {
5848         return ch === 10 ||
5849             ch === 13 ||
5850             ch === 8232 ||
5851             ch === 8233;
5852     }
5853     ts.isLineBreak = isLineBreak;
5854     function isDigit(ch) {
5855         return ch >= 48 && ch <= 57;
5856     }
5857     function isHexDigit(ch) {
5858         return isDigit(ch) || ch >= 65 && ch <= 70 || ch >= 97 && ch <= 102;
5859     }
5860     function isCodePoint(code) {
5861         return code <= 0x10FFFF;
5862     }
5863     function isOctalDigit(ch) {
5864         return ch >= 48 && ch <= 55;
5865     }
5866     ts.isOctalDigit = isOctalDigit;
5867     function couldStartTrivia(text, pos) {
5868         var ch = text.charCodeAt(pos);
5869         switch (ch) {
5870             case 13:
5871             case 10:
5872             case 9:
5873             case 11:
5874             case 12:
5875             case 32:
5876             case 47:
5877             case 60:
5878             case 124:
5879             case 61:
5880             case 62:
5881                 return true;
5882             case 35:
5883                 return pos === 0;
5884             default:
5885                 return ch > 127;
5886         }
5887     }
5888     ts.couldStartTrivia = couldStartTrivia;
5889     function skipTrivia(text, pos, stopAfterLineBreak, stopAtComments) {
5890         if (stopAtComments === void 0) { stopAtComments = false; }
5891         if (ts.positionIsSynthesized(pos)) {
5892             return pos;
5893         }
5894         while (true) {
5895             var ch = text.charCodeAt(pos);
5896             switch (ch) {
5897                 case 13:
5898                     if (text.charCodeAt(pos + 1) === 10) {
5899                         pos++;
5900                     }
5901                 case 10:
5902                     pos++;
5903                     if (stopAfterLineBreak) {
5904                         return pos;
5905                     }
5906                     continue;
5907                 case 9:
5908                 case 11:
5909                 case 12:
5910                 case 32:
5911                     pos++;
5912                     continue;
5913                 case 47:
5914                     if (stopAtComments) {
5915                         break;
5916                     }
5917                     if (text.charCodeAt(pos + 1) === 47) {
5918                         pos += 2;
5919                         while (pos < text.length) {
5920                             if (isLineBreak(text.charCodeAt(pos))) {
5921                                 break;
5922                             }
5923                             pos++;
5924                         }
5925                         continue;
5926                     }
5927                     if (text.charCodeAt(pos + 1) === 42) {
5928                         pos += 2;
5929                         while (pos < text.length) {
5930                             if (text.charCodeAt(pos) === 42 && text.charCodeAt(pos + 1) === 47) {
5931                                 pos += 2;
5932                                 break;
5933                             }
5934                             pos++;
5935                         }
5936                         continue;
5937                     }
5938                     break;
5939                 case 60:
5940                 case 124:
5941                 case 61:
5942                 case 62:
5943                     if (isConflictMarkerTrivia(text, pos)) {
5944                         pos = scanConflictMarkerTrivia(text, pos);
5945                         continue;
5946                     }
5947                     break;
5948                 case 35:
5949                     if (pos === 0 && isShebangTrivia(text, pos)) {
5950                         pos = scanShebangTrivia(text, pos);
5951                         continue;
5952                     }
5953                     break;
5954                 default:
5955                     if (ch > 127 && (isWhiteSpaceLike(ch))) {
5956                         pos++;
5957                         continue;
5958                     }
5959                     break;
5960             }
5961             return pos;
5962         }
5963     }
5964     ts.skipTrivia = skipTrivia;
5965     var mergeConflictMarkerLength = "<<<<<<<".length;
5966     function isConflictMarkerTrivia(text, pos) {
5967         ts.Debug.assert(pos >= 0);
5968         if (pos === 0 || isLineBreak(text.charCodeAt(pos - 1))) {
5969             var ch = text.charCodeAt(pos);
5970             if ((pos + mergeConflictMarkerLength) < text.length) {
5971                 for (var i = 0; i < mergeConflictMarkerLength; i++) {
5972                     if (text.charCodeAt(pos + i) !== ch) {
5973                         return false;
5974                     }
5975                 }
5976                 return ch === 61 ||
5977                     text.charCodeAt(pos + mergeConflictMarkerLength) === 32;
5978             }
5979         }
5980         return false;
5981     }
5982     function scanConflictMarkerTrivia(text, pos, error) {
5983         if (error) {
5984             error(ts.Diagnostics.Merge_conflict_marker_encountered, pos, mergeConflictMarkerLength);
5985         }
5986         var ch = text.charCodeAt(pos);
5987         var len = text.length;
5988         if (ch === 60 || ch === 62) {
5989             while (pos < len && !isLineBreak(text.charCodeAt(pos))) {
5990                 pos++;
5991             }
5992         }
5993         else {
5994             ts.Debug.assert(ch === 124 || ch === 61);
5995             while (pos < len) {
5996                 var currentChar = text.charCodeAt(pos);
5997                 if ((currentChar === 61 || currentChar === 62) && currentChar !== ch && isConflictMarkerTrivia(text, pos)) {
5998                     break;
5999                 }
6000                 pos++;
6001             }
6002         }
6003         return pos;
6004     }
6005     var shebangTriviaRegex = /^#!.*/;
6006     function isShebangTrivia(text, pos) {
6007         ts.Debug.assert(pos === 0);
6008         return shebangTriviaRegex.test(text);
6009     }
6010     ts.isShebangTrivia = isShebangTrivia;
6011     function scanShebangTrivia(text, pos) {
6012         var shebang = shebangTriviaRegex.exec(text)[0];
6013         pos = pos + shebang.length;
6014         return pos;
6015     }
6016     ts.scanShebangTrivia = scanShebangTrivia;
6017     function iterateCommentRanges(reduce, text, pos, trailing, cb, state, initial) {
6018         var pendingPos;
6019         var pendingEnd;
6020         var pendingKind;
6021         var pendingHasTrailingNewLine;
6022         var hasPendingCommentRange = false;
6023         var collecting = trailing;
6024         var accumulator = initial;
6025         if (pos === 0) {
6026             collecting = true;
6027             var shebang = getShebang(text);
6028             if (shebang) {
6029                 pos = shebang.length;
6030             }
6031         }
6032         scan: while (pos >= 0 && pos < text.length) {
6033             var ch = text.charCodeAt(pos);
6034             switch (ch) {
6035                 case 13:
6036                     if (text.charCodeAt(pos + 1) === 10) {
6037                         pos++;
6038                     }
6039                 case 10:
6040                     pos++;
6041                     if (trailing) {
6042                         break scan;
6043                     }
6044                     collecting = true;
6045                     if (hasPendingCommentRange) {
6046                         pendingHasTrailingNewLine = true;
6047                     }
6048                     continue;
6049                 case 9:
6050                 case 11:
6051                 case 12:
6052                 case 32:
6053                     pos++;
6054                     continue;
6055                 case 47:
6056                     var nextChar = text.charCodeAt(pos + 1);
6057                     var hasTrailingNewLine = false;
6058                     if (nextChar === 47 || nextChar === 42) {
6059                         var kind = nextChar === 47 ? 2 : 3;
6060                         var startPos = pos;
6061                         pos += 2;
6062                         if (nextChar === 47) {
6063                             while (pos < text.length) {
6064                                 if (isLineBreak(text.charCodeAt(pos))) {
6065                                     hasTrailingNewLine = true;
6066                                     break;
6067                                 }
6068                                 pos++;
6069                             }
6070                         }
6071                         else {
6072                             while (pos < text.length) {
6073                                 if (text.charCodeAt(pos) === 42 && text.charCodeAt(pos + 1) === 47) {
6074                                     pos += 2;
6075                                     break;
6076                                 }
6077                                 pos++;
6078                             }
6079                         }
6080                         if (collecting) {
6081                             if (hasPendingCommentRange) {
6082                                 accumulator = cb(pendingPos, pendingEnd, pendingKind, pendingHasTrailingNewLine, state, accumulator);
6083                                 if (!reduce && accumulator) {
6084                                     return accumulator;
6085                                 }
6086                             }
6087                             pendingPos = startPos;
6088                             pendingEnd = pos;
6089                             pendingKind = kind;
6090                             pendingHasTrailingNewLine = hasTrailingNewLine;
6091                             hasPendingCommentRange = true;
6092                         }
6093                         continue;
6094                     }
6095                     break scan;
6096                 default:
6097                     if (ch > 127 && (isWhiteSpaceLike(ch))) {
6098                         if (hasPendingCommentRange && isLineBreak(ch)) {
6099                             pendingHasTrailingNewLine = true;
6100                         }
6101                         pos++;
6102                         continue;
6103                     }
6104                     break scan;
6105             }
6106         }
6107         if (hasPendingCommentRange) {
6108             accumulator = cb(pendingPos, pendingEnd, pendingKind, pendingHasTrailingNewLine, state, accumulator);
6109         }
6110         return accumulator;
6111     }
6112     function forEachLeadingCommentRange(text, pos, cb, state) {
6113         return iterateCommentRanges(false, text, pos, false, cb, state);
6114     }
6115     ts.forEachLeadingCommentRange = forEachLeadingCommentRange;
6116     function forEachTrailingCommentRange(text, pos, cb, state) {
6117         return iterateCommentRanges(false, text, pos, true, cb, state);
6118     }
6119     ts.forEachTrailingCommentRange = forEachTrailingCommentRange;
6120     function reduceEachLeadingCommentRange(text, pos, cb, state, initial) {
6121         return iterateCommentRanges(true, text, pos, false, cb, state, initial);
6122     }
6123     ts.reduceEachLeadingCommentRange = reduceEachLeadingCommentRange;
6124     function reduceEachTrailingCommentRange(text, pos, cb, state, initial) {
6125         return iterateCommentRanges(true, text, pos, true, cb, state, initial);
6126     }
6127     ts.reduceEachTrailingCommentRange = reduceEachTrailingCommentRange;
6128     function appendCommentRange(pos, end, kind, hasTrailingNewLine, _state, comments) {
6129         if (!comments) {
6130             comments = [];
6131         }
6132         comments.push({ kind: kind, pos: pos, end: end, hasTrailingNewLine: hasTrailingNewLine });
6133         return comments;
6134     }
6135     function getLeadingCommentRanges(text, pos) {
6136         return reduceEachLeadingCommentRange(text, pos, appendCommentRange, undefined, undefined);
6137     }
6138     ts.getLeadingCommentRanges = getLeadingCommentRanges;
6139     function getTrailingCommentRanges(text, pos) {
6140         return reduceEachTrailingCommentRange(text, pos, appendCommentRange, undefined, undefined);
6141     }
6142     ts.getTrailingCommentRanges = getTrailingCommentRanges;
6143     function getShebang(text) {
6144         var match = shebangTriviaRegex.exec(text);
6145         if (match) {
6146             return match[0];
6147         }
6148     }
6149     ts.getShebang = getShebang;
6150     function isIdentifierStart(ch, languageVersion) {
6151         return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 ||
6152             ch === 36 || ch === 95 ||
6153             ch > 127 && isUnicodeIdentifierStart(ch, languageVersion);
6154     }
6155     ts.isIdentifierStart = isIdentifierStart;
6156     function isIdentifierPart(ch, languageVersion, identifierVariant) {
6157         return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 ||
6158             ch >= 48 && ch <= 57 || ch === 36 || ch === 95 ||
6159             (identifierVariant === 1 ? (ch === 45 || ch === 58) : false) ||
6160             ch > 127 && isUnicodeIdentifierPart(ch, languageVersion);
6161     }
6162     ts.isIdentifierPart = isIdentifierPart;
6163     function isIdentifierText(name, languageVersion, identifierVariant) {
6164         var ch = codePointAt(name, 0);
6165         if (!isIdentifierStart(ch, languageVersion)) {
6166             return false;
6167         }
6168         for (var i = charSize(ch); i < name.length; i += charSize(ch)) {
6169             if (!isIdentifierPart(ch = codePointAt(name, i), languageVersion, identifierVariant)) {
6170                 return false;
6171             }
6172         }
6173         return true;
6174     }
6175     ts.isIdentifierText = isIdentifierText;
6176     function createScanner(languageVersion, skipTrivia, languageVariant, textInitial, onError, start, length) {
6177         if (languageVariant === void 0) { languageVariant = 0; }
6178         var text = textInitial;
6179         var pos;
6180         var end;
6181         var startPos;
6182         var tokenPos;
6183         var token;
6184         var tokenValue;
6185         var tokenFlags;
6186         var commentDirectives;
6187         var inJSDocType = 0;
6188         setText(text, start, length);
6189         var scanner = {
6190             getStartPos: function () { return startPos; },
6191             getTextPos: function () { return pos; },
6192             getToken: function () { return token; },
6193             getTokenPos: function () { return tokenPos; },
6194             getTokenText: function () { return text.substring(tokenPos, pos); },
6195             getTokenValue: function () { return tokenValue; },
6196             hasUnicodeEscape: function () { return (tokenFlags & 1024) !== 0; },
6197             hasExtendedUnicodeEscape: function () { return (tokenFlags & 8) !== 0; },
6198             hasPrecedingLineBreak: function () { return (tokenFlags & 1) !== 0; },
6199             isIdentifier: function () { return token === 75 || token > 112; },
6200             isReservedWord: function () { return token >= 77 && token <= 112; },
6201             isUnterminated: function () { return (tokenFlags & 4) !== 0; },
6202             getCommentDirectives: function () { return commentDirectives; },
6203             getTokenFlags: function () { return tokenFlags; },
6204             reScanGreaterToken: reScanGreaterToken,
6205             reScanSlashToken: reScanSlashToken,
6206             reScanTemplateToken: reScanTemplateToken,
6207             reScanTemplateHeadOrNoSubstitutionTemplate: reScanTemplateHeadOrNoSubstitutionTemplate,
6208             scanJsxIdentifier: scanJsxIdentifier,
6209             scanJsxAttributeValue: scanJsxAttributeValue,
6210             reScanJsxAttributeValue: reScanJsxAttributeValue,
6211             reScanJsxToken: reScanJsxToken,
6212             reScanLessThanToken: reScanLessThanToken,
6213             reScanQuestionToken: reScanQuestionToken,
6214             scanJsxToken: scanJsxToken,
6215             scanJsDocToken: scanJsDocToken,
6216             scan: scan,
6217             getText: getText,
6218             clearCommentDirectives: clearCommentDirectives,
6219             setText: setText,
6220             setScriptTarget: setScriptTarget,
6221             setLanguageVariant: setLanguageVariant,
6222             setOnError: setOnError,
6223             setTextPos: setTextPos,
6224             setInJSDocType: setInJSDocType,
6225             tryScan: tryScan,
6226             lookAhead: lookAhead,
6227             scanRange: scanRange,
6228         };
6229         if (ts.Debug.isDebugging) {
6230             Object.defineProperty(scanner, "__debugShowCurrentPositionInText", {
6231                 get: function () {
6232                     var text = scanner.getText();
6233                     return text.slice(0, scanner.getStartPos()) + "â•‘" + text.slice(scanner.getStartPos());
6234                 },
6235             });
6236         }
6237         return scanner;
6238         function error(message, errPos, length) {
6239             if (errPos === void 0) { errPos = pos; }
6240             if (onError) {
6241                 var oldPos = pos;
6242                 pos = errPos;
6243                 onError(message, length || 0);
6244                 pos = oldPos;
6245             }
6246         }
6247         function scanNumberFragment() {
6248             var start = pos;
6249             var allowSeparator = false;
6250             var isPreviousTokenSeparator = false;
6251             var result = "";
6252             while (true) {
6253                 var ch = text.charCodeAt(pos);
6254                 if (ch === 95) {
6255                     tokenFlags |= 512;
6256                     if (allowSeparator) {
6257                         allowSeparator = false;
6258                         isPreviousTokenSeparator = true;
6259                         result += text.substring(start, pos);
6260                     }
6261                     else if (isPreviousTokenSeparator) {
6262                         error(ts.Diagnostics.Multiple_consecutive_numeric_separators_are_not_permitted, pos, 1);
6263                     }
6264                     else {
6265                         error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos, 1);
6266                     }
6267                     pos++;
6268                     start = pos;
6269                     continue;
6270                 }
6271                 if (isDigit(ch)) {
6272                     allowSeparator = true;
6273                     isPreviousTokenSeparator = false;
6274                     pos++;
6275                     continue;
6276                 }
6277                 break;
6278             }
6279             if (text.charCodeAt(pos - 1) === 95) {
6280                 error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
6281             }
6282             return result + text.substring(start, pos);
6283         }
6284         function scanNumber() {
6285             var start = pos;
6286             var mainFragment = scanNumberFragment();
6287             var decimalFragment;
6288             var scientificFragment;
6289             if (text.charCodeAt(pos) === 46) {
6290                 pos++;
6291                 decimalFragment = scanNumberFragment();
6292             }
6293             var end = pos;
6294             if (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101) {
6295                 pos++;
6296                 tokenFlags |= 16;
6297                 if (text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45)
6298                     pos++;
6299                 var preNumericPart = pos;
6300                 var finalFragment = scanNumberFragment();
6301                 if (!finalFragment) {
6302                     error(ts.Diagnostics.Digit_expected);
6303                 }
6304                 else {
6305                     scientificFragment = text.substring(end, preNumericPart) + finalFragment;
6306                     end = pos;
6307                 }
6308             }
6309             var result;
6310             if (tokenFlags & 512) {
6311                 result = mainFragment;
6312                 if (decimalFragment) {
6313                     result += "." + decimalFragment;
6314                 }
6315                 if (scientificFragment) {
6316                     result += scientificFragment;
6317                 }
6318             }
6319             else {
6320                 result = text.substring(start, end);
6321             }
6322             if (decimalFragment !== undefined || tokenFlags & 16) {
6323                 checkForIdentifierStartAfterNumericLiteral(start, decimalFragment === undefined && !!(tokenFlags & 16));
6324                 return {
6325                     type: 8,
6326                     value: "" + +result
6327                 };
6328             }
6329             else {
6330                 tokenValue = result;
6331                 var type = checkBigIntSuffix();
6332                 checkForIdentifierStartAfterNumericLiteral(start);
6333                 return { type: type, value: tokenValue };
6334             }
6335         }
6336         function checkForIdentifierStartAfterNumericLiteral(numericStart, isScientific) {
6337             if (!isIdentifierStart(codePointAt(text, pos), languageVersion)) {
6338                 return;
6339             }
6340             var identifierStart = pos;
6341             var length = scanIdentifierParts().length;
6342             if (length === 1 && text[identifierStart] === "n") {
6343                 if (isScientific) {
6344                     error(ts.Diagnostics.A_bigint_literal_cannot_use_exponential_notation, numericStart, identifierStart - numericStart + 1);
6345                 }
6346                 else {
6347                     error(ts.Diagnostics.A_bigint_literal_must_be_an_integer, numericStart, identifierStart - numericStart + 1);
6348                 }
6349             }
6350             else {
6351                 error(ts.Diagnostics.An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal, identifierStart, length);
6352                 pos = identifierStart;
6353             }
6354         }
6355         function scanOctalDigits() {
6356             var start = pos;
6357             while (isOctalDigit(text.charCodeAt(pos))) {
6358                 pos++;
6359             }
6360             return +(text.substring(start, pos));
6361         }
6362         function scanExactNumberOfHexDigits(count, canHaveSeparators) {
6363             var valueString = scanHexDigits(count, false, canHaveSeparators);
6364             return valueString ? parseInt(valueString, 16) : -1;
6365         }
6366         function scanMinimumNumberOfHexDigits(count, canHaveSeparators) {
6367             return scanHexDigits(count, true, canHaveSeparators);
6368         }
6369         function scanHexDigits(minCount, scanAsManyAsPossible, canHaveSeparators) {
6370             var valueChars = [];
6371             var allowSeparator = false;
6372             var isPreviousTokenSeparator = false;
6373             while (valueChars.length < minCount || scanAsManyAsPossible) {
6374                 var ch = text.charCodeAt(pos);
6375                 if (canHaveSeparators && ch === 95) {
6376                     tokenFlags |= 512;
6377                     if (allowSeparator) {
6378                         allowSeparator = false;
6379                         isPreviousTokenSeparator = true;
6380                     }
6381                     else if (isPreviousTokenSeparator) {
6382                         error(ts.Diagnostics.Multiple_consecutive_numeric_separators_are_not_permitted, pos, 1);
6383                     }
6384                     else {
6385                         error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos, 1);
6386                     }
6387                     pos++;
6388                     continue;
6389                 }
6390                 allowSeparator = canHaveSeparators;
6391                 if (ch >= 65 && ch <= 70) {
6392                     ch += 97 - 65;
6393                 }
6394                 else if (!((ch >= 48 && ch <= 57) ||
6395                     (ch >= 97 && ch <= 102))) {
6396                     break;
6397                 }
6398                 valueChars.push(ch);
6399                 pos++;
6400                 isPreviousTokenSeparator = false;
6401             }
6402             if (valueChars.length < minCount) {
6403                 valueChars = [];
6404             }
6405             if (text.charCodeAt(pos - 1) === 95) {
6406                 error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
6407             }
6408             return String.fromCharCode.apply(String, valueChars);
6409         }
6410         function scanString(jsxAttributeString) {
6411             if (jsxAttributeString === void 0) { jsxAttributeString = false; }
6412             var quote = text.charCodeAt(pos);
6413             pos++;
6414             var result = "";
6415             var start = pos;
6416             while (true) {
6417                 if (pos >= end) {
6418                     result += text.substring(start, pos);
6419                     tokenFlags |= 4;
6420                     error(ts.Diagnostics.Unterminated_string_literal);
6421                     break;
6422                 }
6423                 var ch = text.charCodeAt(pos);
6424                 if (ch === quote) {
6425                     result += text.substring(start, pos);
6426                     pos++;
6427                     break;
6428                 }
6429                 if (ch === 92 && !jsxAttributeString) {
6430                     result += text.substring(start, pos);
6431                     result += scanEscapeSequence();
6432                     start = pos;
6433                     continue;
6434                 }
6435                 if (isLineBreak(ch) && !jsxAttributeString) {
6436                     result += text.substring(start, pos);
6437                     tokenFlags |= 4;
6438                     error(ts.Diagnostics.Unterminated_string_literal);
6439                     break;
6440                 }
6441                 pos++;
6442             }
6443             return result;
6444         }
6445         function scanTemplateAndSetTokenValue(isTaggedTemplate) {
6446             var startedWithBacktick = text.charCodeAt(pos) === 96;
6447             pos++;
6448             var start = pos;
6449             var contents = "";
6450             var resultingToken;
6451             while (true) {
6452                 if (pos >= end) {
6453                     contents += text.substring(start, pos);
6454                     tokenFlags |= 4;
6455                     error(ts.Diagnostics.Unterminated_template_literal);
6456                     resultingToken = startedWithBacktick ? 14 : 17;
6457                     break;
6458                 }
6459                 var currChar = text.charCodeAt(pos);
6460                 if (currChar === 96) {
6461                     contents += text.substring(start, pos);
6462                     pos++;
6463                     resultingToken = startedWithBacktick ? 14 : 17;
6464                     break;
6465                 }
6466                 if (currChar === 36 && pos + 1 < end && text.charCodeAt(pos + 1) === 123) {
6467                     contents += text.substring(start, pos);
6468                     pos += 2;
6469                     resultingToken = startedWithBacktick ? 15 : 16;
6470                     break;
6471                 }
6472                 if (currChar === 92) {
6473                     contents += text.substring(start, pos);
6474                     contents += scanEscapeSequence(isTaggedTemplate);
6475                     start = pos;
6476                     continue;
6477                 }
6478                 if (currChar === 13) {
6479                     contents += text.substring(start, pos);
6480                     pos++;
6481                     if (pos < end && text.charCodeAt(pos) === 10) {
6482                         pos++;
6483                     }
6484                     contents += "\n";
6485                     start = pos;
6486                     continue;
6487                 }
6488                 pos++;
6489             }
6490             ts.Debug.assert(resultingToken !== undefined);
6491             tokenValue = contents;
6492             return resultingToken;
6493         }
6494         function scanEscapeSequence(isTaggedTemplate) {
6495             var start = pos;
6496             pos++;
6497             if (pos >= end) {
6498                 error(ts.Diagnostics.Unexpected_end_of_text);
6499                 return "";
6500             }
6501             var ch = text.charCodeAt(pos);
6502             pos++;
6503             switch (ch) {
6504                 case 48:
6505                     if (isTaggedTemplate && pos < end && isDigit(text.charCodeAt(pos))) {
6506                         pos++;
6507                         tokenFlags |= 2048;
6508                         return text.substring(start, pos);
6509                     }
6510                     return "\0";
6511                 case 98:
6512                     return "\b";
6513                 case 116:
6514                     return "\t";
6515                 case 110:
6516                     return "\n";
6517                 case 118:
6518                     return "\v";
6519                 case 102:
6520                     return "\f";
6521                 case 114:
6522                     return "\r";
6523                 case 39:
6524                     return "\'";
6525                 case 34:
6526                     return "\"";
6527                 case 117:
6528                     if (isTaggedTemplate) {
6529                         for (var escapePos = pos; escapePos < pos + 4; escapePos++) {
6530                             if (escapePos < end && !isHexDigit(text.charCodeAt(escapePos)) && text.charCodeAt(escapePos) !== 123) {
6531                                 pos = escapePos;
6532                                 tokenFlags |= 2048;
6533                                 return text.substring(start, pos);
6534                             }
6535                         }
6536                     }
6537                     if (pos < end && text.charCodeAt(pos) === 123) {
6538                         pos++;
6539                         if (isTaggedTemplate && !isHexDigit(text.charCodeAt(pos))) {
6540                             tokenFlags |= 2048;
6541                             return text.substring(start, pos);
6542                         }
6543                         if (isTaggedTemplate) {
6544                             var savePos = pos;
6545                             var escapedValueString = scanMinimumNumberOfHexDigits(1, false);
6546                             var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1;
6547                             if (!isCodePoint(escapedValue) || text.charCodeAt(pos) !== 125) {
6548                                 tokenFlags |= 2048;
6549                                 return text.substring(start, pos);
6550                             }
6551                             else {
6552                                 pos = savePos;
6553                             }
6554                         }
6555                         tokenFlags |= 8;
6556                         return scanExtendedUnicodeEscape();
6557                     }
6558                     tokenFlags |= 1024;
6559                     return scanHexadecimalEscape(4);
6560                 case 120:
6561                     if (isTaggedTemplate) {
6562                         if (!isHexDigit(text.charCodeAt(pos))) {
6563                             tokenFlags |= 2048;
6564                             return text.substring(start, pos);
6565                         }
6566                         else if (!isHexDigit(text.charCodeAt(pos + 1))) {
6567                             pos++;
6568                             tokenFlags |= 2048;
6569                             return text.substring(start, pos);
6570                         }
6571                     }
6572                     return scanHexadecimalEscape(2);
6573                 case 13:
6574                     if (pos < end && text.charCodeAt(pos) === 10) {
6575                         pos++;
6576                     }
6577                 case 10:
6578                 case 8232:
6579                 case 8233:
6580                     return "";
6581                 default:
6582                     return String.fromCharCode(ch);
6583             }
6584         }
6585         function scanHexadecimalEscape(numDigits) {
6586             var escapedValue = scanExactNumberOfHexDigits(numDigits, false);
6587             if (escapedValue >= 0) {
6588                 return String.fromCharCode(escapedValue);
6589             }
6590             else {
6591                 error(ts.Diagnostics.Hexadecimal_digit_expected);
6592                 return "";
6593             }
6594         }
6595         function scanExtendedUnicodeEscape() {
6596             var escapedValueString = scanMinimumNumberOfHexDigits(1, false);
6597             var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1;
6598             var isInvalidExtendedEscape = false;
6599             if (escapedValue < 0) {
6600                 error(ts.Diagnostics.Hexadecimal_digit_expected);
6601                 isInvalidExtendedEscape = true;
6602             }
6603             else if (escapedValue > 0x10FFFF) {
6604                 error(ts.Diagnostics.An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive);
6605                 isInvalidExtendedEscape = true;
6606             }
6607             if (pos >= end) {
6608                 error(ts.Diagnostics.Unexpected_end_of_text);
6609                 isInvalidExtendedEscape = true;
6610             }
6611             else if (text.charCodeAt(pos) === 125) {
6612                 pos++;
6613             }
6614             else {
6615                 error(ts.Diagnostics.Unterminated_Unicode_escape_sequence);
6616                 isInvalidExtendedEscape = true;
6617             }
6618             if (isInvalidExtendedEscape) {
6619                 return "";
6620             }
6621             return utf16EncodeAsString(escapedValue);
6622         }
6623         function peekUnicodeEscape() {
6624             if (pos + 5 < end && text.charCodeAt(pos + 1) === 117) {
6625                 var start_1 = pos;
6626                 pos += 2;
6627                 var value = scanExactNumberOfHexDigits(4, false);
6628                 pos = start_1;
6629                 return value;
6630             }
6631             return -1;
6632         }
6633         function peekExtendedUnicodeEscape() {
6634             if (languageVersion >= 2 && codePointAt(text, pos + 1) === 117 && codePointAt(text, pos + 2) === 123) {
6635                 var start_2 = pos;
6636                 pos += 3;
6637                 var escapedValueString = scanMinimumNumberOfHexDigits(1, false);
6638                 var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1;
6639                 pos = start_2;
6640                 return escapedValue;
6641             }
6642             return -1;
6643         }
6644         function scanIdentifierParts() {
6645             var result = "";
6646             var start = pos;
6647             while (pos < end) {
6648                 var ch = codePointAt(text, pos);
6649                 if (isIdentifierPart(ch, languageVersion)) {
6650                     pos += charSize(ch);
6651                 }
6652                 else if (ch === 92) {
6653                     ch = peekExtendedUnicodeEscape();
6654                     if (ch >= 0 && isIdentifierPart(ch, languageVersion)) {
6655                         pos += 3;
6656                         tokenFlags |= 8;
6657                         result += scanExtendedUnicodeEscape();
6658                         start = pos;
6659                         continue;
6660                     }
6661                     ch = peekUnicodeEscape();
6662                     if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) {
6663                         break;
6664                     }
6665                     tokenFlags |= 1024;
6666                     result += text.substring(start, pos);
6667                     result += utf16EncodeAsString(ch);
6668                     pos += 6;
6669                     start = pos;
6670                 }
6671                 else {
6672                     break;
6673                 }
6674             }
6675             result += text.substring(start, pos);
6676             return result;
6677         }
6678         function getIdentifierToken() {
6679             var len = tokenValue.length;
6680             if (len >= 2 && len <= 11) {
6681                 var ch = tokenValue.charCodeAt(0);
6682                 if (ch >= 97 && ch <= 122) {
6683                     var keyword = textToKeyword.get(tokenValue);
6684                     if (keyword !== undefined) {
6685                         return token = keyword;
6686                     }
6687                 }
6688             }
6689             return token = 75;
6690         }
6691         function scanBinaryOrOctalDigits(base) {
6692             var value = "";
6693             var separatorAllowed = false;
6694             var isPreviousTokenSeparator = false;
6695             while (true) {
6696                 var ch = text.charCodeAt(pos);
6697                 if (ch === 95) {
6698                     tokenFlags |= 512;
6699                     if (separatorAllowed) {
6700                         separatorAllowed = false;
6701                         isPreviousTokenSeparator = true;
6702                     }
6703                     else if (isPreviousTokenSeparator) {
6704                         error(ts.Diagnostics.Multiple_consecutive_numeric_separators_are_not_permitted, pos, 1);
6705                     }
6706                     else {
6707                         error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos, 1);
6708                     }
6709                     pos++;
6710                     continue;
6711                 }
6712                 separatorAllowed = true;
6713                 if (!isDigit(ch) || ch - 48 >= base) {
6714                     break;
6715                 }
6716                 value += text[pos];
6717                 pos++;
6718                 isPreviousTokenSeparator = false;
6719             }
6720             if (text.charCodeAt(pos - 1) === 95) {
6721                 error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
6722             }
6723             return value;
6724         }
6725         function checkBigIntSuffix() {
6726             if (text.charCodeAt(pos) === 110) {
6727                 tokenValue += "n";
6728                 if (tokenFlags & 384) {
6729                     tokenValue = ts.parsePseudoBigInt(tokenValue) + "n";
6730                 }
6731                 pos++;
6732                 return 9;
6733             }
6734             else {
6735                 var numericValue = tokenFlags & 128
6736                     ? parseInt(tokenValue.slice(2), 2)
6737                     : tokenFlags & 256
6738                         ? parseInt(tokenValue.slice(2), 8)
6739                         : +tokenValue;
6740                 tokenValue = "" + numericValue;
6741                 return 8;
6742             }
6743         }
6744         function scan() {
6745             var _a;
6746             startPos = pos;
6747             tokenFlags = 0;
6748             var asteriskSeen = false;
6749             while (true) {
6750                 tokenPos = pos;
6751                 if (pos >= end) {
6752                     return token = 1;
6753                 }
6754                 var ch = codePointAt(text, pos);
6755                 if (ch === 35 && pos === 0 && isShebangTrivia(text, pos)) {
6756                     pos = scanShebangTrivia(text, pos);
6757                     if (skipTrivia) {
6758                         continue;
6759                     }
6760                     else {
6761                         return token = 6;
6762                     }
6763                 }
6764                 switch (ch) {
6765                     case 10:
6766                     case 13:
6767                         tokenFlags |= 1;
6768                         if (skipTrivia) {
6769                             pos++;
6770                             continue;
6771                         }
6772                         else {
6773                             if (ch === 13 && pos + 1 < end && text.charCodeAt(pos + 1) === 10) {
6774                                 pos += 2;
6775                             }
6776                             else {
6777                                 pos++;
6778                             }
6779                             return token = 4;
6780                         }
6781                     case 9:
6782                     case 11:
6783                     case 12:
6784                     case 32:
6785                     case 160:
6786                     case 5760:
6787                     case 8192:
6788                     case 8193:
6789                     case 8194:
6790                     case 8195:
6791                     case 8196:
6792                     case 8197:
6793                     case 8198:
6794                     case 8199:
6795                     case 8200:
6796                     case 8201:
6797                     case 8202:
6798                     case 8203:
6799                     case 8239:
6800                     case 8287:
6801                     case 12288:
6802                     case 65279:
6803                         if (skipTrivia) {
6804                             pos++;
6805                             continue;
6806                         }
6807                         else {
6808                             while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) {
6809                                 pos++;
6810                             }
6811                             return token = 5;
6812                         }
6813                     case 33:
6814                         if (text.charCodeAt(pos + 1) === 61) {
6815                             if (text.charCodeAt(pos + 2) === 61) {
6816                                 return pos += 3, token = 37;
6817                             }
6818                             return pos += 2, token = 35;
6819                         }
6820                         pos++;
6821                         return token = 53;
6822                     case 34:
6823                     case 39:
6824                         tokenValue = scanString();
6825                         return token = 10;
6826                     case 96:
6827                         return token = scanTemplateAndSetTokenValue(false);
6828                     case 37:
6829                         if (text.charCodeAt(pos + 1) === 61) {
6830                             return pos += 2, token = 68;
6831                         }
6832                         pos++;
6833                         return token = 44;
6834                     case 38:
6835                         if (text.charCodeAt(pos + 1) === 38) {
6836                             return pos += 2, token = 55;
6837                         }
6838                         if (text.charCodeAt(pos + 1) === 61) {
6839                             return pos += 2, token = 72;
6840                         }
6841                         pos++;
6842                         return token = 50;
6843                     case 40:
6844                         pos++;
6845                         return token = 20;
6846                     case 41:
6847                         pos++;
6848                         return token = 21;
6849                     case 42:
6850                         if (text.charCodeAt(pos + 1) === 61) {
6851                             return pos += 2, token = 65;
6852                         }
6853                         if (text.charCodeAt(pos + 1) === 42) {
6854                             if (text.charCodeAt(pos + 2) === 61) {
6855                                 return pos += 3, token = 66;
6856                             }
6857                             return pos += 2, token = 42;
6858                         }
6859                         pos++;
6860                         if (inJSDocType && !asteriskSeen && (tokenFlags & 1)) {
6861                             asteriskSeen = true;
6862                             continue;
6863                         }
6864                         return token = 41;
6865                     case 43:
6866                         if (text.charCodeAt(pos + 1) === 43) {
6867                             return pos += 2, token = 45;
6868                         }
6869                         if (text.charCodeAt(pos + 1) === 61) {
6870                             return pos += 2, token = 63;
6871                         }
6872                         pos++;
6873                         return token = 39;
6874                     case 44:
6875                         pos++;
6876                         return token = 27;
6877                     case 45:
6878                         if (text.charCodeAt(pos + 1) === 45) {
6879                             return pos += 2, token = 46;
6880                         }
6881                         if (text.charCodeAt(pos + 1) === 61) {
6882                             return pos += 2, token = 64;
6883                         }
6884                         pos++;
6885                         return token = 40;
6886                     case 46:
6887                         if (isDigit(text.charCodeAt(pos + 1))) {
6888                             tokenValue = scanNumber().value;
6889                             return token = 8;
6890                         }
6891                         if (text.charCodeAt(pos + 1) === 46 && text.charCodeAt(pos + 2) === 46) {
6892                             return pos += 3, token = 25;
6893                         }
6894                         pos++;
6895                         return token = 24;
6896                     case 47:
6897                         if (text.charCodeAt(pos + 1) === 47) {
6898                             pos += 2;
6899                             while (pos < end) {
6900                                 if (isLineBreak(text.charCodeAt(pos))) {
6901                                     break;
6902                                 }
6903                                 pos++;
6904                             }
6905                             commentDirectives = appendIfCommentDirective(commentDirectives, text.slice(tokenPos, pos), commentDirectiveRegExSingleLine, tokenPos);
6906                             if (skipTrivia) {
6907                                 continue;
6908                             }
6909                             else {
6910                                 return token = 2;
6911                             }
6912                         }
6913                         if (text.charCodeAt(pos + 1) === 42) {
6914                             pos += 2;
6915                             if (text.charCodeAt(pos) === 42 && text.charCodeAt(pos + 1) !== 47) {
6916                                 tokenFlags |= 2;
6917                             }
6918                             var commentClosed = false;
6919                             var lastLineStart = tokenPos;
6920                             while (pos < end) {
6921                                 var ch_1 = text.charCodeAt(pos);
6922                                 if (ch_1 === 42 && text.charCodeAt(pos + 1) === 47) {
6923                                     pos += 2;
6924                                     commentClosed = true;
6925                                     break;
6926                                 }
6927                                 pos++;
6928                                 if (isLineBreak(ch_1)) {
6929                                     lastLineStart = pos;
6930                                     tokenFlags |= 1;
6931                                 }
6932                             }
6933                             commentDirectives = appendIfCommentDirective(commentDirectives, text.slice(lastLineStart, pos), commentDirectiveRegExMultiLine, lastLineStart);
6934                             if (!commentClosed) {
6935                                 error(ts.Diagnostics.Asterisk_Slash_expected);
6936                             }
6937                             if (skipTrivia) {
6938                                 continue;
6939                             }
6940                             else {
6941                                 if (!commentClosed) {
6942                                     tokenFlags |= 4;
6943                                 }
6944                                 return token = 3;
6945                             }
6946                         }
6947                         if (text.charCodeAt(pos + 1) === 61) {
6948                             return pos += 2, token = 67;
6949                         }
6950                         pos++;
6951                         return token = 43;
6952                     case 48:
6953                         if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) {
6954                             pos += 2;
6955                             tokenValue = scanMinimumNumberOfHexDigits(1, true);
6956                             if (!tokenValue) {
6957                                 error(ts.Diagnostics.Hexadecimal_digit_expected);
6958                                 tokenValue = "0";
6959                             }
6960                             tokenValue = "0x" + tokenValue;
6961                             tokenFlags |= 64;
6962                             return token = checkBigIntSuffix();
6963                         }
6964                         else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 || text.charCodeAt(pos + 1) === 98)) {
6965                             pos += 2;
6966                             tokenValue = scanBinaryOrOctalDigits(2);
6967                             if (!tokenValue) {
6968                                 error(ts.Diagnostics.Binary_digit_expected);
6969                                 tokenValue = "0";
6970                             }
6971                             tokenValue = "0b" + tokenValue;
6972                             tokenFlags |= 128;
6973                             return token = checkBigIntSuffix();
6974                         }
6975                         else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 || text.charCodeAt(pos + 1) === 111)) {
6976                             pos += 2;
6977                             tokenValue = scanBinaryOrOctalDigits(8);
6978                             if (!tokenValue) {
6979                                 error(ts.Diagnostics.Octal_digit_expected);
6980                                 tokenValue = "0";
6981                             }
6982                             tokenValue = "0o" + tokenValue;
6983                             tokenFlags |= 256;
6984                             return token = checkBigIntSuffix();
6985                         }
6986                         if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) {
6987                             tokenValue = "" + scanOctalDigits();
6988                             tokenFlags |= 32;
6989                             return token = 8;
6990                         }
6991                     case 49:
6992                     case 50:
6993                     case 51:
6994                     case 52:
6995                     case 53:
6996                     case 54:
6997                     case 55:
6998                     case 56:
6999                     case 57:
7000                         (_a = scanNumber(), token = _a.type, tokenValue = _a.value);
7001                         return token;
7002                     case 58:
7003                         pos++;
7004                         return token = 58;
7005                     case 59:
7006                         pos++;
7007                         return token = 26;
7008                     case 60:
7009                         if (isConflictMarkerTrivia(text, pos)) {
7010                             pos = scanConflictMarkerTrivia(text, pos, error);
7011                             if (skipTrivia) {
7012                                 continue;
7013                             }
7014                             else {
7015                                 return token = 7;
7016                             }
7017                         }
7018                         if (text.charCodeAt(pos + 1) === 60) {
7019                             if (text.charCodeAt(pos + 2) === 61) {
7020                                 return pos += 3, token = 69;
7021                             }
7022                             return pos += 2, token = 47;
7023                         }
7024                         if (text.charCodeAt(pos + 1) === 61) {
7025                             return pos += 2, token = 32;
7026                         }
7027                         if (languageVariant === 1 &&
7028                             text.charCodeAt(pos + 1) === 47 &&
7029                             text.charCodeAt(pos + 2) !== 42) {
7030                             return pos += 2, token = 30;
7031                         }
7032                         pos++;
7033                         return token = 29;
7034                     case 61:
7035                         if (isConflictMarkerTrivia(text, pos)) {
7036                             pos = scanConflictMarkerTrivia(text, pos, error);
7037                             if (skipTrivia) {
7038                                 continue;
7039                             }
7040                             else {
7041                                 return token = 7;
7042                             }
7043                         }
7044                         if (text.charCodeAt(pos + 1) === 61) {
7045                             if (text.charCodeAt(pos + 2) === 61) {
7046                                 return pos += 3, token = 36;
7047                             }
7048                             return pos += 2, token = 34;
7049                         }
7050                         if (text.charCodeAt(pos + 1) === 62) {
7051                             return pos += 2, token = 38;
7052                         }
7053                         pos++;
7054                         return token = 62;
7055                     case 62:
7056                         if (isConflictMarkerTrivia(text, pos)) {
7057                             pos = scanConflictMarkerTrivia(text, pos, error);
7058                             if (skipTrivia) {
7059                                 continue;
7060                             }
7061                             else {
7062                                 return token = 7;
7063                             }
7064                         }
7065                         pos++;
7066                         return token = 31;
7067                     case 63:
7068                         pos++;
7069                         if (text.charCodeAt(pos) === 46 && !isDigit(text.charCodeAt(pos + 1))) {
7070                             pos++;
7071                             return token = 28;
7072                         }
7073                         if (text.charCodeAt(pos) === 63) {
7074                             pos++;
7075                             return token = 60;
7076                         }
7077                         return token = 57;
7078                     case 91:
7079                         pos++;
7080                         return token = 22;
7081                     case 93:
7082                         pos++;
7083                         return token = 23;
7084                     case 94:
7085                         if (text.charCodeAt(pos + 1) === 61) {
7086                             return pos += 2, token = 74;
7087                         }
7088                         pos++;
7089                         return token = 52;
7090                     case 123:
7091                         pos++;
7092                         return token = 18;
7093                     case 124:
7094                         if (isConflictMarkerTrivia(text, pos)) {
7095                             pos = scanConflictMarkerTrivia(text, pos, error);
7096                             if (skipTrivia) {
7097                                 continue;
7098                             }
7099                             else {
7100                                 return token = 7;
7101                             }
7102                         }
7103                         if (text.charCodeAt(pos + 1) === 124) {
7104                             return pos += 2, token = 56;
7105                         }
7106                         if (text.charCodeAt(pos + 1) === 61) {
7107                             return pos += 2, token = 73;
7108                         }
7109                         pos++;
7110                         return token = 51;
7111                     case 125:
7112                         pos++;
7113                         return token = 19;
7114                     case 126:
7115                         pos++;
7116                         return token = 54;
7117                     case 64:
7118                         pos++;
7119                         return token = 59;
7120                     case 92:
7121                         var extendedCookedChar = peekExtendedUnicodeEscape();
7122                         if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) {
7123                             pos += 3;
7124                             tokenFlags |= 8;
7125                             tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts();
7126                             return token = getIdentifierToken();
7127                         }
7128                         var cookedChar = peekUnicodeEscape();
7129                         if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) {
7130                             pos += 6;
7131                             tokenFlags |= 1024;
7132                             tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts();
7133                             return token = getIdentifierToken();
7134                         }
7135                         error(ts.Diagnostics.Invalid_character);
7136                         pos++;
7137                         return token = 0;
7138                     case 35:
7139                         if (pos !== 0 && text[pos + 1] === "!") {
7140                             error(ts.Diagnostics.can_only_be_used_at_the_start_of_a_file);
7141                             pos++;
7142                             return token = 0;
7143                         }
7144                         pos++;
7145                         if (isIdentifierStart(ch = text.charCodeAt(pos), languageVersion)) {
7146                             pos++;
7147                             while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion))
7148                                 pos++;
7149                             tokenValue = text.substring(tokenPos, pos);
7150                             if (ch === 92) {
7151                                 tokenValue += scanIdentifierParts();
7152                             }
7153                         }
7154                         else {
7155                             tokenValue = "#";
7156                             error(ts.Diagnostics.Invalid_character);
7157                         }
7158                         return token = 76;
7159                     default:
7160                         if (isIdentifierStart(ch, languageVersion)) {
7161                             pos += charSize(ch);
7162                             while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion))
7163                                 pos += charSize(ch);
7164                             tokenValue = text.substring(tokenPos, pos);
7165                             if (ch === 92) {
7166                                 tokenValue += scanIdentifierParts();
7167                             }
7168                             return token = getIdentifierToken();
7169                         }
7170                         else if (isWhiteSpaceSingleLine(ch)) {
7171                             pos += charSize(ch);
7172                             continue;
7173                         }
7174                         else if (isLineBreak(ch)) {
7175                             tokenFlags |= 1;
7176                             pos += charSize(ch);
7177                             continue;
7178                         }
7179                         error(ts.Diagnostics.Invalid_character);
7180                         pos += charSize(ch);
7181                         return token = 0;
7182                 }
7183             }
7184         }
7185         function reScanGreaterToken() {
7186             if (token === 31) {
7187                 if (text.charCodeAt(pos) === 62) {
7188                     if (text.charCodeAt(pos + 1) === 62) {
7189                         if (text.charCodeAt(pos + 2) === 61) {
7190                             return pos += 3, token = 71;
7191                         }
7192                         return pos += 2, token = 49;
7193                     }
7194                     if (text.charCodeAt(pos + 1) === 61) {
7195                         return pos += 2, token = 70;
7196                     }
7197                     pos++;
7198                     return token = 48;
7199                 }
7200                 if (text.charCodeAt(pos) === 61) {
7201                     pos++;
7202                     return token = 33;
7203                 }
7204             }
7205             return token;
7206         }
7207         function reScanSlashToken() {
7208             if (token === 43 || token === 67) {
7209                 var p = tokenPos + 1;
7210                 var inEscape = false;
7211                 var inCharacterClass = false;
7212                 while (true) {
7213                     if (p >= end) {
7214                         tokenFlags |= 4;
7215                         error(ts.Diagnostics.Unterminated_regular_expression_literal);
7216                         break;
7217                     }
7218                     var ch = text.charCodeAt(p);
7219                     if (isLineBreak(ch)) {
7220                         tokenFlags |= 4;
7221                         error(ts.Diagnostics.Unterminated_regular_expression_literal);
7222                         break;
7223                     }
7224                     if (inEscape) {
7225                         inEscape = false;
7226                     }
7227                     else if (ch === 47 && !inCharacterClass) {
7228                         p++;
7229                         break;
7230                     }
7231                     else if (ch === 91) {
7232                         inCharacterClass = true;
7233                     }
7234                     else if (ch === 92) {
7235                         inEscape = true;
7236                     }
7237                     else if (ch === 93) {
7238                         inCharacterClass = false;
7239                     }
7240                     p++;
7241                 }
7242                 while (p < end && isIdentifierPart(text.charCodeAt(p), languageVersion)) {
7243                     p++;
7244                 }
7245                 pos = p;
7246                 tokenValue = text.substring(tokenPos, pos);
7247                 token = 13;
7248             }
7249             return token;
7250         }
7251         function appendIfCommentDirective(commentDirectives, text, commentDirectiveRegEx, lineStart) {
7252             var type = getDirectiveFromComment(text, commentDirectiveRegEx);
7253             if (type === undefined) {
7254                 return commentDirectives;
7255             }
7256             return ts.append(commentDirectives, {
7257                 range: { pos: lineStart, end: pos },
7258                 type: type,
7259             });
7260         }
7261         function getDirectiveFromComment(text, commentDirectiveRegEx) {
7262             var match = commentDirectiveRegEx.exec(text);
7263             if (!match) {
7264                 return undefined;
7265             }
7266             switch (match[1]) {
7267                 case "ts-expect-error":
7268                     return 0;
7269                 case "ts-ignore":
7270                     return 1;
7271             }
7272             return undefined;
7273         }
7274         function reScanTemplateToken(isTaggedTemplate) {
7275             ts.Debug.assert(token === 19, "'reScanTemplateToken' should only be called on a '}'");
7276             pos = tokenPos;
7277             return token = scanTemplateAndSetTokenValue(isTaggedTemplate);
7278         }
7279         function reScanTemplateHeadOrNoSubstitutionTemplate() {
7280             pos = tokenPos;
7281             return token = scanTemplateAndSetTokenValue(true);
7282         }
7283         function reScanJsxToken() {
7284             pos = tokenPos = startPos;
7285             return token = scanJsxToken();
7286         }
7287         function reScanLessThanToken() {
7288             if (token === 47) {
7289                 pos = tokenPos + 1;
7290                 return token = 29;
7291             }
7292             return token;
7293         }
7294         function reScanQuestionToken() {
7295             ts.Debug.assert(token === 60, "'reScanQuestionToken' should only be called on a '??'");
7296             pos = tokenPos + 1;
7297             return token = 57;
7298         }
7299         function scanJsxToken() {
7300             startPos = tokenPos = pos;
7301             if (pos >= end) {
7302                 return token = 1;
7303             }
7304             var char = text.charCodeAt(pos);
7305             if (char === 60) {
7306                 if (text.charCodeAt(pos + 1) === 47) {
7307                     pos += 2;
7308                     return token = 30;
7309                 }
7310                 pos++;
7311                 return token = 29;
7312             }
7313             if (char === 123) {
7314                 pos++;
7315                 return token = 18;
7316             }
7317             var firstNonWhitespace = 0;
7318             var lastNonWhitespace = -1;
7319             while (pos < end) {
7320                 if (!isWhiteSpaceSingleLine(char)) {
7321                     lastNonWhitespace = pos;
7322                 }
7323                 char = text.charCodeAt(pos);
7324                 if (char === 123) {
7325                     break;
7326                 }
7327                 if (char === 60) {
7328                     if (isConflictMarkerTrivia(text, pos)) {
7329                         pos = scanConflictMarkerTrivia(text, pos, error);
7330                         return token = 7;
7331                     }
7332                     break;
7333                 }
7334                 if (char === 62) {
7335                     error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_gt, pos, 1);
7336                 }
7337                 if (char === 125) {
7338                     error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_rbrace, pos, 1);
7339                 }
7340                 if (lastNonWhitespace > 0)
7341                     lastNonWhitespace++;
7342                 if (isLineBreak(char) && firstNonWhitespace === 0) {
7343                     firstNonWhitespace = -1;
7344                 }
7345                 else if (!isWhiteSpaceLike(char)) {
7346                     firstNonWhitespace = pos;
7347                 }
7348                 pos++;
7349             }
7350             var endPosition = lastNonWhitespace === -1 ? pos : lastNonWhitespace;
7351             tokenValue = text.substring(startPos, endPosition);
7352             return firstNonWhitespace === -1 ? 12 : 11;
7353         }
7354         function scanJsxIdentifier() {
7355             if (tokenIsIdentifierOrKeyword(token)) {
7356                 while (pos < end) {
7357                     var ch = text.charCodeAt(pos);
7358                     if (ch === 45) {
7359                         tokenValue += "-";
7360                         pos++;
7361                         continue;
7362                     }
7363                     var oldPos = pos;
7364                     tokenValue += scanIdentifierParts();
7365                     if (pos === oldPos) {
7366                         break;
7367                     }
7368                 }
7369             }
7370             return token;
7371         }
7372         function scanJsxAttributeValue() {
7373             startPos = pos;
7374             switch (text.charCodeAt(pos)) {
7375                 case 34:
7376                 case 39:
7377                     tokenValue = scanString(true);
7378                     return token = 10;
7379                 default:
7380                     return scan();
7381             }
7382         }
7383         function reScanJsxAttributeValue() {
7384             pos = tokenPos = startPos;
7385             return scanJsxAttributeValue();
7386         }
7387         function scanJsDocToken() {
7388             startPos = tokenPos = pos;
7389             tokenFlags = 0;
7390             if (pos >= end) {
7391                 return token = 1;
7392             }
7393             var ch = codePointAt(text, pos);
7394             pos += charSize(ch);
7395             switch (ch) {
7396                 case 9:
7397                 case 11:
7398                 case 12:
7399                 case 32:
7400                     while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) {
7401                         pos++;
7402                     }
7403                     return token = 5;
7404                 case 64:
7405                     return token = 59;
7406                 case 10:
7407                 case 13:
7408                     tokenFlags |= 1;
7409                     return token = 4;
7410                 case 42:
7411                     return token = 41;
7412                 case 123:
7413                     return token = 18;
7414                 case 125:
7415                     return token = 19;
7416                 case 91:
7417                     return token = 22;
7418                 case 93:
7419                     return token = 23;
7420                 case 60:
7421                     return token = 29;
7422                 case 62:
7423                     return token = 31;
7424                 case 61:
7425                     return token = 62;
7426                 case 44:
7427                     return token = 27;
7428                 case 46:
7429                     return token = 24;
7430                 case 96:
7431                     return token = 61;
7432                 case 92:
7433                     pos--;
7434                     var extendedCookedChar = peekExtendedUnicodeEscape();
7435                     if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) {
7436                         pos += 3;
7437                         tokenFlags |= 8;
7438                         tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts();
7439                         return token = getIdentifierToken();
7440                     }
7441                     var cookedChar = peekUnicodeEscape();
7442                     if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) {
7443                         pos += 6;
7444                         tokenFlags |= 1024;
7445                         tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts();
7446                         return token = getIdentifierToken();
7447                     }
7448                     pos++;
7449                     return token = 0;
7450             }
7451             if (isIdentifierStart(ch, languageVersion)) {
7452                 var char = ch;
7453                 while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45)
7454                     pos += charSize(char);
7455                 tokenValue = text.substring(tokenPos, pos);
7456                 if (char === 92) {
7457                     tokenValue += scanIdentifierParts();
7458                 }
7459                 return token = getIdentifierToken();
7460             }
7461             else {
7462                 return token = 0;
7463             }
7464         }
7465         function speculationHelper(callback, isLookahead) {
7466             var savePos = pos;
7467             var saveStartPos = startPos;
7468             var saveTokenPos = tokenPos;
7469             var saveToken = token;
7470             var saveTokenValue = tokenValue;
7471             var saveTokenFlags = tokenFlags;
7472             var result = callback();
7473             if (!result || isLookahead) {
7474                 pos = savePos;
7475                 startPos = saveStartPos;
7476                 tokenPos = saveTokenPos;
7477                 token = saveToken;
7478                 tokenValue = saveTokenValue;
7479                 tokenFlags = saveTokenFlags;
7480             }
7481             return result;
7482         }
7483         function scanRange(start, length, callback) {
7484             var saveEnd = end;
7485             var savePos = pos;
7486             var saveStartPos = startPos;
7487             var saveTokenPos = tokenPos;
7488             var saveToken = token;
7489             var saveTokenValue = tokenValue;
7490             var saveTokenFlags = tokenFlags;
7491             var saveErrorExpectations = commentDirectives;
7492             setText(text, start, length);
7493             var result = callback();
7494             end = saveEnd;
7495             pos = savePos;
7496             startPos = saveStartPos;
7497             tokenPos = saveTokenPos;
7498             token = saveToken;
7499             tokenValue = saveTokenValue;
7500             tokenFlags = saveTokenFlags;
7501             commentDirectives = saveErrorExpectations;
7502             return result;
7503         }
7504         function lookAhead(callback) {
7505             return speculationHelper(callback, true);
7506         }
7507         function tryScan(callback) {
7508             return speculationHelper(callback, false);
7509         }
7510         function getText() {
7511             return text;
7512         }
7513         function clearCommentDirectives() {
7514             commentDirectives = undefined;
7515         }
7516         function setText(newText, start, length) {
7517             text = newText || "";
7518             end = length === undefined ? text.length : start + length;
7519             setTextPos(start || 0);
7520         }
7521         function setOnError(errorCallback) {
7522             onError = errorCallback;
7523         }
7524         function setScriptTarget(scriptTarget) {
7525             languageVersion = scriptTarget;
7526         }
7527         function setLanguageVariant(variant) {
7528             languageVariant = variant;
7529         }
7530         function setTextPos(textPos) {
7531             ts.Debug.assert(textPos >= 0);
7532             pos = textPos;
7533             startPos = textPos;
7534             tokenPos = textPos;
7535             token = 0;
7536             tokenValue = undefined;
7537             tokenFlags = 0;
7538         }
7539         function setInJSDocType(inType) {
7540             inJSDocType += inType ? 1 : -1;
7541         }
7542     }
7543     ts.createScanner = createScanner;
7544     var codePointAt = String.prototype.codePointAt ? function (s, i) { return s.codePointAt(i); } : function codePointAt(str, i) {
7545         var size = str.length;
7546         if (i < 0 || i >= size) {
7547             return undefined;
7548         }
7549         var first = str.charCodeAt(i);
7550         if (first >= 0xD800 && first <= 0xDBFF && size > i + 1) {
7551             var second = str.charCodeAt(i + 1);
7552             if (second >= 0xDC00 && second <= 0xDFFF) {
7553                 return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
7554             }
7555         }
7556         return first;
7557     };
7558     function charSize(ch) {
7559         if (ch >= 0x10000) {
7560             return 2;
7561         }
7562         return 1;
7563     }
7564     function utf16EncodeAsStringFallback(codePoint) {
7565         ts.Debug.assert(0x0 <= codePoint && codePoint <= 0x10FFFF);
7566         if (codePoint <= 65535) {
7567             return String.fromCharCode(codePoint);
7568         }
7569         var codeUnit1 = Math.floor((codePoint - 65536) / 1024) + 0xD800;
7570         var codeUnit2 = ((codePoint - 65536) % 1024) + 0xDC00;
7571         return String.fromCharCode(codeUnit1, codeUnit2);
7572     }
7573     var utf16EncodeAsStringWorker = String.fromCodePoint ? function (codePoint) { return String.fromCodePoint(codePoint); } : utf16EncodeAsStringFallback;
7574     function utf16EncodeAsString(codePoint) {
7575         return utf16EncodeAsStringWorker(codePoint);
7576     }
7577     ts.utf16EncodeAsString = utf16EncodeAsString;
7578 })(ts || (ts = {}));
7579 var ts;
7580 (function (ts) {
7581     function isExternalModuleNameRelative(moduleName) {
7582         return ts.pathIsRelative(moduleName) || ts.isRootedDiskPath(moduleName);
7583     }
7584     ts.isExternalModuleNameRelative = isExternalModuleNameRelative;
7585     function sortAndDeduplicateDiagnostics(diagnostics) {
7586         return ts.sortAndDeduplicate(diagnostics, ts.compareDiagnostics);
7587     }
7588     ts.sortAndDeduplicateDiagnostics = sortAndDeduplicateDiagnostics;
7589     function getDefaultLibFileName(options) {
7590         switch (options.target) {
7591             case 99:
7592                 return "lib.esnext.full.d.ts";
7593             case 7:
7594                 return "lib.es2020.full.d.ts";
7595             case 6:
7596                 return "lib.es2019.full.d.ts";
7597             case 5:
7598                 return "lib.es2018.full.d.ts";
7599             case 4:
7600                 return "lib.es2017.full.d.ts";
7601             case 3:
7602                 return "lib.es2016.full.d.ts";
7603             case 2:
7604                 return "lib.es6.d.ts";
7605             default:
7606                 return "lib.d.ts";
7607         }
7608     }
7609     ts.getDefaultLibFileName = getDefaultLibFileName;
7610     function textSpanEnd(span) {
7611         return span.start + span.length;
7612     }
7613     ts.textSpanEnd = textSpanEnd;
7614     function textSpanIsEmpty(span) {
7615         return span.length === 0;
7616     }
7617     ts.textSpanIsEmpty = textSpanIsEmpty;
7618     function textSpanContainsPosition(span, position) {
7619         return position >= span.start && position < textSpanEnd(span);
7620     }
7621     ts.textSpanContainsPosition = textSpanContainsPosition;
7622     function textRangeContainsPositionInclusive(span, position) {
7623         return position >= span.pos && position <= span.end;
7624     }
7625     ts.textRangeContainsPositionInclusive = textRangeContainsPositionInclusive;
7626     function textSpanContainsTextSpan(span, other) {
7627         return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span);
7628     }
7629     ts.textSpanContainsTextSpan = textSpanContainsTextSpan;
7630     function textSpanOverlapsWith(span, other) {
7631         return textSpanOverlap(span, other) !== undefined;
7632     }
7633     ts.textSpanOverlapsWith = textSpanOverlapsWith;
7634     function textSpanOverlap(span1, span2) {
7635         var overlap = textSpanIntersection(span1, span2);
7636         return overlap && overlap.length === 0 ? undefined : overlap;
7637     }
7638     ts.textSpanOverlap = textSpanOverlap;
7639     function textSpanIntersectsWithTextSpan(span, other) {
7640         return decodedTextSpanIntersectsWith(span.start, span.length, other.start, other.length);
7641     }
7642     ts.textSpanIntersectsWithTextSpan = textSpanIntersectsWithTextSpan;
7643     function textSpanIntersectsWith(span, start, length) {
7644         return decodedTextSpanIntersectsWith(span.start, span.length, start, length);
7645     }
7646     ts.textSpanIntersectsWith = textSpanIntersectsWith;
7647     function decodedTextSpanIntersectsWith(start1, length1, start2, length2) {
7648         var end1 = start1 + length1;
7649         var end2 = start2 + length2;
7650         return start2 <= end1 && end2 >= start1;
7651     }
7652     ts.decodedTextSpanIntersectsWith = decodedTextSpanIntersectsWith;
7653     function textSpanIntersectsWithPosition(span, position) {
7654         return position <= textSpanEnd(span) && position >= span.start;
7655     }
7656     ts.textSpanIntersectsWithPosition = textSpanIntersectsWithPosition;
7657     function textSpanIntersection(span1, span2) {
7658         var start = Math.max(span1.start, span2.start);
7659         var end = Math.min(textSpanEnd(span1), textSpanEnd(span2));
7660         return start <= end ? createTextSpanFromBounds(start, end) : undefined;
7661     }
7662     ts.textSpanIntersection = textSpanIntersection;
7663     function createTextSpan(start, length) {
7664         if (start < 0) {
7665             throw new Error("start < 0");
7666         }
7667         if (length < 0) {
7668             throw new Error("length < 0");
7669         }
7670         return { start: start, length: length };
7671     }
7672     ts.createTextSpan = createTextSpan;
7673     function createTextSpanFromBounds(start, end) {
7674         return createTextSpan(start, end - start);
7675     }
7676     ts.createTextSpanFromBounds = createTextSpanFromBounds;
7677     function textChangeRangeNewSpan(range) {
7678         return createTextSpan(range.span.start, range.newLength);
7679     }
7680     ts.textChangeRangeNewSpan = textChangeRangeNewSpan;
7681     function textChangeRangeIsUnchanged(range) {
7682         return textSpanIsEmpty(range.span) && range.newLength === 0;
7683     }
7684     ts.textChangeRangeIsUnchanged = textChangeRangeIsUnchanged;
7685     function createTextChangeRange(span, newLength) {
7686         if (newLength < 0) {
7687             throw new Error("newLength < 0");
7688         }
7689         return { span: span, newLength: newLength };
7690     }
7691     ts.createTextChangeRange = createTextChangeRange;
7692     ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0);
7693     function collapseTextChangeRangesAcrossMultipleVersions(changes) {
7694         if (changes.length === 0) {
7695             return ts.unchangedTextChangeRange;
7696         }
7697         if (changes.length === 1) {
7698             return changes[0];
7699         }
7700         var change0 = changes[0];
7701         var oldStartN = change0.span.start;
7702         var oldEndN = textSpanEnd(change0.span);
7703         var newEndN = oldStartN + change0.newLength;
7704         for (var i = 1; i < changes.length; i++) {
7705             var nextChange = changes[i];
7706             var oldStart1 = oldStartN;
7707             var oldEnd1 = oldEndN;
7708             var newEnd1 = newEndN;
7709             var oldStart2 = nextChange.span.start;
7710             var oldEnd2 = textSpanEnd(nextChange.span);
7711             var newEnd2 = oldStart2 + nextChange.newLength;
7712             oldStartN = Math.min(oldStart1, oldStart2);
7713             oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1));
7714             newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2));
7715         }
7716         return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), newEndN - oldStartN);
7717     }
7718     ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions;
7719     function getTypeParameterOwner(d) {
7720         if (d && d.kind === 155) {
7721             for (var current = d; current; current = current.parent) {
7722                 if (isFunctionLike(current) || isClassLike(current) || current.kind === 246) {
7723                     return current;
7724                 }
7725             }
7726         }
7727     }
7728     ts.getTypeParameterOwner = getTypeParameterOwner;
7729     function isParameterPropertyDeclaration(node, parent) {
7730         return ts.hasModifier(node, 92) && parent.kind === 162;
7731     }
7732     ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration;
7733     function isEmptyBindingPattern(node) {
7734         if (isBindingPattern(node)) {
7735             return ts.every(node.elements, isEmptyBindingElement);
7736         }
7737         return false;
7738     }
7739     ts.isEmptyBindingPattern = isEmptyBindingPattern;
7740     function isEmptyBindingElement(node) {
7741         if (isOmittedExpression(node)) {
7742             return true;
7743         }
7744         return isEmptyBindingPattern(node.name);
7745     }
7746     ts.isEmptyBindingElement = isEmptyBindingElement;
7747     function walkUpBindingElementsAndPatterns(binding) {
7748         var node = binding.parent;
7749         while (isBindingElement(node.parent)) {
7750             node = node.parent.parent;
7751         }
7752         return node.parent;
7753     }
7754     ts.walkUpBindingElementsAndPatterns = walkUpBindingElementsAndPatterns;
7755     function getCombinedFlags(node, getFlags) {
7756         if (isBindingElement(node)) {
7757             node = walkUpBindingElementsAndPatterns(node);
7758         }
7759         var flags = getFlags(node);
7760         if (node.kind === 242) {
7761             node = node.parent;
7762         }
7763         if (node && node.kind === 243) {
7764             flags |= getFlags(node);
7765             node = node.parent;
7766         }
7767         if (node && node.kind === 225) {
7768             flags |= getFlags(node);
7769         }
7770         return flags;
7771     }
7772     function getCombinedModifierFlags(node) {
7773         return getCombinedFlags(node, ts.getModifierFlags);
7774     }
7775     ts.getCombinedModifierFlags = getCombinedModifierFlags;
7776     function getCombinedNodeFlags(node) {
7777         return getCombinedFlags(node, function (n) { return n.flags; });
7778     }
7779     ts.getCombinedNodeFlags = getCombinedNodeFlags;
7780     function validateLocaleAndSetLanguage(locale, sys, errors) {
7781         var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase());
7782         if (!matchResult) {
7783             if (errors) {
7784                 errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, "en", "ja-jp"));
7785             }
7786             return;
7787         }
7788         var language = matchResult[1];
7789         var territory = matchResult[3];
7790         if (!trySetLanguageAndTerritory(language, territory, errors)) {
7791             trySetLanguageAndTerritory(language, undefined, errors);
7792         }
7793         ts.setUILocale(locale);
7794         function trySetLanguageAndTerritory(language, territory, errors) {
7795             var compilerFilePath = ts.normalizePath(sys.getExecutingFilePath());
7796             var containingDirectoryPath = ts.getDirectoryPath(compilerFilePath);
7797             var filePath = ts.combinePaths(containingDirectoryPath, language);
7798             if (territory) {
7799                 filePath = filePath + "-" + territory;
7800             }
7801             filePath = sys.resolvePath(ts.combinePaths(filePath, "diagnosticMessages.generated.json"));
7802             if (!sys.fileExists(filePath)) {
7803                 return false;
7804             }
7805             var fileContents = "";
7806             try {
7807                 fileContents = sys.readFile(filePath);
7808             }
7809             catch (e) {
7810                 if (errors) {
7811                     errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unable_to_open_file_0, filePath));
7812                 }
7813                 return false;
7814             }
7815             try {
7816                 ts.setLocalizedDiagnosticMessages(JSON.parse(fileContents));
7817             }
7818             catch (_a) {
7819                 if (errors) {
7820                     errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Corrupted_locale_file_0, filePath));
7821                 }
7822                 return false;
7823             }
7824             return true;
7825         }
7826     }
7827     ts.validateLocaleAndSetLanguage = validateLocaleAndSetLanguage;
7828     function getOriginalNode(node, nodeTest) {
7829         if (node) {
7830             while (node.original !== undefined) {
7831                 node = node.original;
7832             }
7833         }
7834         return !nodeTest || nodeTest(node) ? node : undefined;
7835     }
7836     ts.getOriginalNode = getOriginalNode;
7837     function isParseTreeNode(node) {
7838         return (node.flags & 8) === 0;
7839     }
7840     ts.isParseTreeNode = isParseTreeNode;
7841     function getParseTreeNode(node, nodeTest) {
7842         if (node === undefined || isParseTreeNode(node)) {
7843             return node;
7844         }
7845         node = getOriginalNode(node);
7846         if (isParseTreeNode(node) && (!nodeTest || nodeTest(node))) {
7847             return node;
7848         }
7849         return undefined;
7850     }
7851     ts.getParseTreeNode = getParseTreeNode;
7852     function escapeLeadingUnderscores(identifier) {
7853         return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 ? "_" + identifier : identifier);
7854     }
7855     ts.escapeLeadingUnderscores = escapeLeadingUnderscores;
7856     function unescapeLeadingUnderscores(identifier) {
7857         var id = identifier;
7858         return id.length >= 3 && id.charCodeAt(0) === 95 && id.charCodeAt(1) === 95 && id.charCodeAt(2) === 95 ? id.substr(1) : id;
7859     }
7860     ts.unescapeLeadingUnderscores = unescapeLeadingUnderscores;
7861     function idText(identifierOrPrivateName) {
7862         return unescapeLeadingUnderscores(identifierOrPrivateName.escapedText);
7863     }
7864     ts.idText = idText;
7865     function symbolName(symbol) {
7866         if (symbol.valueDeclaration && isPrivateIdentifierPropertyDeclaration(symbol.valueDeclaration)) {
7867             return idText(symbol.valueDeclaration.name);
7868         }
7869         return unescapeLeadingUnderscores(symbol.escapedName);
7870     }
7871     ts.symbolName = symbolName;
7872     function nameForNamelessJSDocTypedef(declaration) {
7873         var hostNode = declaration.parent.parent;
7874         if (!hostNode) {
7875             return undefined;
7876         }
7877         if (isDeclaration(hostNode)) {
7878             return getDeclarationIdentifier(hostNode);
7879         }
7880         switch (hostNode.kind) {
7881             case 225:
7882                 if (hostNode.declarationList && hostNode.declarationList.declarations[0]) {
7883                     return getDeclarationIdentifier(hostNode.declarationList.declarations[0]);
7884                 }
7885                 break;
7886             case 226:
7887                 var expr = hostNode.expression;
7888                 if (expr.kind === 209 && expr.operatorToken.kind === 62) {
7889                     expr = expr.left;
7890                 }
7891                 switch (expr.kind) {
7892                     case 194:
7893                         return expr.name;
7894                     case 195:
7895                         var arg = expr.argumentExpression;
7896                         if (isIdentifier(arg)) {
7897                             return arg;
7898                         }
7899                 }
7900                 break;
7901             case 200: {
7902                 return getDeclarationIdentifier(hostNode.expression);
7903             }
7904             case 238: {
7905                 if (isDeclaration(hostNode.statement) || isExpression(hostNode.statement)) {
7906                     return getDeclarationIdentifier(hostNode.statement);
7907                 }
7908                 break;
7909             }
7910         }
7911     }
7912     function getDeclarationIdentifier(node) {
7913         var name = getNameOfDeclaration(node);
7914         return name && isIdentifier(name) ? name : undefined;
7915     }
7916     function nodeHasName(statement, name) {
7917         if (isNamedDeclaration(statement) && isIdentifier(statement.name) && idText(statement.name) === idText(name)) {
7918             return true;
7919         }
7920         if (isVariableStatement(statement) && ts.some(statement.declarationList.declarations, function (d) { return nodeHasName(d, name); })) {
7921             return true;
7922         }
7923         return false;
7924     }
7925     ts.nodeHasName = nodeHasName;
7926     function getNameOfJSDocTypedef(declaration) {
7927         return declaration.name || nameForNamelessJSDocTypedef(declaration);
7928     }
7929     ts.getNameOfJSDocTypedef = getNameOfJSDocTypedef;
7930     function isNamedDeclaration(node) {
7931         return !!node.name;
7932     }
7933     ts.isNamedDeclaration = isNamedDeclaration;
7934     function getNonAssignedNameOfDeclaration(declaration) {
7935         switch (declaration.kind) {
7936             case 75:
7937                 return declaration;
7938             case 323:
7939             case 317: {
7940                 var name = declaration.name;
7941                 if (name.kind === 153) {
7942                     return name.right;
7943                 }
7944                 break;
7945             }
7946             case 196:
7947             case 209: {
7948                 var expr_1 = declaration;
7949                 switch (ts.getAssignmentDeclarationKind(expr_1)) {
7950                     case 1:
7951                     case 4:
7952                     case 5:
7953                     case 3:
7954                         return ts.getElementOrPropertyAccessArgumentExpressionOrName(expr_1.left);
7955                     case 7:
7956                     case 8:
7957                     case 9:
7958                         return expr_1.arguments[1];
7959                     default:
7960                         return undefined;
7961                 }
7962             }
7963             case 322:
7964                 return getNameOfJSDocTypedef(declaration);
7965             case 316:
7966                 return nameForNamelessJSDocTypedef(declaration);
7967             case 259: {
7968                 var expression = declaration.expression;
7969                 return isIdentifier(expression) ? expression : undefined;
7970             }
7971             case 195:
7972                 var expr = declaration;
7973                 if (ts.isBindableStaticElementAccessExpression(expr)) {
7974                     return expr.argumentExpression;
7975                 }
7976         }
7977         return declaration.name;
7978     }
7979     ts.getNonAssignedNameOfDeclaration = getNonAssignedNameOfDeclaration;
7980     function getNameOfDeclaration(declaration) {
7981         if (declaration === undefined)
7982             return undefined;
7983         return getNonAssignedNameOfDeclaration(declaration) ||
7984             (isFunctionExpression(declaration) || isClassExpression(declaration) ? getAssignedName(declaration) : undefined);
7985     }
7986     ts.getNameOfDeclaration = getNameOfDeclaration;
7987     function getAssignedName(node) {
7988         if (!node.parent) {
7989             return undefined;
7990         }
7991         else if (isPropertyAssignment(node.parent) || isBindingElement(node.parent)) {
7992             return node.parent.name;
7993         }
7994         else if (isBinaryExpression(node.parent) && node === node.parent.right) {
7995             if (isIdentifier(node.parent.left)) {
7996                 return node.parent.left;
7997             }
7998             else if (ts.isAccessExpression(node.parent.left)) {
7999                 return ts.getElementOrPropertyAccessArgumentExpressionOrName(node.parent.left);
8000             }
8001         }
8002         else if (isVariableDeclaration(node.parent) && isIdentifier(node.parent.name)) {
8003             return node.parent.name;
8004         }
8005     }
8006     function getJSDocParameterTags(param) {
8007         if (param.name) {
8008             if (isIdentifier(param.name)) {
8009                 var name_1 = param.name.escapedText;
8010                 return getJSDocTags(param.parent).filter(function (tag) { return isJSDocParameterTag(tag) && isIdentifier(tag.name) && tag.name.escapedText === name_1; });
8011             }
8012             else {
8013                 var i = param.parent.parameters.indexOf(param);
8014                 ts.Debug.assert(i > -1, "Parameters should always be in their parents' parameter list");
8015                 var paramTags = getJSDocTags(param.parent).filter(isJSDocParameterTag);
8016                 if (i < paramTags.length) {
8017                     return [paramTags[i]];
8018                 }
8019             }
8020         }
8021         return ts.emptyArray;
8022     }
8023     ts.getJSDocParameterTags = getJSDocParameterTags;
8024     function getJSDocTypeParameterTags(param) {
8025         var name = param.name.escapedText;
8026         return getJSDocTags(param.parent).filter(function (tag) {
8027             return isJSDocTemplateTag(tag) && tag.typeParameters.some(function (tp) { return tp.name.escapedText === name; });
8028         });
8029     }
8030     ts.getJSDocTypeParameterTags = getJSDocTypeParameterTags;
8031     function hasJSDocParameterTags(node) {
8032         return !!getFirstJSDocTag(node, isJSDocParameterTag);
8033     }
8034     ts.hasJSDocParameterTags = hasJSDocParameterTags;
8035     function getJSDocAugmentsTag(node) {
8036         return getFirstJSDocTag(node, isJSDocAugmentsTag);
8037     }
8038     ts.getJSDocAugmentsTag = getJSDocAugmentsTag;
8039     function getJSDocImplementsTags(node) {
8040         return getAllJSDocTags(node, isJSDocImplementsTag);
8041     }
8042     ts.getJSDocImplementsTags = getJSDocImplementsTags;
8043     function getJSDocClassTag(node) {
8044         return getFirstJSDocTag(node, isJSDocClassTag);
8045     }
8046     ts.getJSDocClassTag = getJSDocClassTag;
8047     function getJSDocPublicTag(node) {
8048         return getFirstJSDocTag(node, isJSDocPublicTag);
8049     }
8050     ts.getJSDocPublicTag = getJSDocPublicTag;
8051     function getJSDocPrivateTag(node) {
8052         return getFirstJSDocTag(node, isJSDocPrivateTag);
8053     }
8054     ts.getJSDocPrivateTag = getJSDocPrivateTag;
8055     function getJSDocProtectedTag(node) {
8056         return getFirstJSDocTag(node, isJSDocProtectedTag);
8057     }
8058     ts.getJSDocProtectedTag = getJSDocProtectedTag;
8059     function getJSDocReadonlyTag(node) {
8060         return getFirstJSDocTag(node, isJSDocReadonlyTag);
8061     }
8062     ts.getJSDocReadonlyTag = getJSDocReadonlyTag;
8063     function getJSDocEnumTag(node) {
8064         return getFirstJSDocTag(node, isJSDocEnumTag);
8065     }
8066     ts.getJSDocEnumTag = getJSDocEnumTag;
8067     function getJSDocThisTag(node) {
8068         return getFirstJSDocTag(node, isJSDocThisTag);
8069     }
8070     ts.getJSDocThisTag = getJSDocThisTag;
8071     function getJSDocReturnTag(node) {
8072         return getFirstJSDocTag(node, isJSDocReturnTag);
8073     }
8074     ts.getJSDocReturnTag = getJSDocReturnTag;
8075     function getJSDocTemplateTag(node) {
8076         return getFirstJSDocTag(node, isJSDocTemplateTag);
8077     }
8078     ts.getJSDocTemplateTag = getJSDocTemplateTag;
8079     function getJSDocTypeTag(node) {
8080         var tag = getFirstJSDocTag(node, isJSDocTypeTag);
8081         if (tag && tag.typeExpression && tag.typeExpression.type) {
8082             return tag;
8083         }
8084         return undefined;
8085     }
8086     ts.getJSDocTypeTag = getJSDocTypeTag;
8087     function getJSDocType(node) {
8088         var tag = getFirstJSDocTag(node, isJSDocTypeTag);
8089         if (!tag && isParameter(node)) {
8090             tag = ts.find(getJSDocParameterTags(node), function (tag) { return !!tag.typeExpression; });
8091         }
8092         return tag && tag.typeExpression && tag.typeExpression.type;
8093     }
8094     ts.getJSDocType = getJSDocType;
8095     function getJSDocReturnType(node) {
8096         var returnTag = getJSDocReturnTag(node);
8097         if (returnTag && returnTag.typeExpression) {
8098             return returnTag.typeExpression.type;
8099         }
8100         var typeTag = getJSDocTypeTag(node);
8101         if (typeTag && typeTag.typeExpression) {
8102             var type = typeTag.typeExpression.type;
8103             if (isTypeLiteralNode(type)) {
8104                 var sig = ts.find(type.members, isCallSignatureDeclaration);
8105                 return sig && sig.type;
8106             }
8107             if (isFunctionTypeNode(type) || isJSDocFunctionType(type)) {
8108                 return type.type;
8109             }
8110         }
8111     }
8112     ts.getJSDocReturnType = getJSDocReturnType;
8113     function getJSDocTags(node) {
8114         var tags = node.jsDocCache;
8115         if (tags === undefined) {
8116             var comments = ts.getJSDocCommentsAndTags(node);
8117             ts.Debug.assert(comments.length < 2 || comments[0] !== comments[1]);
8118             node.jsDocCache = tags = ts.flatMap(comments, function (j) { return isJSDoc(j) ? j.tags : j; });
8119         }
8120         return tags;
8121     }
8122     ts.getJSDocTags = getJSDocTags;
8123     function getFirstJSDocTag(node, predicate) {
8124         return ts.find(getJSDocTags(node), predicate);
8125     }
8126     function getAllJSDocTags(node, predicate) {
8127         return getJSDocTags(node).filter(predicate);
8128     }
8129     ts.getAllJSDocTags = getAllJSDocTags;
8130     function getAllJSDocTagsOfKind(node, kind) {
8131         return getJSDocTags(node).filter(function (doc) { return doc.kind === kind; });
8132     }
8133     ts.getAllJSDocTagsOfKind = getAllJSDocTagsOfKind;
8134     function getEffectiveTypeParameterDeclarations(node) {
8135         if (isJSDocSignature(node)) {
8136             return ts.emptyArray;
8137         }
8138         if (ts.isJSDocTypeAlias(node)) {
8139             ts.Debug.assert(node.parent.kind === 303);
8140             return ts.flatMap(node.parent.tags, function (tag) { return isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; });
8141         }
8142         if (node.typeParameters) {
8143             return node.typeParameters;
8144         }
8145         if (ts.isInJSFile(node)) {
8146             var decls = ts.getJSDocTypeParameterDeclarations(node);
8147             if (decls.length) {
8148                 return decls;
8149             }
8150             var typeTag = getJSDocType(node);
8151             if (typeTag && isFunctionTypeNode(typeTag) && typeTag.typeParameters) {
8152                 return typeTag.typeParameters;
8153             }
8154         }
8155         return ts.emptyArray;
8156     }
8157     ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations;
8158     function getEffectiveConstraintOfTypeParameter(node) {
8159         return node.constraint ? node.constraint :
8160             isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] ? node.parent.constraint :
8161                 undefined;
8162     }
8163     ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter;
8164     function isNumericLiteral(node) {
8165         return node.kind === 8;
8166     }
8167     ts.isNumericLiteral = isNumericLiteral;
8168     function isBigIntLiteral(node) {
8169         return node.kind === 9;
8170     }
8171     ts.isBigIntLiteral = isBigIntLiteral;
8172     function isStringLiteral(node) {
8173         return node.kind === 10;
8174     }
8175     ts.isStringLiteral = isStringLiteral;
8176     function isJsxText(node) {
8177         return node.kind === 11;
8178     }
8179     ts.isJsxText = isJsxText;
8180     function isRegularExpressionLiteral(node) {
8181         return node.kind === 13;
8182     }
8183     ts.isRegularExpressionLiteral = isRegularExpressionLiteral;
8184     function isNoSubstitutionTemplateLiteral(node) {
8185         return node.kind === 14;
8186     }
8187     ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral;
8188     function isTemplateHead(node) {
8189         return node.kind === 15;
8190     }
8191     ts.isTemplateHead = isTemplateHead;
8192     function isTemplateMiddle(node) {
8193         return node.kind === 16;
8194     }
8195     ts.isTemplateMiddle = isTemplateMiddle;
8196     function isTemplateTail(node) {
8197         return node.kind === 17;
8198     }
8199     ts.isTemplateTail = isTemplateTail;
8200     function isIdentifier(node) {
8201         return node.kind === 75;
8202     }
8203     ts.isIdentifier = isIdentifier;
8204     function isQualifiedName(node) {
8205         return node.kind === 153;
8206     }
8207     ts.isQualifiedName = isQualifiedName;
8208     function isComputedPropertyName(node) {
8209         return node.kind === 154;
8210     }
8211     ts.isComputedPropertyName = isComputedPropertyName;
8212     function isPrivateIdentifier(node) {
8213         return node.kind === 76;
8214     }
8215     ts.isPrivateIdentifier = isPrivateIdentifier;
8216     function isIdentifierOrPrivateIdentifier(node) {
8217         return node.kind === 75 || node.kind === 76;
8218     }
8219     ts.isIdentifierOrPrivateIdentifier = isIdentifierOrPrivateIdentifier;
8220     function isTypeParameterDeclaration(node) {
8221         return node.kind === 155;
8222     }
8223     ts.isTypeParameterDeclaration = isTypeParameterDeclaration;
8224     function isParameter(node) {
8225         return node.kind === 156;
8226     }
8227     ts.isParameter = isParameter;
8228     function isDecorator(node) {
8229         return node.kind === 157;
8230     }
8231     ts.isDecorator = isDecorator;
8232     function isPropertySignature(node) {
8233         return node.kind === 158;
8234     }
8235     ts.isPropertySignature = isPropertySignature;
8236     function isPropertyDeclaration(node) {
8237         return node.kind === 159;
8238     }
8239     ts.isPropertyDeclaration = isPropertyDeclaration;
8240     function isMethodSignature(node) {
8241         return node.kind === 160;
8242     }
8243     ts.isMethodSignature = isMethodSignature;
8244     function isMethodDeclaration(node) {
8245         return node.kind === 161;
8246     }
8247     ts.isMethodDeclaration = isMethodDeclaration;
8248     function isConstructorDeclaration(node) {
8249         return node.kind === 162;
8250     }
8251     ts.isConstructorDeclaration = isConstructorDeclaration;
8252     function isGetAccessorDeclaration(node) {
8253         return node.kind === 163;
8254     }
8255     ts.isGetAccessorDeclaration = isGetAccessorDeclaration;
8256     function isSetAccessorDeclaration(node) {
8257         return node.kind === 164;
8258     }
8259     ts.isSetAccessorDeclaration = isSetAccessorDeclaration;
8260     function isCallSignatureDeclaration(node) {
8261         return node.kind === 165;
8262     }
8263     ts.isCallSignatureDeclaration = isCallSignatureDeclaration;
8264     function isConstructSignatureDeclaration(node) {
8265         return node.kind === 166;
8266     }
8267     ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration;
8268     function isIndexSignatureDeclaration(node) {
8269         return node.kind === 167;
8270     }
8271     ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration;
8272     function isGetOrSetAccessorDeclaration(node) {
8273         return node.kind === 164 || node.kind === 163;
8274     }
8275     ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration;
8276     function isTypePredicateNode(node) {
8277         return node.kind === 168;
8278     }
8279     ts.isTypePredicateNode = isTypePredicateNode;
8280     function isTypeReferenceNode(node) {
8281         return node.kind === 169;
8282     }
8283     ts.isTypeReferenceNode = isTypeReferenceNode;
8284     function isFunctionTypeNode(node) {
8285         return node.kind === 170;
8286     }
8287     ts.isFunctionTypeNode = isFunctionTypeNode;
8288     function isConstructorTypeNode(node) {
8289         return node.kind === 171;
8290     }
8291     ts.isConstructorTypeNode = isConstructorTypeNode;
8292     function isTypeQueryNode(node) {
8293         return node.kind === 172;
8294     }
8295     ts.isTypeQueryNode = isTypeQueryNode;
8296     function isTypeLiteralNode(node) {
8297         return node.kind === 173;
8298     }
8299     ts.isTypeLiteralNode = isTypeLiteralNode;
8300     function isArrayTypeNode(node) {
8301         return node.kind === 174;
8302     }
8303     ts.isArrayTypeNode = isArrayTypeNode;
8304     function isTupleTypeNode(node) {
8305         return node.kind === 175;
8306     }
8307     ts.isTupleTypeNode = isTupleTypeNode;
8308     function isUnionTypeNode(node) {
8309         return node.kind === 178;
8310     }
8311     ts.isUnionTypeNode = isUnionTypeNode;
8312     function isIntersectionTypeNode(node) {
8313         return node.kind === 179;
8314     }
8315     ts.isIntersectionTypeNode = isIntersectionTypeNode;
8316     function isConditionalTypeNode(node) {
8317         return node.kind === 180;
8318     }
8319     ts.isConditionalTypeNode = isConditionalTypeNode;
8320     function isInferTypeNode(node) {
8321         return node.kind === 181;
8322     }
8323     ts.isInferTypeNode = isInferTypeNode;
8324     function isParenthesizedTypeNode(node) {
8325         return node.kind === 182;
8326     }
8327     ts.isParenthesizedTypeNode = isParenthesizedTypeNode;
8328     function isThisTypeNode(node) {
8329         return node.kind === 183;
8330     }
8331     ts.isThisTypeNode = isThisTypeNode;
8332     function isTypeOperatorNode(node) {
8333         return node.kind === 184;
8334     }
8335     ts.isTypeOperatorNode = isTypeOperatorNode;
8336     function isIndexedAccessTypeNode(node) {
8337         return node.kind === 185;
8338     }
8339     ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode;
8340     function isMappedTypeNode(node) {
8341         return node.kind === 186;
8342     }
8343     ts.isMappedTypeNode = isMappedTypeNode;
8344     function isLiteralTypeNode(node) {
8345         return node.kind === 187;
8346     }
8347     ts.isLiteralTypeNode = isLiteralTypeNode;
8348     function isImportTypeNode(node) {
8349         return node.kind === 188;
8350     }
8351     ts.isImportTypeNode = isImportTypeNode;
8352     function isObjectBindingPattern(node) {
8353         return node.kind === 189;
8354     }
8355     ts.isObjectBindingPattern = isObjectBindingPattern;
8356     function isArrayBindingPattern(node) {
8357         return node.kind === 190;
8358     }
8359     ts.isArrayBindingPattern = isArrayBindingPattern;
8360     function isBindingElement(node) {
8361         return node.kind === 191;
8362     }
8363     ts.isBindingElement = isBindingElement;
8364     function isArrayLiteralExpression(node) {
8365         return node.kind === 192;
8366     }
8367     ts.isArrayLiteralExpression = isArrayLiteralExpression;
8368     function isObjectLiteralExpression(node) {
8369         return node.kind === 193;
8370     }
8371     ts.isObjectLiteralExpression = isObjectLiteralExpression;
8372     function isPropertyAccessExpression(node) {
8373         return node.kind === 194;
8374     }
8375     ts.isPropertyAccessExpression = isPropertyAccessExpression;
8376     function isPropertyAccessChain(node) {
8377         return isPropertyAccessExpression(node) && !!(node.flags & 32);
8378     }
8379     ts.isPropertyAccessChain = isPropertyAccessChain;
8380     function isElementAccessExpression(node) {
8381         return node.kind === 195;
8382     }
8383     ts.isElementAccessExpression = isElementAccessExpression;
8384     function isElementAccessChain(node) {
8385         return isElementAccessExpression(node) && !!(node.flags & 32);
8386     }
8387     ts.isElementAccessChain = isElementAccessChain;
8388     function isCallExpression(node) {
8389         return node.kind === 196;
8390     }
8391     ts.isCallExpression = isCallExpression;
8392     function isCallChain(node) {
8393         return isCallExpression(node) && !!(node.flags & 32);
8394     }
8395     ts.isCallChain = isCallChain;
8396     function isOptionalChain(node) {
8397         var kind = node.kind;
8398         return !!(node.flags & 32) &&
8399             (kind === 194
8400                 || kind === 195
8401                 || kind === 196
8402                 || kind === 218);
8403     }
8404     ts.isOptionalChain = isOptionalChain;
8405     function isOptionalChainRoot(node) {
8406         return isOptionalChain(node) && !isNonNullExpression(node) && !!node.questionDotToken;
8407     }
8408     ts.isOptionalChainRoot = isOptionalChainRoot;
8409     function isExpressionOfOptionalChainRoot(node) {
8410         return isOptionalChainRoot(node.parent) && node.parent.expression === node;
8411     }
8412     ts.isExpressionOfOptionalChainRoot = isExpressionOfOptionalChainRoot;
8413     function isOutermostOptionalChain(node) {
8414         return !isOptionalChain(node.parent)
8415             || isOptionalChainRoot(node.parent)
8416             || node !== node.parent.expression;
8417     }
8418     ts.isOutermostOptionalChain = isOutermostOptionalChain;
8419     function isNullishCoalesce(node) {
8420         return node.kind === 209 && node.operatorToken.kind === 60;
8421     }
8422     ts.isNullishCoalesce = isNullishCoalesce;
8423     function isNewExpression(node) {
8424         return node.kind === 197;
8425     }
8426     ts.isNewExpression = isNewExpression;
8427     function isTaggedTemplateExpression(node) {
8428         return node.kind === 198;
8429     }
8430     ts.isTaggedTemplateExpression = isTaggedTemplateExpression;
8431     function isTypeAssertion(node) {
8432         return node.kind === 199;
8433     }
8434     ts.isTypeAssertion = isTypeAssertion;
8435     function isConstTypeReference(node) {
8436         return isTypeReferenceNode(node) && isIdentifier(node.typeName) &&
8437             node.typeName.escapedText === "const" && !node.typeArguments;
8438     }
8439     ts.isConstTypeReference = isConstTypeReference;
8440     function isParenthesizedExpression(node) {
8441         return node.kind === 200;
8442     }
8443     ts.isParenthesizedExpression = isParenthesizedExpression;
8444     function skipPartiallyEmittedExpressions(node) {
8445         return ts.skipOuterExpressions(node, 8);
8446     }
8447     ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions;
8448     function isFunctionExpression(node) {
8449         return node.kind === 201;
8450     }
8451     ts.isFunctionExpression = isFunctionExpression;
8452     function isArrowFunction(node) {
8453         return node.kind === 202;
8454     }
8455     ts.isArrowFunction = isArrowFunction;
8456     function isDeleteExpression(node) {
8457         return node.kind === 203;
8458     }
8459     ts.isDeleteExpression = isDeleteExpression;
8460     function isTypeOfExpression(node) {
8461         return node.kind === 204;
8462     }
8463     ts.isTypeOfExpression = isTypeOfExpression;
8464     function isVoidExpression(node) {
8465         return node.kind === 205;
8466     }
8467     ts.isVoidExpression = isVoidExpression;
8468     function isAwaitExpression(node) {
8469         return node.kind === 206;
8470     }
8471     ts.isAwaitExpression = isAwaitExpression;
8472     function isPrefixUnaryExpression(node) {
8473         return node.kind === 207;
8474     }
8475     ts.isPrefixUnaryExpression = isPrefixUnaryExpression;
8476     function isPostfixUnaryExpression(node) {
8477         return node.kind === 208;
8478     }
8479     ts.isPostfixUnaryExpression = isPostfixUnaryExpression;
8480     function isBinaryExpression(node) {
8481         return node.kind === 209;
8482     }
8483     ts.isBinaryExpression = isBinaryExpression;
8484     function isConditionalExpression(node) {
8485         return node.kind === 210;
8486     }
8487     ts.isConditionalExpression = isConditionalExpression;
8488     function isTemplateExpression(node) {
8489         return node.kind === 211;
8490     }
8491     ts.isTemplateExpression = isTemplateExpression;
8492     function isYieldExpression(node) {
8493         return node.kind === 212;
8494     }
8495     ts.isYieldExpression = isYieldExpression;
8496     function isSpreadElement(node) {
8497         return node.kind === 213;
8498     }
8499     ts.isSpreadElement = isSpreadElement;
8500     function isClassExpression(node) {
8501         return node.kind === 214;
8502     }
8503     ts.isClassExpression = isClassExpression;
8504     function isOmittedExpression(node) {
8505         return node.kind === 215;
8506     }
8507     ts.isOmittedExpression = isOmittedExpression;
8508     function isExpressionWithTypeArguments(node) {
8509         return node.kind === 216;
8510     }
8511     ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments;
8512     function isAsExpression(node) {
8513         return node.kind === 217;
8514     }
8515     ts.isAsExpression = isAsExpression;
8516     function isNonNullExpression(node) {
8517         return node.kind === 218;
8518     }
8519     ts.isNonNullExpression = isNonNullExpression;
8520     function isNonNullChain(node) {
8521         return isNonNullExpression(node) && !!(node.flags & 32);
8522     }
8523     ts.isNonNullChain = isNonNullChain;
8524     function isMetaProperty(node) {
8525         return node.kind === 219;
8526     }
8527     ts.isMetaProperty = isMetaProperty;
8528     function isTemplateSpan(node) {
8529         return node.kind === 221;
8530     }
8531     ts.isTemplateSpan = isTemplateSpan;
8532     function isSemicolonClassElement(node) {
8533         return node.kind === 222;
8534     }
8535     ts.isSemicolonClassElement = isSemicolonClassElement;
8536     function isBlock(node) {
8537         return node.kind === 223;
8538     }
8539     ts.isBlock = isBlock;
8540     function isVariableStatement(node) {
8541         return node.kind === 225;
8542     }
8543     ts.isVariableStatement = isVariableStatement;
8544     function isEmptyStatement(node) {
8545         return node.kind === 224;
8546     }
8547     ts.isEmptyStatement = isEmptyStatement;
8548     function isExpressionStatement(node) {
8549         return node.kind === 226;
8550     }
8551     ts.isExpressionStatement = isExpressionStatement;
8552     function isIfStatement(node) {
8553         return node.kind === 227;
8554     }
8555     ts.isIfStatement = isIfStatement;
8556     function isDoStatement(node) {
8557         return node.kind === 228;
8558     }
8559     ts.isDoStatement = isDoStatement;
8560     function isWhileStatement(node) {
8561         return node.kind === 229;
8562     }
8563     ts.isWhileStatement = isWhileStatement;
8564     function isForStatement(node) {
8565         return node.kind === 230;
8566     }
8567     ts.isForStatement = isForStatement;
8568     function isForInStatement(node) {
8569         return node.kind === 231;
8570     }
8571     ts.isForInStatement = isForInStatement;
8572     function isForOfStatement(node) {
8573         return node.kind === 232;
8574     }
8575     ts.isForOfStatement = isForOfStatement;
8576     function isContinueStatement(node) {
8577         return node.kind === 233;
8578     }
8579     ts.isContinueStatement = isContinueStatement;
8580     function isBreakStatement(node) {
8581         return node.kind === 234;
8582     }
8583     ts.isBreakStatement = isBreakStatement;
8584     function isBreakOrContinueStatement(node) {
8585         return node.kind === 234 || node.kind === 233;
8586     }
8587     ts.isBreakOrContinueStatement = isBreakOrContinueStatement;
8588     function isReturnStatement(node) {
8589         return node.kind === 235;
8590     }
8591     ts.isReturnStatement = isReturnStatement;
8592     function isWithStatement(node) {
8593         return node.kind === 236;
8594     }
8595     ts.isWithStatement = isWithStatement;
8596     function isSwitchStatement(node) {
8597         return node.kind === 237;
8598     }
8599     ts.isSwitchStatement = isSwitchStatement;
8600     function isLabeledStatement(node) {
8601         return node.kind === 238;
8602     }
8603     ts.isLabeledStatement = isLabeledStatement;
8604     function isThrowStatement(node) {
8605         return node.kind === 239;
8606     }
8607     ts.isThrowStatement = isThrowStatement;
8608     function isTryStatement(node) {
8609         return node.kind === 240;
8610     }
8611     ts.isTryStatement = isTryStatement;
8612     function isDebuggerStatement(node) {
8613         return node.kind === 241;
8614     }
8615     ts.isDebuggerStatement = isDebuggerStatement;
8616     function isVariableDeclaration(node) {
8617         return node.kind === 242;
8618     }
8619     ts.isVariableDeclaration = isVariableDeclaration;
8620     function isVariableDeclarationList(node) {
8621         return node.kind === 243;
8622     }
8623     ts.isVariableDeclarationList = isVariableDeclarationList;
8624     function isFunctionDeclaration(node) {
8625         return node.kind === 244;
8626     }
8627     ts.isFunctionDeclaration = isFunctionDeclaration;
8628     function isClassDeclaration(node) {
8629         return node.kind === 245;
8630     }
8631     ts.isClassDeclaration = isClassDeclaration;
8632     function isInterfaceDeclaration(node) {
8633         return node.kind === 246;
8634     }
8635     ts.isInterfaceDeclaration = isInterfaceDeclaration;
8636     function isTypeAliasDeclaration(node) {
8637         return node.kind === 247;
8638     }
8639     ts.isTypeAliasDeclaration = isTypeAliasDeclaration;
8640     function isEnumDeclaration(node) {
8641         return node.kind === 248;
8642     }
8643     ts.isEnumDeclaration = isEnumDeclaration;
8644     function isModuleDeclaration(node) {
8645         return node.kind === 249;
8646     }
8647     ts.isModuleDeclaration = isModuleDeclaration;
8648     function isModuleBlock(node) {
8649         return node.kind === 250;
8650     }
8651     ts.isModuleBlock = isModuleBlock;
8652     function isCaseBlock(node) {
8653         return node.kind === 251;
8654     }
8655     ts.isCaseBlock = isCaseBlock;
8656     function isNamespaceExportDeclaration(node) {
8657         return node.kind === 252;
8658     }
8659     ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration;
8660     function isImportEqualsDeclaration(node) {
8661         return node.kind === 253;
8662     }
8663     ts.isImportEqualsDeclaration = isImportEqualsDeclaration;
8664     function isImportDeclaration(node) {
8665         return node.kind === 254;
8666     }
8667     ts.isImportDeclaration = isImportDeclaration;
8668     function isImportClause(node) {
8669         return node.kind === 255;
8670     }
8671     ts.isImportClause = isImportClause;
8672     function isNamespaceImport(node) {
8673         return node.kind === 256;
8674     }
8675     ts.isNamespaceImport = isNamespaceImport;
8676     function isNamespaceExport(node) {
8677         return node.kind === 262;
8678     }
8679     ts.isNamespaceExport = isNamespaceExport;
8680     function isNamedExportBindings(node) {
8681         return node.kind === 262 || node.kind === 261;
8682     }
8683     ts.isNamedExportBindings = isNamedExportBindings;
8684     function isNamedImports(node) {
8685         return node.kind === 257;
8686     }
8687     ts.isNamedImports = isNamedImports;
8688     function isImportSpecifier(node) {
8689         return node.kind === 258;
8690     }
8691     ts.isImportSpecifier = isImportSpecifier;
8692     function isExportAssignment(node) {
8693         return node.kind === 259;
8694     }
8695     ts.isExportAssignment = isExportAssignment;
8696     function isExportDeclaration(node) {
8697         return node.kind === 260;
8698     }
8699     ts.isExportDeclaration = isExportDeclaration;
8700     function isNamedExports(node) {
8701         return node.kind === 261;
8702     }
8703     ts.isNamedExports = isNamedExports;
8704     function isExportSpecifier(node) {
8705         return node.kind === 263;
8706     }
8707     ts.isExportSpecifier = isExportSpecifier;
8708     function isMissingDeclaration(node) {
8709         return node.kind === 264;
8710     }
8711     ts.isMissingDeclaration = isMissingDeclaration;
8712     function isExternalModuleReference(node) {
8713         return node.kind === 265;
8714     }
8715     ts.isExternalModuleReference = isExternalModuleReference;
8716     function isJsxElement(node) {
8717         return node.kind === 266;
8718     }
8719     ts.isJsxElement = isJsxElement;
8720     function isJsxSelfClosingElement(node) {
8721         return node.kind === 267;
8722     }
8723     ts.isJsxSelfClosingElement = isJsxSelfClosingElement;
8724     function isJsxOpeningElement(node) {
8725         return node.kind === 268;
8726     }
8727     ts.isJsxOpeningElement = isJsxOpeningElement;
8728     function isJsxClosingElement(node) {
8729         return node.kind === 269;
8730     }
8731     ts.isJsxClosingElement = isJsxClosingElement;
8732     function isJsxFragment(node) {
8733         return node.kind === 270;
8734     }
8735     ts.isJsxFragment = isJsxFragment;
8736     function isJsxOpeningFragment(node) {
8737         return node.kind === 271;
8738     }
8739     ts.isJsxOpeningFragment = isJsxOpeningFragment;
8740     function isJsxClosingFragment(node) {
8741         return node.kind === 272;
8742     }
8743     ts.isJsxClosingFragment = isJsxClosingFragment;
8744     function isJsxAttribute(node) {
8745         return node.kind === 273;
8746     }
8747     ts.isJsxAttribute = isJsxAttribute;
8748     function isJsxAttributes(node) {
8749         return node.kind === 274;
8750     }
8751     ts.isJsxAttributes = isJsxAttributes;
8752     function isJsxSpreadAttribute(node) {
8753         return node.kind === 275;
8754     }
8755     ts.isJsxSpreadAttribute = isJsxSpreadAttribute;
8756     function isJsxExpression(node) {
8757         return node.kind === 276;
8758     }
8759     ts.isJsxExpression = isJsxExpression;
8760     function isCaseClause(node) {
8761         return node.kind === 277;
8762     }
8763     ts.isCaseClause = isCaseClause;
8764     function isDefaultClause(node) {
8765         return node.kind === 278;
8766     }
8767     ts.isDefaultClause = isDefaultClause;
8768     function isHeritageClause(node) {
8769         return node.kind === 279;
8770     }
8771     ts.isHeritageClause = isHeritageClause;
8772     function isCatchClause(node) {
8773         return node.kind === 280;
8774     }
8775     ts.isCatchClause = isCatchClause;
8776     function isPropertyAssignment(node) {
8777         return node.kind === 281;
8778     }
8779     ts.isPropertyAssignment = isPropertyAssignment;
8780     function isShorthandPropertyAssignment(node) {
8781         return node.kind === 282;
8782     }
8783     ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment;
8784     function isSpreadAssignment(node) {
8785         return node.kind === 283;
8786     }
8787     ts.isSpreadAssignment = isSpreadAssignment;
8788     function isEnumMember(node) {
8789         return node.kind === 284;
8790     }
8791     ts.isEnumMember = isEnumMember;
8792     function isSourceFile(node) {
8793         return node.kind === 290;
8794     }
8795     ts.isSourceFile = isSourceFile;
8796     function isBundle(node) {
8797         return node.kind === 291;
8798     }
8799     ts.isBundle = isBundle;
8800     function isUnparsedSource(node) {
8801         return node.kind === 292;
8802     }
8803     ts.isUnparsedSource = isUnparsedSource;
8804     function isUnparsedPrepend(node) {
8805         return node.kind === 286;
8806     }
8807     ts.isUnparsedPrepend = isUnparsedPrepend;
8808     function isUnparsedTextLike(node) {
8809         switch (node.kind) {
8810             case 287:
8811             case 288:
8812                 return true;
8813             default:
8814                 return false;
8815         }
8816     }
8817     ts.isUnparsedTextLike = isUnparsedTextLike;
8818     function isUnparsedNode(node) {
8819         return isUnparsedTextLike(node) ||
8820             node.kind === 285 ||
8821             node.kind === 289;
8822     }
8823     ts.isUnparsedNode = isUnparsedNode;
8824     function isJSDocTypeExpression(node) {
8825         return node.kind === 294;
8826     }
8827     ts.isJSDocTypeExpression = isJSDocTypeExpression;
8828     function isJSDocAllType(node) {
8829         return node.kind === 295;
8830     }
8831     ts.isJSDocAllType = isJSDocAllType;
8832     function isJSDocUnknownType(node) {
8833         return node.kind === 296;
8834     }
8835     ts.isJSDocUnknownType = isJSDocUnknownType;
8836     function isJSDocNullableType(node) {
8837         return node.kind === 297;
8838     }
8839     ts.isJSDocNullableType = isJSDocNullableType;
8840     function isJSDocNonNullableType(node) {
8841         return node.kind === 298;
8842     }
8843     ts.isJSDocNonNullableType = isJSDocNonNullableType;
8844     function isJSDocOptionalType(node) {
8845         return node.kind === 299;
8846     }
8847     ts.isJSDocOptionalType = isJSDocOptionalType;
8848     function isJSDocFunctionType(node) {
8849         return node.kind === 300;
8850     }
8851     ts.isJSDocFunctionType = isJSDocFunctionType;
8852     function isJSDocVariadicType(node) {
8853         return node.kind === 301;
8854     }
8855     ts.isJSDocVariadicType = isJSDocVariadicType;
8856     function isJSDoc(node) {
8857         return node.kind === 303;
8858     }
8859     ts.isJSDoc = isJSDoc;
8860     function isJSDocAuthorTag(node) {
8861         return node.kind === 309;
8862     }
8863     ts.isJSDocAuthorTag = isJSDocAuthorTag;
8864     function isJSDocAugmentsTag(node) {
8865         return node.kind === 307;
8866     }
8867     ts.isJSDocAugmentsTag = isJSDocAugmentsTag;
8868     function isJSDocImplementsTag(node) {
8869         return node.kind === 308;
8870     }
8871     ts.isJSDocImplementsTag = isJSDocImplementsTag;
8872     function isJSDocClassTag(node) {
8873         return node.kind === 310;
8874     }
8875     ts.isJSDocClassTag = isJSDocClassTag;
8876     function isJSDocPublicTag(node) {
8877         return node.kind === 311;
8878     }
8879     ts.isJSDocPublicTag = isJSDocPublicTag;
8880     function isJSDocPrivateTag(node) {
8881         return node.kind === 312;
8882     }
8883     ts.isJSDocPrivateTag = isJSDocPrivateTag;
8884     function isJSDocProtectedTag(node) {
8885         return node.kind === 313;
8886     }
8887     ts.isJSDocProtectedTag = isJSDocProtectedTag;
8888     function isJSDocReadonlyTag(node) {
8889         return node.kind === 314;
8890     }
8891     ts.isJSDocReadonlyTag = isJSDocReadonlyTag;
8892     function isJSDocEnumTag(node) {
8893         return node.kind === 316;
8894     }
8895     ts.isJSDocEnumTag = isJSDocEnumTag;
8896     function isJSDocThisTag(node) {
8897         return node.kind === 319;
8898     }
8899     ts.isJSDocThisTag = isJSDocThisTag;
8900     function isJSDocParameterTag(node) {
8901         return node.kind === 317;
8902     }
8903     ts.isJSDocParameterTag = isJSDocParameterTag;
8904     function isJSDocReturnTag(node) {
8905         return node.kind === 318;
8906     }
8907     ts.isJSDocReturnTag = isJSDocReturnTag;
8908     function isJSDocTypeTag(node) {
8909         return node.kind === 320;
8910     }
8911     ts.isJSDocTypeTag = isJSDocTypeTag;
8912     function isJSDocTemplateTag(node) {
8913         return node.kind === 321;
8914     }
8915     ts.isJSDocTemplateTag = isJSDocTemplateTag;
8916     function isJSDocTypedefTag(node) {
8917         return node.kind === 322;
8918     }
8919     ts.isJSDocTypedefTag = isJSDocTypedefTag;
8920     function isJSDocPropertyTag(node) {
8921         return node.kind === 323;
8922     }
8923     ts.isJSDocPropertyTag = isJSDocPropertyTag;
8924     function isJSDocPropertyLikeTag(node) {
8925         return node.kind === 323 || node.kind === 317;
8926     }
8927     ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag;
8928     function isJSDocTypeLiteral(node) {
8929         return node.kind === 304;
8930     }
8931     ts.isJSDocTypeLiteral = isJSDocTypeLiteral;
8932     function isJSDocCallbackTag(node) {
8933         return node.kind === 315;
8934     }
8935     ts.isJSDocCallbackTag = isJSDocCallbackTag;
8936     function isJSDocSignature(node) {
8937         return node.kind === 305;
8938     }
8939     ts.isJSDocSignature = isJSDocSignature;
8940     function isSyntaxList(n) {
8941         return n.kind === 324;
8942     }
8943     ts.isSyntaxList = isSyntaxList;
8944     function isNode(node) {
8945         return isNodeKind(node.kind);
8946     }
8947     ts.isNode = isNode;
8948     function isNodeKind(kind) {
8949         return kind >= 153;
8950     }
8951     ts.isNodeKind = isNodeKind;
8952     function isToken(n) {
8953         return n.kind >= 0 && n.kind <= 152;
8954     }
8955     ts.isToken = isToken;
8956     function isNodeArray(array) {
8957         return array.hasOwnProperty("pos") && array.hasOwnProperty("end");
8958     }
8959     ts.isNodeArray = isNodeArray;
8960     function isLiteralKind(kind) {
8961         return 8 <= kind && kind <= 14;
8962     }
8963     ts.isLiteralKind = isLiteralKind;
8964     function isLiteralExpression(node) {
8965         return isLiteralKind(node.kind);
8966     }
8967     ts.isLiteralExpression = isLiteralExpression;
8968     function isTemplateLiteralKind(kind) {
8969         return 14 <= kind && kind <= 17;
8970     }
8971     ts.isTemplateLiteralKind = isTemplateLiteralKind;
8972     function isTemplateLiteralToken(node) {
8973         return isTemplateLiteralKind(node.kind);
8974     }
8975     ts.isTemplateLiteralToken = isTemplateLiteralToken;
8976     function isTemplateMiddleOrTemplateTail(node) {
8977         var kind = node.kind;
8978         return kind === 16
8979             || kind === 17;
8980     }
8981     ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail;
8982     function isImportOrExportSpecifier(node) {
8983         return isImportSpecifier(node) || isExportSpecifier(node);
8984     }
8985     ts.isImportOrExportSpecifier = isImportOrExportSpecifier;
8986     function isTypeOnlyImportOrExportDeclaration(node) {
8987         switch (node.kind) {
8988             case 258:
8989             case 263:
8990                 return node.parent.parent.isTypeOnly;
8991             case 256:
8992                 return node.parent.isTypeOnly;
8993             case 255:
8994                 return node.isTypeOnly;
8995             default:
8996                 return false;
8997         }
8998     }
8999     ts.isTypeOnlyImportOrExportDeclaration = isTypeOnlyImportOrExportDeclaration;
9000     function isStringTextContainingNode(node) {
9001         return node.kind === 10 || isTemplateLiteralKind(node.kind);
9002     }
9003     ts.isStringTextContainingNode = isStringTextContainingNode;
9004     function isGeneratedIdentifier(node) {
9005         return isIdentifier(node) && (node.autoGenerateFlags & 7) > 0;
9006     }
9007     ts.isGeneratedIdentifier = isGeneratedIdentifier;
9008     function isPrivateIdentifierPropertyDeclaration(node) {
9009         return isPropertyDeclaration(node) && isPrivateIdentifier(node.name);
9010     }
9011     ts.isPrivateIdentifierPropertyDeclaration = isPrivateIdentifierPropertyDeclaration;
9012     function isPrivateIdentifierPropertyAccessExpression(node) {
9013         return isPropertyAccessExpression(node) && isPrivateIdentifier(node.name);
9014     }
9015     ts.isPrivateIdentifierPropertyAccessExpression = isPrivateIdentifierPropertyAccessExpression;
9016     function isModifierKind(token) {
9017         switch (token) {
9018             case 122:
9019             case 126:
9020             case 81:
9021             case 130:
9022             case 84:
9023             case 89:
9024             case 119:
9025             case 117:
9026             case 118:
9027             case 138:
9028             case 120:
9029                 return true;
9030         }
9031         return false;
9032     }
9033     ts.isModifierKind = isModifierKind;
9034     function isParameterPropertyModifier(kind) {
9035         return !!(ts.modifierToFlag(kind) & 92);
9036     }
9037     ts.isParameterPropertyModifier = isParameterPropertyModifier;
9038     function isClassMemberModifier(idToken) {
9039         return isParameterPropertyModifier(idToken) || idToken === 120;
9040     }
9041     ts.isClassMemberModifier = isClassMemberModifier;
9042     function isModifier(node) {
9043         return isModifierKind(node.kind);
9044     }
9045     ts.isModifier = isModifier;
9046     function isEntityName(node) {
9047         var kind = node.kind;
9048         return kind === 153
9049             || kind === 75;
9050     }
9051     ts.isEntityName = isEntityName;
9052     function isPropertyName(node) {
9053         var kind = node.kind;
9054         return kind === 75
9055             || kind === 76
9056             || kind === 10
9057             || kind === 8
9058             || kind === 154;
9059     }
9060     ts.isPropertyName = isPropertyName;
9061     function isBindingName(node) {
9062         var kind = node.kind;
9063         return kind === 75
9064             || kind === 189
9065             || kind === 190;
9066     }
9067     ts.isBindingName = isBindingName;
9068     function isFunctionLike(node) {
9069         return node && isFunctionLikeKind(node.kind);
9070     }
9071     ts.isFunctionLike = isFunctionLike;
9072     function isFunctionLikeDeclaration(node) {
9073         return node && isFunctionLikeDeclarationKind(node.kind);
9074     }
9075     ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration;
9076     function isFunctionLikeDeclarationKind(kind) {
9077         switch (kind) {
9078             case 244:
9079             case 161:
9080             case 162:
9081             case 163:
9082             case 164:
9083             case 201:
9084             case 202:
9085                 return true;
9086             default:
9087                 return false;
9088         }
9089     }
9090     function isFunctionLikeKind(kind) {
9091         switch (kind) {
9092             case 160:
9093             case 165:
9094             case 305:
9095             case 166:
9096             case 167:
9097             case 170:
9098             case 300:
9099             case 171:
9100                 return true;
9101             default:
9102                 return isFunctionLikeDeclarationKind(kind);
9103         }
9104     }
9105     ts.isFunctionLikeKind = isFunctionLikeKind;
9106     function isFunctionOrModuleBlock(node) {
9107         return isSourceFile(node) || isModuleBlock(node) || isBlock(node) && isFunctionLike(node.parent);
9108     }
9109     ts.isFunctionOrModuleBlock = isFunctionOrModuleBlock;
9110     function isClassElement(node) {
9111         var kind = node.kind;
9112         return kind === 162
9113             || kind === 159
9114             || kind === 161
9115             || kind === 163
9116             || kind === 164
9117             || kind === 167
9118             || kind === 222;
9119     }
9120     ts.isClassElement = isClassElement;
9121     function isClassLike(node) {
9122         return node && (node.kind === 245 || node.kind === 214);
9123     }
9124     ts.isClassLike = isClassLike;
9125     function isAccessor(node) {
9126         return node && (node.kind === 163 || node.kind === 164);
9127     }
9128     ts.isAccessor = isAccessor;
9129     function isMethodOrAccessor(node) {
9130         switch (node.kind) {
9131             case 161:
9132             case 163:
9133             case 164:
9134                 return true;
9135             default:
9136                 return false;
9137         }
9138     }
9139     ts.isMethodOrAccessor = isMethodOrAccessor;
9140     function isTypeElement(node) {
9141         var kind = node.kind;
9142         return kind === 166
9143             || kind === 165
9144             || kind === 158
9145             || kind === 160
9146             || kind === 167;
9147     }
9148     ts.isTypeElement = isTypeElement;
9149     function isClassOrTypeElement(node) {
9150         return isTypeElement(node) || isClassElement(node);
9151     }
9152     ts.isClassOrTypeElement = isClassOrTypeElement;
9153     function isObjectLiteralElementLike(node) {
9154         var kind = node.kind;
9155         return kind === 281
9156             || kind === 282
9157             || kind === 283
9158             || kind === 161
9159             || kind === 163
9160             || kind === 164;
9161     }
9162     ts.isObjectLiteralElementLike = isObjectLiteralElementLike;
9163     function isTypeNode(node) {
9164         return ts.isTypeNodeKind(node.kind);
9165     }
9166     ts.isTypeNode = isTypeNode;
9167     function isFunctionOrConstructorTypeNode(node) {
9168         switch (node.kind) {
9169             case 170:
9170             case 171:
9171                 return true;
9172         }
9173         return false;
9174     }
9175     ts.isFunctionOrConstructorTypeNode = isFunctionOrConstructorTypeNode;
9176     function isBindingPattern(node) {
9177         if (node) {
9178             var kind = node.kind;
9179             return kind === 190
9180                 || kind === 189;
9181         }
9182         return false;
9183     }
9184     ts.isBindingPattern = isBindingPattern;
9185     function isAssignmentPattern(node) {
9186         var kind = node.kind;
9187         return kind === 192
9188             || kind === 193;
9189     }
9190     ts.isAssignmentPattern = isAssignmentPattern;
9191     function isArrayBindingElement(node) {
9192         var kind = node.kind;
9193         return kind === 191
9194             || kind === 215;
9195     }
9196     ts.isArrayBindingElement = isArrayBindingElement;
9197     function isDeclarationBindingElement(bindingElement) {
9198         switch (bindingElement.kind) {
9199             case 242:
9200             case 156:
9201             case 191:
9202                 return true;
9203         }
9204         return false;
9205     }
9206     ts.isDeclarationBindingElement = isDeclarationBindingElement;
9207     function isBindingOrAssignmentPattern(node) {
9208         return isObjectBindingOrAssignmentPattern(node)
9209             || isArrayBindingOrAssignmentPattern(node);
9210     }
9211     ts.isBindingOrAssignmentPattern = isBindingOrAssignmentPattern;
9212     function isObjectBindingOrAssignmentPattern(node) {
9213         switch (node.kind) {
9214             case 189:
9215             case 193:
9216                 return true;
9217         }
9218         return false;
9219     }
9220     ts.isObjectBindingOrAssignmentPattern = isObjectBindingOrAssignmentPattern;
9221     function isArrayBindingOrAssignmentPattern(node) {
9222         switch (node.kind) {
9223             case 190:
9224             case 192:
9225                 return true;
9226         }
9227         return false;
9228     }
9229     ts.isArrayBindingOrAssignmentPattern = isArrayBindingOrAssignmentPattern;
9230     function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) {
9231         var kind = node.kind;
9232         return kind === 194
9233             || kind === 153
9234             || kind === 188;
9235     }
9236     ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode;
9237     function isPropertyAccessOrQualifiedName(node) {
9238         var kind = node.kind;
9239         return kind === 194
9240             || kind === 153;
9241     }
9242     ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName;
9243     function isCallLikeExpression(node) {
9244         switch (node.kind) {
9245             case 268:
9246             case 267:
9247             case 196:
9248             case 197:
9249             case 198:
9250             case 157:
9251                 return true;
9252             default:
9253                 return false;
9254         }
9255     }
9256     ts.isCallLikeExpression = isCallLikeExpression;
9257     function isCallOrNewExpression(node) {
9258         return node.kind === 196 || node.kind === 197;
9259     }
9260     ts.isCallOrNewExpression = isCallOrNewExpression;
9261     function isTemplateLiteral(node) {
9262         var kind = node.kind;
9263         return kind === 211
9264             || kind === 14;
9265     }
9266     ts.isTemplateLiteral = isTemplateLiteral;
9267     function isLeftHandSideExpression(node) {
9268         return isLeftHandSideExpressionKind(skipPartiallyEmittedExpressions(node).kind);
9269     }
9270     ts.isLeftHandSideExpression = isLeftHandSideExpression;
9271     function isLeftHandSideExpressionKind(kind) {
9272         switch (kind) {
9273             case 194:
9274             case 195:
9275             case 197:
9276             case 196:
9277             case 266:
9278             case 267:
9279             case 270:
9280             case 198:
9281             case 192:
9282             case 200:
9283             case 193:
9284             case 214:
9285             case 201:
9286             case 75:
9287             case 13:
9288             case 8:
9289             case 9:
9290             case 10:
9291             case 14:
9292             case 211:
9293             case 91:
9294             case 100:
9295             case 104:
9296             case 106:
9297             case 102:
9298             case 218:
9299             case 219:
9300             case 96:
9301                 return true;
9302             default:
9303                 return false;
9304         }
9305     }
9306     function isUnaryExpression(node) {
9307         return isUnaryExpressionKind(skipPartiallyEmittedExpressions(node).kind);
9308     }
9309     ts.isUnaryExpression = isUnaryExpression;
9310     function isUnaryExpressionKind(kind) {
9311         switch (kind) {
9312             case 207:
9313             case 208:
9314             case 203:
9315             case 204:
9316             case 205:
9317             case 206:
9318             case 199:
9319                 return true;
9320             default:
9321                 return isLeftHandSideExpressionKind(kind);
9322         }
9323     }
9324     function isUnaryExpressionWithWrite(expr) {
9325         switch (expr.kind) {
9326             case 208:
9327                 return true;
9328             case 207:
9329                 return expr.operator === 45 ||
9330                     expr.operator === 46;
9331             default:
9332                 return false;
9333         }
9334     }
9335     ts.isUnaryExpressionWithWrite = isUnaryExpressionWithWrite;
9336     function isExpression(node) {
9337         return isExpressionKind(skipPartiallyEmittedExpressions(node).kind);
9338     }
9339     ts.isExpression = isExpression;
9340     function isExpressionKind(kind) {
9341         switch (kind) {
9342             case 210:
9343             case 212:
9344             case 202:
9345             case 209:
9346             case 213:
9347             case 217:
9348             case 215:
9349             case 327:
9350             case 326:
9351                 return true;
9352             default:
9353                 return isUnaryExpressionKind(kind);
9354         }
9355     }
9356     function isAssertionExpression(node) {
9357         var kind = node.kind;
9358         return kind === 199
9359             || kind === 217;
9360     }
9361     ts.isAssertionExpression = isAssertionExpression;
9362     function isPartiallyEmittedExpression(node) {
9363         return node.kind === 326;
9364     }
9365     ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression;
9366     function isNotEmittedStatement(node) {
9367         return node.kind === 325;
9368     }
9369     ts.isNotEmittedStatement = isNotEmittedStatement;
9370     function isSyntheticReference(node) {
9371         return node.kind === 330;
9372     }
9373     ts.isSyntheticReference = isSyntheticReference;
9374     function isNotEmittedOrPartiallyEmittedNode(node) {
9375         return isNotEmittedStatement(node)
9376             || isPartiallyEmittedExpression(node);
9377     }
9378     ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode;
9379     function isIterationStatement(node, lookInLabeledStatements) {
9380         switch (node.kind) {
9381             case 230:
9382             case 231:
9383             case 232:
9384             case 228:
9385             case 229:
9386                 return true;
9387             case 238:
9388                 return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements);
9389         }
9390         return false;
9391     }
9392     ts.isIterationStatement = isIterationStatement;
9393     function isScopeMarker(node) {
9394         return isExportAssignment(node) || isExportDeclaration(node);
9395     }
9396     ts.isScopeMarker = isScopeMarker;
9397     function hasScopeMarker(statements) {
9398         return ts.some(statements, isScopeMarker);
9399     }
9400     ts.hasScopeMarker = hasScopeMarker;
9401     function needsScopeMarker(result) {
9402         return !ts.isAnyImportOrReExport(result) && !isExportAssignment(result) && !ts.hasModifier(result, 1) && !ts.isAmbientModule(result);
9403     }
9404     ts.needsScopeMarker = needsScopeMarker;
9405     function isExternalModuleIndicator(result) {
9406         return ts.isAnyImportOrReExport(result) || isExportAssignment(result) || ts.hasModifier(result, 1);
9407     }
9408     ts.isExternalModuleIndicator = isExternalModuleIndicator;
9409     function isForInOrOfStatement(node) {
9410         return node.kind === 231 || node.kind === 232;
9411     }
9412     ts.isForInOrOfStatement = isForInOrOfStatement;
9413     function isConciseBody(node) {
9414         return isBlock(node)
9415             || isExpression(node);
9416     }
9417     ts.isConciseBody = isConciseBody;
9418     function isFunctionBody(node) {
9419         return isBlock(node);
9420     }
9421     ts.isFunctionBody = isFunctionBody;
9422     function isForInitializer(node) {
9423         return isVariableDeclarationList(node)
9424             || isExpression(node);
9425     }
9426     ts.isForInitializer = isForInitializer;
9427     function isModuleBody(node) {
9428         var kind = node.kind;
9429         return kind === 250
9430             || kind === 249
9431             || kind === 75;
9432     }
9433     ts.isModuleBody = isModuleBody;
9434     function isNamespaceBody(node) {
9435         var kind = node.kind;
9436         return kind === 250
9437             || kind === 249;
9438     }
9439     ts.isNamespaceBody = isNamespaceBody;
9440     function isJSDocNamespaceBody(node) {
9441         var kind = node.kind;
9442         return kind === 75
9443             || kind === 249;
9444     }
9445     ts.isJSDocNamespaceBody = isJSDocNamespaceBody;
9446     function isNamedImportBindings(node) {
9447         var kind = node.kind;
9448         return kind === 257
9449             || kind === 256;
9450     }
9451     ts.isNamedImportBindings = isNamedImportBindings;
9452     function isModuleOrEnumDeclaration(node) {
9453         return node.kind === 249 || node.kind === 248;
9454     }
9455     ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration;
9456     function isDeclarationKind(kind) {
9457         return kind === 202
9458             || kind === 191
9459             || kind === 245
9460             || kind === 214
9461             || kind === 162
9462             || kind === 248
9463             || kind === 284
9464             || kind === 263
9465             || kind === 244
9466             || kind === 201
9467             || kind === 163
9468             || kind === 255
9469             || kind === 253
9470             || kind === 258
9471             || kind === 246
9472             || kind === 273
9473             || kind === 161
9474             || kind === 160
9475             || kind === 249
9476             || kind === 252
9477             || kind === 256
9478             || kind === 262
9479             || kind === 156
9480             || kind === 281
9481             || kind === 159
9482             || kind === 158
9483             || kind === 164
9484             || kind === 282
9485             || kind === 247
9486             || kind === 155
9487             || kind === 242
9488             || kind === 322
9489             || kind === 315
9490             || kind === 323;
9491     }
9492     function isDeclarationStatementKind(kind) {
9493         return kind === 244
9494             || kind === 264
9495             || kind === 245
9496             || kind === 246
9497             || kind === 247
9498             || kind === 248
9499             || kind === 249
9500             || kind === 254
9501             || kind === 253
9502             || kind === 260
9503             || kind === 259
9504             || kind === 252;
9505     }
9506     function isStatementKindButNotDeclarationKind(kind) {
9507         return kind === 234
9508             || kind === 233
9509             || kind === 241
9510             || kind === 228
9511             || kind === 226
9512             || kind === 224
9513             || kind === 231
9514             || kind === 232
9515             || kind === 230
9516             || kind === 227
9517             || kind === 238
9518             || kind === 235
9519             || kind === 237
9520             || kind === 239
9521             || kind === 240
9522             || kind === 225
9523             || kind === 229
9524             || kind === 236
9525             || kind === 325
9526             || kind === 329
9527             || kind === 328;
9528     }
9529     function isDeclaration(node) {
9530         if (node.kind === 155) {
9531             return (node.parent && node.parent.kind !== 321) || ts.isInJSFile(node);
9532         }
9533         return isDeclarationKind(node.kind);
9534     }
9535     ts.isDeclaration = isDeclaration;
9536     function isDeclarationStatement(node) {
9537         return isDeclarationStatementKind(node.kind);
9538     }
9539     ts.isDeclarationStatement = isDeclarationStatement;
9540     function isStatementButNotDeclaration(node) {
9541         return isStatementKindButNotDeclarationKind(node.kind);
9542     }
9543     ts.isStatementButNotDeclaration = isStatementButNotDeclaration;
9544     function isStatement(node) {
9545         var kind = node.kind;
9546         return isStatementKindButNotDeclarationKind(kind)
9547             || isDeclarationStatementKind(kind)
9548             || isBlockStatement(node);
9549     }
9550     ts.isStatement = isStatement;
9551     function isBlockStatement(node) {
9552         if (node.kind !== 223)
9553             return false;
9554         if (node.parent !== undefined) {
9555             if (node.parent.kind === 240 || node.parent.kind === 280) {
9556                 return false;
9557             }
9558         }
9559         return !ts.isFunctionBlock(node);
9560     }
9561     function isModuleReference(node) {
9562         var kind = node.kind;
9563         return kind === 265
9564             || kind === 153
9565             || kind === 75;
9566     }
9567     ts.isModuleReference = isModuleReference;
9568     function isJsxTagNameExpression(node) {
9569         var kind = node.kind;
9570         return kind === 104
9571             || kind === 75
9572             || kind === 194;
9573     }
9574     ts.isJsxTagNameExpression = isJsxTagNameExpression;
9575     function isJsxChild(node) {
9576         var kind = node.kind;
9577         return kind === 266
9578             || kind === 276
9579             || kind === 267
9580             || kind === 11
9581             || kind === 270;
9582     }
9583     ts.isJsxChild = isJsxChild;
9584     function isJsxAttributeLike(node) {
9585         var kind = node.kind;
9586         return kind === 273
9587             || kind === 275;
9588     }
9589     ts.isJsxAttributeLike = isJsxAttributeLike;
9590     function isStringLiteralOrJsxExpression(node) {
9591         var kind = node.kind;
9592         return kind === 10
9593             || kind === 276;
9594     }
9595     ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression;
9596     function isJsxOpeningLikeElement(node) {
9597         var kind = node.kind;
9598         return kind === 268
9599             || kind === 267;
9600     }
9601     ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement;
9602     function isCaseOrDefaultClause(node) {
9603         var kind = node.kind;
9604         return kind === 277
9605             || kind === 278;
9606     }
9607     ts.isCaseOrDefaultClause = isCaseOrDefaultClause;
9608     function isJSDocNode(node) {
9609         return node.kind >= 294 && node.kind <= 323;
9610     }
9611     ts.isJSDocNode = isJSDocNode;
9612     function isJSDocCommentContainingNode(node) {
9613         return node.kind === 303 || node.kind === 302 || isJSDocTag(node) || isJSDocTypeLiteral(node) || isJSDocSignature(node);
9614     }
9615     ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode;
9616     function isJSDocTag(node) {
9617         return node.kind >= 306 && node.kind <= 323;
9618     }
9619     ts.isJSDocTag = isJSDocTag;
9620     function isSetAccessor(node) {
9621         return node.kind === 164;
9622     }
9623     ts.isSetAccessor = isSetAccessor;
9624     function isGetAccessor(node) {
9625         return node.kind === 163;
9626     }
9627     ts.isGetAccessor = isGetAccessor;
9628     function hasJSDocNodes(node) {
9629         var jsDoc = node.jsDoc;
9630         return !!jsDoc && jsDoc.length > 0;
9631     }
9632     ts.hasJSDocNodes = hasJSDocNodes;
9633     function hasType(node) {
9634         return !!node.type;
9635     }
9636     ts.hasType = hasType;
9637     function hasInitializer(node) {
9638         return !!node.initializer;
9639     }
9640     ts.hasInitializer = hasInitializer;
9641     function hasOnlyExpressionInitializer(node) {
9642         switch (node.kind) {
9643             case 242:
9644             case 156:
9645             case 191:
9646             case 158:
9647             case 159:
9648             case 281:
9649             case 284:
9650                 return true;
9651             default:
9652                 return false;
9653         }
9654     }
9655     ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer;
9656     function isObjectLiteralElement(node) {
9657         return node.kind === 273 || node.kind === 275 || isObjectLiteralElementLike(node);
9658     }
9659     ts.isObjectLiteralElement = isObjectLiteralElement;
9660     function isTypeReferenceType(node) {
9661         return node.kind === 169 || node.kind === 216;
9662     }
9663     ts.isTypeReferenceType = isTypeReferenceType;
9664     var MAX_SMI_X86 = 1073741823;
9665     function guessIndentation(lines) {
9666         var indentation = MAX_SMI_X86;
9667         for (var _i = 0, lines_1 = lines; _i < lines_1.length; _i++) {
9668             var line = lines_1[_i];
9669             if (!line.length) {
9670                 continue;
9671             }
9672             var i = 0;
9673             for (; i < line.length && i < indentation; i++) {
9674                 if (!ts.isWhiteSpaceLike(line.charCodeAt(i))) {
9675                     break;
9676                 }
9677             }
9678             if (i < indentation) {
9679                 indentation = i;
9680             }
9681             if (indentation === 0) {
9682                 return 0;
9683             }
9684         }
9685         return indentation === MAX_SMI_X86 ? undefined : indentation;
9686     }
9687     ts.guessIndentation = guessIndentation;
9688     function isStringLiteralLike(node) {
9689         return node.kind === 10 || node.kind === 14;
9690     }
9691     ts.isStringLiteralLike = isStringLiteralLike;
9692 })(ts || (ts = {}));
9693 var ts;
9694 (function (ts) {
9695     ts.resolvingEmptyArray = [];
9696     ts.emptyMap = ts.createMap();
9697     ts.emptyUnderscoreEscapedMap = ts.emptyMap;
9698     ts.externalHelpersModuleNameText = "tslib";
9699     ts.defaultMaximumTruncationLength = 160;
9700     ts.noTruncationMaximumTruncationLength = 1000000;
9701     function getDeclarationOfKind(symbol, kind) {
9702         var declarations = symbol.declarations;
9703         if (declarations) {
9704             for (var _i = 0, declarations_1 = declarations; _i < declarations_1.length; _i++) {
9705                 var declaration = declarations_1[_i];
9706                 if (declaration.kind === kind) {
9707                     return declaration;
9708                 }
9709             }
9710         }
9711         return undefined;
9712     }
9713     ts.getDeclarationOfKind = getDeclarationOfKind;
9714     function createUnderscoreEscapedMap() {
9715         return new ts.Map();
9716     }
9717     ts.createUnderscoreEscapedMap = createUnderscoreEscapedMap;
9718     function hasEntries(map) {
9719         return !!map && !!map.size;
9720     }
9721     ts.hasEntries = hasEntries;
9722     function createSymbolTable(symbols) {
9723         var result = ts.createMap();
9724         if (symbols) {
9725             for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
9726                 var symbol = symbols_1[_i];
9727                 result.set(symbol.escapedName, symbol);
9728             }
9729         }
9730         return result;
9731     }
9732     ts.createSymbolTable = createSymbolTable;
9733     function isTransientSymbol(symbol) {
9734         return (symbol.flags & 33554432) !== 0;
9735     }
9736     ts.isTransientSymbol = isTransientSymbol;
9737     var stringWriter = createSingleLineStringWriter();
9738     function createSingleLineStringWriter() {
9739         var str = "";
9740         var writeText = function (text) { return str += text; };
9741         return {
9742             getText: function () { return str; },
9743             write: writeText,
9744             rawWrite: writeText,
9745             writeKeyword: writeText,
9746             writeOperator: writeText,
9747             writePunctuation: writeText,
9748             writeSpace: writeText,
9749             writeStringLiteral: writeText,
9750             writeLiteral: writeText,
9751             writeParameter: writeText,
9752             writeProperty: writeText,
9753             writeSymbol: function (s, _) { return writeText(s); },
9754             writeTrailingSemicolon: writeText,
9755             writeComment: writeText,
9756             getTextPos: function () { return str.length; },
9757             getLine: function () { return 0; },
9758             getColumn: function () { return 0; },
9759             getIndent: function () { return 0; },
9760             isAtStartOfLine: function () { return false; },
9761             hasTrailingComment: function () { return false; },
9762             hasTrailingWhitespace: function () { return !!str.length && ts.isWhiteSpaceLike(str.charCodeAt(str.length - 1)); },
9763             writeLine: function () { return str += " "; },
9764             increaseIndent: ts.noop,
9765             decreaseIndent: ts.noop,
9766             clear: function () { return str = ""; },
9767             trackSymbol: ts.noop,
9768             reportInaccessibleThisError: ts.noop,
9769             reportInaccessibleUniqueSymbolError: ts.noop,
9770             reportPrivateInBaseOfClassExpression: ts.noop,
9771         };
9772     }
9773     function changesAffectModuleResolution(oldOptions, newOptions) {
9774         return oldOptions.configFilePath !== newOptions.configFilePath ||
9775             optionsHaveModuleResolutionChanges(oldOptions, newOptions);
9776     }
9777     ts.changesAffectModuleResolution = changesAffectModuleResolution;
9778     function optionsHaveModuleResolutionChanges(oldOptions, newOptions) {
9779         return ts.moduleResolutionOptionDeclarations.some(function (o) {
9780             return !isJsonEqual(getCompilerOptionValue(oldOptions, o), getCompilerOptionValue(newOptions, o));
9781         });
9782     }
9783     ts.optionsHaveModuleResolutionChanges = optionsHaveModuleResolutionChanges;
9784     function findAncestor(node, callback) {
9785         while (node) {
9786             var result = callback(node);
9787             if (result === "quit") {
9788                 return undefined;
9789             }
9790             else if (result) {
9791                 return node;
9792             }
9793             node = node.parent;
9794         }
9795         return undefined;
9796     }
9797     ts.findAncestor = findAncestor;
9798     function forEachAncestor(node, callback) {
9799         while (true) {
9800             var res = callback(node);
9801             if (res === "quit")
9802                 return undefined;
9803             if (res !== undefined)
9804                 return res;
9805             if (ts.isSourceFile(node))
9806                 return undefined;
9807             node = node.parent;
9808         }
9809     }
9810     ts.forEachAncestor = forEachAncestor;
9811     function forEachEntry(map, callback) {
9812         var iterator = map.entries();
9813         for (var iterResult = iterator.next(); !iterResult.done; iterResult = iterator.next()) {
9814             var _a = iterResult.value, key = _a[0], value = _a[1];
9815             var result = callback(value, key);
9816             if (result) {
9817                 return result;
9818             }
9819         }
9820         return undefined;
9821     }
9822     ts.forEachEntry = forEachEntry;
9823     function forEachKey(map, callback) {
9824         var iterator = map.keys();
9825         for (var iterResult = iterator.next(); !iterResult.done; iterResult = iterator.next()) {
9826             var result = callback(iterResult.value);
9827             if (result) {
9828                 return result;
9829             }
9830         }
9831         return undefined;
9832     }
9833     ts.forEachKey = forEachKey;
9834     function copyEntries(source, target) {
9835         source.forEach(function (value, key) {
9836             target.set(key, value);
9837         });
9838     }
9839     ts.copyEntries = copyEntries;
9840     function arrayToSet(array, makeKey) {
9841         return ts.arrayToMap(array, makeKey || (function (s) { return s; }), ts.returnTrue);
9842     }
9843     ts.arrayToSet = arrayToSet;
9844     function cloneMap(map) {
9845         var clone = ts.createMap();
9846         copyEntries(map, clone);
9847         return clone;
9848     }
9849     ts.cloneMap = cloneMap;
9850     function usingSingleLineStringWriter(action) {
9851         var oldString = stringWriter.getText();
9852         try {
9853             action(stringWriter);
9854             return stringWriter.getText();
9855         }
9856         finally {
9857             stringWriter.clear();
9858             stringWriter.writeKeyword(oldString);
9859         }
9860     }
9861     ts.usingSingleLineStringWriter = usingSingleLineStringWriter;
9862     function getFullWidth(node) {
9863         return node.end - node.pos;
9864     }
9865     ts.getFullWidth = getFullWidth;
9866     function getResolvedModule(sourceFile, moduleNameText) {
9867         return sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText);
9868     }
9869     ts.getResolvedModule = getResolvedModule;
9870     function setResolvedModule(sourceFile, moduleNameText, resolvedModule) {
9871         if (!sourceFile.resolvedModules) {
9872             sourceFile.resolvedModules = ts.createMap();
9873         }
9874         sourceFile.resolvedModules.set(moduleNameText, resolvedModule);
9875     }
9876     ts.setResolvedModule = setResolvedModule;
9877     function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) {
9878         if (!sourceFile.resolvedTypeReferenceDirectiveNames) {
9879             sourceFile.resolvedTypeReferenceDirectiveNames = ts.createMap();
9880         }
9881         sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, resolvedTypeReferenceDirective);
9882     }
9883     ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective;
9884     function projectReferenceIsEqualTo(oldRef, newRef) {
9885         return oldRef.path === newRef.path &&
9886             !oldRef.prepend === !newRef.prepend &&
9887             !oldRef.circular === !newRef.circular;
9888     }
9889     ts.projectReferenceIsEqualTo = projectReferenceIsEqualTo;
9890     function moduleResolutionIsEqualTo(oldResolution, newResolution) {
9891         return oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport &&
9892             oldResolution.extension === newResolution.extension &&
9893             oldResolution.resolvedFileName === newResolution.resolvedFileName &&
9894             oldResolution.originalPath === newResolution.originalPath &&
9895             packageIdIsEqual(oldResolution.packageId, newResolution.packageId);
9896     }
9897     ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo;
9898     function packageIdIsEqual(a, b) {
9899         return a === b || !!a && !!b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version;
9900     }
9901     function packageIdToString(_a) {
9902         var name = _a.name, subModuleName = _a.subModuleName, version = _a.version;
9903         var fullName = subModuleName ? name + "/" + subModuleName : name;
9904         return fullName + "@" + version;
9905     }
9906     ts.packageIdToString = packageIdToString;
9907     function typeDirectiveIsEqualTo(oldResolution, newResolution) {
9908         return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary;
9909     }
9910     ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo;
9911     function hasChangesInResolutions(names, newResolutions, oldResolutions, comparer) {
9912         ts.Debug.assert(names.length === newResolutions.length);
9913         for (var i = 0; i < names.length; i++) {
9914             var newResolution = newResolutions[i];
9915             var oldResolution = oldResolutions && oldResolutions.get(names[i]);
9916             var changed = oldResolution
9917                 ? !newResolution || !comparer(oldResolution, newResolution)
9918                 : newResolution;
9919             if (changed) {
9920                 return true;
9921             }
9922         }
9923         return false;
9924     }
9925     ts.hasChangesInResolutions = hasChangesInResolutions;
9926     function containsParseError(node) {
9927         aggregateChildData(node);
9928         return (node.flags & 262144) !== 0;
9929     }
9930     ts.containsParseError = containsParseError;
9931     function aggregateChildData(node) {
9932         if (!(node.flags & 524288)) {
9933             var thisNodeOrAnySubNodesHasError = ((node.flags & 65536) !== 0) ||
9934                 ts.forEachChild(node, containsParseError);
9935             if (thisNodeOrAnySubNodesHasError) {
9936                 node.flags |= 262144;
9937             }
9938             node.flags |= 524288;
9939         }
9940     }
9941     function getSourceFileOfNode(node) {
9942         while (node && node.kind !== 290) {
9943             node = node.parent;
9944         }
9945         return node;
9946     }
9947     ts.getSourceFileOfNode = getSourceFileOfNode;
9948     function isStatementWithLocals(node) {
9949         switch (node.kind) {
9950             case 223:
9951             case 251:
9952             case 230:
9953             case 231:
9954             case 232:
9955                 return true;
9956         }
9957         return false;
9958     }
9959     ts.isStatementWithLocals = isStatementWithLocals;
9960     function getStartPositionOfLine(line, sourceFile) {
9961         ts.Debug.assert(line >= 0);
9962         return ts.getLineStarts(sourceFile)[line];
9963     }
9964     ts.getStartPositionOfLine = getStartPositionOfLine;
9965     function nodePosToString(node) {
9966         var file = getSourceFileOfNode(node);
9967         var loc = ts.getLineAndCharacterOfPosition(file, node.pos);
9968         return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")";
9969     }
9970     ts.nodePosToString = nodePosToString;
9971     function getEndLinePosition(line, sourceFile) {
9972         ts.Debug.assert(line >= 0);
9973         var lineStarts = ts.getLineStarts(sourceFile);
9974         var lineIndex = line;
9975         var sourceText = sourceFile.text;
9976         if (lineIndex + 1 === lineStarts.length) {
9977             return sourceText.length - 1;
9978         }
9979         else {
9980             var start = lineStarts[lineIndex];
9981             var pos = lineStarts[lineIndex + 1] - 1;
9982             ts.Debug.assert(ts.isLineBreak(sourceText.charCodeAt(pos)));
9983             while (start <= pos && ts.isLineBreak(sourceText.charCodeAt(pos))) {
9984                 pos--;
9985             }
9986             return pos;
9987         }
9988     }
9989     ts.getEndLinePosition = getEndLinePosition;
9990     function isFileLevelUniqueName(sourceFile, name, hasGlobalName) {
9991         return !(hasGlobalName && hasGlobalName(name)) && !sourceFile.identifiers.has(name);
9992     }
9993     ts.isFileLevelUniqueName = isFileLevelUniqueName;
9994     function nodeIsMissing(node) {
9995         if (node === undefined) {
9996             return true;
9997         }
9998         return node.pos === node.end && node.pos >= 0 && node.kind !== 1;
9999     }
10000     ts.nodeIsMissing = nodeIsMissing;
10001     function nodeIsPresent(node) {
10002         return !nodeIsMissing(node);
10003     }
10004     ts.nodeIsPresent = nodeIsPresent;
10005     function insertStatementsAfterPrologue(to, from, isPrologueDirective) {
10006         if (from === undefined || from.length === 0)
10007             return to;
10008         var statementIndex = 0;
10009         for (; statementIndex < to.length; ++statementIndex) {
10010             if (!isPrologueDirective(to[statementIndex])) {
10011                 break;
10012             }
10013         }
10014         to.splice.apply(to, __spreadArrays([statementIndex, 0], from));
10015         return to;
10016     }
10017     function insertStatementAfterPrologue(to, statement, isPrologueDirective) {
10018         if (statement === undefined)
10019             return to;
10020         var statementIndex = 0;
10021         for (; statementIndex < to.length; ++statementIndex) {
10022             if (!isPrologueDirective(to[statementIndex])) {
10023                 break;
10024             }
10025         }
10026         to.splice(statementIndex, 0, statement);
10027         return to;
10028     }
10029     function isAnyPrologueDirective(node) {
10030         return isPrologueDirective(node) || !!(getEmitFlags(node) & 1048576);
10031     }
10032     function insertStatementsAfterStandardPrologue(to, from) {
10033         return insertStatementsAfterPrologue(to, from, isPrologueDirective);
10034     }
10035     ts.insertStatementsAfterStandardPrologue = insertStatementsAfterStandardPrologue;
10036     function insertStatementsAfterCustomPrologue(to, from) {
10037         return insertStatementsAfterPrologue(to, from, isAnyPrologueDirective);
10038     }
10039     ts.insertStatementsAfterCustomPrologue = insertStatementsAfterCustomPrologue;
10040     function insertStatementAfterStandardPrologue(to, statement) {
10041         return insertStatementAfterPrologue(to, statement, isPrologueDirective);
10042     }
10043     ts.insertStatementAfterStandardPrologue = insertStatementAfterStandardPrologue;
10044     function insertStatementAfterCustomPrologue(to, statement) {
10045         return insertStatementAfterPrologue(to, statement, isAnyPrologueDirective);
10046     }
10047     ts.insertStatementAfterCustomPrologue = insertStatementAfterCustomPrologue;
10048     function isRecognizedTripleSlashComment(text, commentPos, commentEnd) {
10049         if (text.charCodeAt(commentPos + 1) === 47 &&
10050             commentPos + 2 < commentEnd &&
10051             text.charCodeAt(commentPos + 2) === 47) {
10052             var textSubStr = text.substring(commentPos, commentEnd);
10053             return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) ||
10054                 textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ||
10055                 textSubStr.match(fullTripleSlashReferenceTypeReferenceDirectiveRegEx) ||
10056                 textSubStr.match(defaultLibReferenceRegEx) ?
10057                 true : false;
10058         }
10059         return false;
10060     }
10061     ts.isRecognizedTripleSlashComment = isRecognizedTripleSlashComment;
10062     function isPinnedComment(text, start) {
10063         return text.charCodeAt(start + 1) === 42 &&
10064             text.charCodeAt(start + 2) === 33;
10065     }
10066     ts.isPinnedComment = isPinnedComment;
10067     function createCommentDirectivesMap(sourceFile, commentDirectives) {
10068         var directivesByLine = ts.createMapFromEntries(commentDirectives.map(function (commentDirective) { return ([
10069             "" + ts.getLineAndCharacterOfPosition(sourceFile, commentDirective.range.end).line,
10070             commentDirective,
10071         ]); }));
10072         var usedLines = ts.createMap();
10073         return { getUnusedExpectations: getUnusedExpectations, markUsed: markUsed };
10074         function getUnusedExpectations() {
10075             return ts.arrayFrom(directivesByLine.entries())
10076                 .filter(function (_a) {
10077                 var line = _a[0], directive = _a[1];
10078                 return directive.type === 0 && !usedLines.get(line);
10079             })
10080                 .map(function (_a) {
10081                 var _ = _a[0], directive = _a[1];
10082                 return directive;
10083             });
10084         }
10085         function markUsed(line) {
10086             if (!directivesByLine.has("" + line)) {
10087                 return false;
10088             }
10089             usedLines.set("" + line, true);
10090             return true;
10091         }
10092     }
10093     ts.createCommentDirectivesMap = createCommentDirectivesMap;
10094     function getTokenPosOfNode(node, sourceFile, includeJsDoc) {
10095         if (nodeIsMissing(node)) {
10096             return node.pos;
10097         }
10098         if (ts.isJSDocNode(node)) {
10099             return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, false, true);
10100         }
10101         if (includeJsDoc && ts.hasJSDocNodes(node)) {
10102             return getTokenPosOfNode(node.jsDoc[0], sourceFile);
10103         }
10104         if (node.kind === 324 && node._children.length > 0) {
10105             return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc);
10106         }
10107         return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos);
10108     }
10109     ts.getTokenPosOfNode = getTokenPosOfNode;
10110     function getNonDecoratorTokenPosOfNode(node, sourceFile) {
10111         if (nodeIsMissing(node) || !node.decorators) {
10112             return getTokenPosOfNode(node, sourceFile);
10113         }
10114         return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end);
10115     }
10116     ts.getNonDecoratorTokenPosOfNode = getNonDecoratorTokenPosOfNode;
10117     function getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia) {
10118         if (includeTrivia === void 0) { includeTrivia = false; }
10119         return getTextOfNodeFromSourceText(sourceFile.text, node, includeTrivia);
10120     }
10121     ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile;
10122     function isJSDocTypeExpressionOrChild(node) {
10123         return !!findAncestor(node, ts.isJSDocTypeExpression);
10124     }
10125     function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) {
10126         if (includeTrivia === void 0) { includeTrivia = false; }
10127         if (nodeIsMissing(node)) {
10128             return "";
10129         }
10130         var text = sourceText.substring(includeTrivia ? node.pos : ts.skipTrivia(sourceText, node.pos), node.end);
10131         if (isJSDocTypeExpressionOrChild(node)) {
10132             text = text.replace(/(^|\r?\n|\r)\s*\*\s*/g, "$1");
10133         }
10134         return text;
10135     }
10136     ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText;
10137     function getTextOfNode(node, includeTrivia) {
10138         if (includeTrivia === void 0) { includeTrivia = false; }
10139         return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia);
10140     }
10141     ts.getTextOfNode = getTextOfNode;
10142     function getPos(range) {
10143         return range.pos;
10144     }
10145     function indexOfNode(nodeArray, node) {
10146         return ts.binarySearch(nodeArray, node, getPos, ts.compareValues);
10147     }
10148     ts.indexOfNode = indexOfNode;
10149     function getEmitFlags(node) {
10150         var emitNode = node.emitNode;
10151         return emitNode && emitNode.flags || 0;
10152     }
10153     ts.getEmitFlags = getEmitFlags;
10154     function getLiteralText(node, sourceFile, neverAsciiEscape, jsxAttributeEscape) {
10155         if (!nodeIsSynthesized(node) && node.parent && !((ts.isNumericLiteral(node) && node.numericLiteralFlags & 512) ||
10156             ts.isBigIntLiteral(node))) {
10157             return getSourceTextOfNodeFromSourceFile(sourceFile, node);
10158         }
10159         switch (node.kind) {
10160             case 10: {
10161                 var escapeText = jsxAttributeEscape ? escapeJsxAttributeString :
10162                     neverAsciiEscape || (getEmitFlags(node) & 16777216) ? escapeString :
10163                         escapeNonAsciiString;
10164                 if (node.singleQuote) {
10165                     return "'" + escapeText(node.text, 39) + "'";
10166                 }
10167                 else {
10168                     return '"' + escapeText(node.text, 34) + '"';
10169                 }
10170             }
10171             case 14:
10172             case 15:
10173             case 16:
10174             case 17: {
10175                 var escapeText = neverAsciiEscape || (getEmitFlags(node) & 16777216) ? escapeString :
10176                     escapeNonAsciiString;
10177                 var rawText = node.rawText || escapeTemplateSubstitution(escapeText(node.text, 96));
10178                 switch (node.kind) {
10179                     case 14:
10180                         return "`" + rawText + "`";
10181                     case 15:
10182                         return "`" + rawText + "${";
10183                     case 16:
10184                         return "}" + rawText + "${";
10185                     case 17:
10186                         return "}" + rawText + "`";
10187                 }
10188                 break;
10189             }
10190             case 8:
10191             case 9:
10192             case 13:
10193                 return node.text;
10194         }
10195         return ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for.");
10196     }
10197     ts.getLiteralText = getLiteralText;
10198     function getTextOfConstantValue(value) {
10199         return ts.isString(value) ? '"' + escapeNonAsciiString(value) + '"' : "" + value;
10200     }
10201     ts.getTextOfConstantValue = getTextOfConstantValue;
10202     function makeIdentifierFromModuleName(moduleName) {
10203         return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_");
10204     }
10205     ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName;
10206     function isBlockOrCatchScoped(declaration) {
10207         return (ts.getCombinedNodeFlags(declaration) & 3) !== 0 ||
10208             isCatchClauseVariableDeclarationOrBindingElement(declaration);
10209     }
10210     ts.isBlockOrCatchScoped = isBlockOrCatchScoped;
10211     function isCatchClauseVariableDeclarationOrBindingElement(declaration) {
10212         var node = getRootDeclaration(declaration);
10213         return node.kind === 242 && node.parent.kind === 280;
10214     }
10215     ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement;
10216     function isAmbientModule(node) {
10217         return ts.isModuleDeclaration(node) && (node.name.kind === 10 || isGlobalScopeAugmentation(node));
10218     }
10219     ts.isAmbientModule = isAmbientModule;
10220     function isModuleWithStringLiteralName(node) {
10221         return ts.isModuleDeclaration(node) && node.name.kind === 10;
10222     }
10223     ts.isModuleWithStringLiteralName = isModuleWithStringLiteralName;
10224     function isNonGlobalAmbientModule(node) {
10225         return ts.isModuleDeclaration(node) && ts.isStringLiteral(node.name);
10226     }
10227     ts.isNonGlobalAmbientModule = isNonGlobalAmbientModule;
10228     function isEffectiveModuleDeclaration(node) {
10229         return ts.isModuleDeclaration(node) || ts.isIdentifier(node);
10230     }
10231     ts.isEffectiveModuleDeclaration = isEffectiveModuleDeclaration;
10232     function isShorthandAmbientModuleSymbol(moduleSymbol) {
10233         return isShorthandAmbientModule(moduleSymbol.valueDeclaration);
10234     }
10235     ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol;
10236     function isShorthandAmbientModule(node) {
10237         return node && node.kind === 249 && (!node.body);
10238     }
10239     function isBlockScopedContainerTopLevel(node) {
10240         return node.kind === 290 ||
10241             node.kind === 249 ||
10242             ts.isFunctionLike(node);
10243     }
10244     ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel;
10245     function isGlobalScopeAugmentation(module) {
10246         return !!(module.flags & 1024);
10247     }
10248     ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation;
10249     function isExternalModuleAugmentation(node) {
10250         return isAmbientModule(node) && isModuleAugmentationExternal(node);
10251     }
10252     ts.isExternalModuleAugmentation = isExternalModuleAugmentation;
10253     function isModuleAugmentationExternal(node) {
10254         switch (node.parent.kind) {
10255             case 290:
10256                 return ts.isExternalModule(node.parent);
10257             case 250:
10258                 return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent);
10259         }
10260         return false;
10261     }
10262     ts.isModuleAugmentationExternal = isModuleAugmentationExternal;
10263     function getNonAugmentationDeclaration(symbol) {
10264         return ts.find(symbol.declarations, function (d) { return !isExternalModuleAugmentation(d) && !(ts.isModuleDeclaration(d) && isGlobalScopeAugmentation(d)); });
10265     }
10266     ts.getNonAugmentationDeclaration = getNonAugmentationDeclaration;
10267     function isEffectiveExternalModule(node, compilerOptions) {
10268         return ts.isExternalModule(node) || compilerOptions.isolatedModules || ((getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS) && !!node.commonJsModuleIndicator);
10269     }
10270     ts.isEffectiveExternalModule = isEffectiveExternalModule;
10271     function isEffectiveStrictModeSourceFile(node, compilerOptions) {
10272         switch (node.scriptKind) {
10273             case 1:
10274             case 3:
10275             case 2:
10276             case 4:
10277                 break;
10278             default:
10279                 return false;
10280         }
10281         if (node.isDeclarationFile) {
10282             return false;
10283         }
10284         if (getStrictOptionValue(compilerOptions, "alwaysStrict")) {
10285             return true;
10286         }
10287         if (ts.startsWithUseStrict(node.statements)) {
10288             return true;
10289         }
10290         if (ts.isExternalModule(node) || compilerOptions.isolatedModules) {
10291             if (getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) {
10292                 return true;
10293             }
10294             return !compilerOptions.noImplicitUseStrict;
10295         }
10296         return false;
10297     }
10298     ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile;
10299     function isBlockScope(node, parentNode) {
10300         switch (node.kind) {
10301             case 290:
10302             case 251:
10303             case 280:
10304             case 249:
10305             case 230:
10306             case 231:
10307             case 232:
10308             case 162:
10309             case 161:
10310             case 163:
10311             case 164:
10312             case 244:
10313             case 201:
10314             case 202:
10315                 return true;
10316             case 223:
10317                 return !ts.isFunctionLike(parentNode);
10318         }
10319         return false;
10320     }
10321     ts.isBlockScope = isBlockScope;
10322     function isDeclarationWithTypeParameters(node) {
10323         switch (node.kind) {
10324             case 315:
10325             case 322:
10326             case 305:
10327                 return true;
10328             default:
10329                 ts.assertType(node);
10330                 return isDeclarationWithTypeParameterChildren(node);
10331         }
10332     }
10333     ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters;
10334     function isDeclarationWithTypeParameterChildren(node) {
10335         switch (node.kind) {
10336             case 165:
10337             case 166:
10338             case 160:
10339             case 167:
10340             case 170:
10341             case 171:
10342             case 300:
10343             case 245:
10344             case 214:
10345             case 246:
10346             case 247:
10347             case 321:
10348             case 244:
10349             case 161:
10350             case 162:
10351             case 163:
10352             case 164:
10353             case 201:
10354             case 202:
10355                 return true;
10356             default:
10357                 ts.assertType(node);
10358                 return false;
10359         }
10360     }
10361     ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren;
10362     function isAnyImportSyntax(node) {
10363         switch (node.kind) {
10364             case 254:
10365             case 253:
10366                 return true;
10367             default:
10368                 return false;
10369         }
10370     }
10371     ts.isAnyImportSyntax = isAnyImportSyntax;
10372     function isLateVisibilityPaintedStatement(node) {
10373         switch (node.kind) {
10374             case 254:
10375             case 253:
10376             case 225:
10377             case 245:
10378             case 244:
10379             case 249:
10380             case 247:
10381             case 246:
10382             case 248:
10383                 return true;
10384             default:
10385                 return false;
10386         }
10387     }
10388     ts.isLateVisibilityPaintedStatement = isLateVisibilityPaintedStatement;
10389     function isAnyImportOrReExport(node) {
10390         return isAnyImportSyntax(node) || ts.isExportDeclaration(node);
10391     }
10392     ts.isAnyImportOrReExport = isAnyImportOrReExport;
10393     function getEnclosingBlockScopeContainer(node) {
10394         return findAncestor(node.parent, function (current) { return isBlockScope(current, current.parent); });
10395     }
10396     ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer;
10397     function declarationNameToString(name) {
10398         return !name || getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name);
10399     }
10400     ts.declarationNameToString = declarationNameToString;
10401     function getNameFromIndexInfo(info) {
10402         return info.declaration ? declarationNameToString(info.declaration.parameters[0].name) : undefined;
10403     }
10404     ts.getNameFromIndexInfo = getNameFromIndexInfo;
10405     function isComputedNonLiteralName(name) {
10406         return name.kind === 154 && !isStringOrNumericLiteralLike(name.expression);
10407     }
10408     ts.isComputedNonLiteralName = isComputedNonLiteralName;
10409     function getTextOfPropertyName(name) {
10410         switch (name.kind) {
10411             case 75:
10412             case 76:
10413                 return name.escapedText;
10414             case 10:
10415             case 8:
10416             case 14:
10417                 return ts.escapeLeadingUnderscores(name.text);
10418             case 154:
10419                 if (isStringOrNumericLiteralLike(name.expression))
10420                     return ts.escapeLeadingUnderscores(name.expression.text);
10421                 return ts.Debug.fail("Text of property name cannot be read from non-literal-valued ComputedPropertyNames");
10422             default:
10423                 return ts.Debug.assertNever(name);
10424         }
10425     }
10426     ts.getTextOfPropertyName = getTextOfPropertyName;
10427     function entityNameToString(name) {
10428         switch (name.kind) {
10429             case 104:
10430                 return "this";
10431             case 76:
10432             case 75:
10433                 return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name);
10434             case 153:
10435                 return entityNameToString(name.left) + "." + entityNameToString(name.right);
10436             case 194:
10437                 if (ts.isIdentifier(name.name) || ts.isPrivateIdentifier(name.name)) {
10438                     return entityNameToString(name.expression) + "." + entityNameToString(name.name);
10439                 }
10440                 else {
10441                     return ts.Debug.assertNever(name.name);
10442                 }
10443             default:
10444                 return ts.Debug.assertNever(name);
10445         }
10446     }
10447     ts.entityNameToString = entityNameToString;
10448     function createDiagnosticForNode(node, message, arg0, arg1, arg2, arg3) {
10449         var sourceFile = getSourceFileOfNode(node);
10450         return createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2, arg3);
10451     }
10452     ts.createDiagnosticForNode = createDiagnosticForNode;
10453     function createDiagnosticForNodeArray(sourceFile, nodes, message, arg0, arg1, arg2, arg3) {
10454         var start = ts.skipTrivia(sourceFile.text, nodes.pos);
10455         return createFileDiagnostic(sourceFile, start, nodes.end - start, message, arg0, arg1, arg2, arg3);
10456     }
10457     ts.createDiagnosticForNodeArray = createDiagnosticForNodeArray;
10458     function createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2, arg3) {
10459         var span = getErrorSpanForNode(sourceFile, node);
10460         return createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2, arg3);
10461     }
10462     ts.createDiagnosticForNodeInSourceFile = createDiagnosticForNodeInSourceFile;
10463     function createDiagnosticForNodeFromMessageChain(node, messageChain, relatedInformation) {
10464         var sourceFile = getSourceFileOfNode(node);
10465         var span = getErrorSpanForNode(sourceFile, node);
10466         return {
10467             file: sourceFile,
10468             start: span.start,
10469             length: span.length,
10470             code: messageChain.code,
10471             category: messageChain.category,
10472             messageText: messageChain.next ? messageChain : messageChain.messageText,
10473             relatedInformation: relatedInformation
10474         };
10475     }
10476     ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain;
10477     function createDiagnosticForRange(sourceFile, range, message) {
10478         return {
10479             file: sourceFile,
10480             start: range.pos,
10481             length: range.end - range.pos,
10482             code: message.code,
10483             category: message.category,
10484             messageText: message.message,
10485         };
10486     }
10487     ts.createDiagnosticForRange = createDiagnosticForRange;
10488     function getSpanOfTokenAtPosition(sourceFile, pos) {
10489         var scanner = ts.createScanner(sourceFile.languageVersion, true, sourceFile.languageVariant, sourceFile.text, undefined, pos);
10490         scanner.scan();
10491         var start = scanner.getTokenPos();
10492         return ts.createTextSpanFromBounds(start, scanner.getTextPos());
10493     }
10494     ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition;
10495     function getErrorSpanForArrowFunction(sourceFile, node) {
10496         var pos = ts.skipTrivia(sourceFile.text, node.pos);
10497         if (node.body && node.body.kind === 223) {
10498             var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line;
10499             var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line;
10500             if (startLine < endLine) {
10501                 return ts.createTextSpan(pos, getEndLinePosition(startLine, sourceFile) - pos + 1);
10502             }
10503         }
10504         return ts.createTextSpanFromBounds(pos, node.end);
10505     }
10506     function getErrorSpanForNode(sourceFile, node) {
10507         var errorNode = node;
10508         switch (node.kind) {
10509             case 290:
10510                 var pos_1 = ts.skipTrivia(sourceFile.text, 0, false);
10511                 if (pos_1 === sourceFile.text.length) {
10512                     return ts.createTextSpan(0, 0);
10513                 }
10514                 return getSpanOfTokenAtPosition(sourceFile, pos_1);
10515             case 242:
10516             case 191:
10517             case 245:
10518             case 214:
10519             case 246:
10520             case 249:
10521             case 248:
10522             case 284:
10523             case 244:
10524             case 201:
10525             case 161:
10526             case 163:
10527             case 164:
10528             case 247:
10529             case 159:
10530             case 158:
10531                 errorNode = node.name;
10532                 break;
10533             case 202:
10534                 return getErrorSpanForArrowFunction(sourceFile, node);
10535             case 277:
10536             case 278:
10537                 var start = ts.skipTrivia(sourceFile.text, node.pos);
10538                 var end = node.statements.length > 0 ? node.statements[0].pos : node.end;
10539                 return ts.createTextSpanFromBounds(start, end);
10540         }
10541         if (errorNode === undefined) {
10542             return getSpanOfTokenAtPosition(sourceFile, node.pos);
10543         }
10544         ts.Debug.assert(!ts.isJSDoc(errorNode));
10545         var isMissing = nodeIsMissing(errorNode);
10546         var pos = isMissing || ts.isJsxText(node)
10547             ? errorNode.pos
10548             : ts.skipTrivia(sourceFile.text, errorNode.pos);
10549         if (isMissing) {
10550             ts.Debug.assert(pos === errorNode.pos, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809");
10551             ts.Debug.assert(pos === errorNode.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809");
10552         }
10553         else {
10554             ts.Debug.assert(pos >= errorNode.pos, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809");
10555             ts.Debug.assert(pos <= errorNode.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809");
10556         }
10557         return ts.createTextSpanFromBounds(pos, errorNode.end);
10558     }
10559     ts.getErrorSpanForNode = getErrorSpanForNode;
10560     function isExternalOrCommonJsModule(file) {
10561         return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined;
10562     }
10563     ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule;
10564     function isJsonSourceFile(file) {
10565         return file.scriptKind === 6;
10566     }
10567     ts.isJsonSourceFile = isJsonSourceFile;
10568     function isEnumConst(node) {
10569         return !!(ts.getCombinedModifierFlags(node) & 2048);
10570     }
10571     ts.isEnumConst = isEnumConst;
10572     function isDeclarationReadonly(declaration) {
10573         return !!(ts.getCombinedModifierFlags(declaration) & 64 && !ts.isParameterPropertyDeclaration(declaration, declaration.parent));
10574     }
10575     ts.isDeclarationReadonly = isDeclarationReadonly;
10576     function isVarConst(node) {
10577         return !!(ts.getCombinedNodeFlags(node) & 2);
10578     }
10579     ts.isVarConst = isVarConst;
10580     function isLet(node) {
10581         return !!(ts.getCombinedNodeFlags(node) & 1);
10582     }
10583     ts.isLet = isLet;
10584     function isSuperCall(n) {
10585         return n.kind === 196 && n.expression.kind === 102;
10586     }
10587     ts.isSuperCall = isSuperCall;
10588     function isImportCall(n) {
10589         return n.kind === 196 && n.expression.kind === 96;
10590     }
10591     ts.isImportCall = isImportCall;
10592     function isImportMeta(n) {
10593         return ts.isMetaProperty(n)
10594             && n.keywordToken === 96
10595             && n.name.escapedText === "meta";
10596     }
10597     ts.isImportMeta = isImportMeta;
10598     function isLiteralImportTypeNode(n) {
10599         return ts.isImportTypeNode(n) && ts.isLiteralTypeNode(n.argument) && ts.isStringLiteral(n.argument.literal);
10600     }
10601     ts.isLiteralImportTypeNode = isLiteralImportTypeNode;
10602     function isPrologueDirective(node) {
10603         return node.kind === 226
10604             && node.expression.kind === 10;
10605     }
10606     ts.isPrologueDirective = isPrologueDirective;
10607     function isCustomPrologue(node) {
10608         return !!(getEmitFlags(node) & 1048576);
10609     }
10610     ts.isCustomPrologue = isCustomPrologue;
10611     function isHoistedFunction(node) {
10612         return isCustomPrologue(node)
10613             && ts.isFunctionDeclaration(node);
10614     }
10615     ts.isHoistedFunction = isHoistedFunction;
10616     function isHoistedVariable(node) {
10617         return ts.isIdentifier(node.name)
10618             && !node.initializer;
10619     }
10620     function isHoistedVariableStatement(node) {
10621         return isCustomPrologue(node)
10622             && ts.isVariableStatement(node)
10623             && ts.every(node.declarationList.declarations, isHoistedVariable);
10624     }
10625     ts.isHoistedVariableStatement = isHoistedVariableStatement;
10626     function getLeadingCommentRangesOfNode(node, sourceFileOfNode) {
10627         return node.kind !== 11 ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined;
10628     }
10629     ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode;
10630     function getJSDocCommentRanges(node, text) {
10631         var commentRanges = (node.kind === 156 ||
10632             node.kind === 155 ||
10633             node.kind === 201 ||
10634             node.kind === 202 ||
10635             node.kind === 200) ?
10636             ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) :
10637             ts.getLeadingCommentRanges(text, node.pos);
10638         return ts.filter(commentRanges, function (comment) {
10639             return text.charCodeAt(comment.pos + 1) === 42 &&
10640                 text.charCodeAt(comment.pos + 2) === 42 &&
10641                 text.charCodeAt(comment.pos + 3) !== 47;
10642         });
10643     }
10644     ts.getJSDocCommentRanges = getJSDocCommentRanges;
10645     ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*<reference\s+path\s*=\s*)('|")(.+?)\2.*?\/>/;
10646     var fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*<reference\s+types\s*=\s*)('|")(.+?)\2.*?\/>/;
10647     ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*<amd-dependency\s+path\s*=\s*)('|")(.+?)\2.*?\/>/;
10648     var defaultLibReferenceRegEx = /^(\/\/\/\s*<reference\s+no-default-lib\s*=\s*)('|")(.+?)\2\s*\/>/;
10649     function isPartOfTypeNode(node) {
10650         if (168 <= node.kind && node.kind <= 188) {
10651             return true;
10652         }
10653         switch (node.kind) {
10654             case 125:
10655             case 148:
10656             case 140:
10657             case 151:
10658             case 143:
10659             case 128:
10660             case 144:
10661             case 141:
10662             case 146:
10663             case 137:
10664                 return true;
10665             case 110:
10666                 return node.parent.kind !== 205;
10667             case 216:
10668                 return !isExpressionWithTypeArgumentsInClassExtendsClause(node);
10669             case 155:
10670                 return node.parent.kind === 186 || node.parent.kind === 181;
10671             case 75:
10672                 if (node.parent.kind === 153 && node.parent.right === node) {
10673                     node = node.parent;
10674                 }
10675                 else if (node.parent.kind === 194 && node.parent.name === node) {
10676                     node = node.parent;
10677                 }
10678                 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'.");
10679             case 153:
10680             case 194:
10681             case 104: {
10682                 var parent = node.parent;
10683                 if (parent.kind === 172) {
10684                     return false;
10685                 }
10686                 if (parent.kind === 188) {
10687                     return !parent.isTypeOf;
10688                 }
10689                 if (168 <= parent.kind && parent.kind <= 188) {
10690                     return true;
10691                 }
10692                 switch (parent.kind) {
10693                     case 216:
10694                         return !isExpressionWithTypeArgumentsInClassExtendsClause(parent);
10695                     case 155:
10696                         return node === parent.constraint;
10697                     case 321:
10698                         return node === parent.constraint;
10699                     case 159:
10700                     case 158:
10701                     case 156:
10702                     case 242:
10703                         return node === parent.type;
10704                     case 244:
10705                     case 201:
10706                     case 202:
10707                     case 162:
10708                     case 161:
10709                     case 160:
10710                     case 163:
10711                     case 164:
10712                         return node === parent.type;
10713                     case 165:
10714                     case 166:
10715                     case 167:
10716                         return node === parent.type;
10717                     case 199:
10718                         return node === parent.type;
10719                     case 196:
10720                     case 197:
10721                         return ts.contains(parent.typeArguments, node);
10722                     case 198:
10723                         return false;
10724                 }
10725             }
10726         }
10727         return false;
10728     }
10729     ts.isPartOfTypeNode = isPartOfTypeNode;
10730     function isChildOfNodeWithKind(node, kind) {
10731         while (node) {
10732             if (node.kind === kind) {
10733                 return true;
10734             }
10735             node = node.parent;
10736         }
10737         return false;
10738     }
10739     ts.isChildOfNodeWithKind = isChildOfNodeWithKind;
10740     function forEachReturnStatement(body, visitor) {
10741         return traverse(body);
10742         function traverse(node) {
10743             switch (node.kind) {
10744                 case 235:
10745                     return visitor(node);
10746                 case 251:
10747                 case 223:
10748                 case 227:
10749                 case 228:
10750                 case 229:
10751                 case 230:
10752                 case 231:
10753                 case 232:
10754                 case 236:
10755                 case 237:
10756                 case 277:
10757                 case 278:
10758                 case 238:
10759                 case 240:
10760                 case 280:
10761                     return ts.forEachChild(node, traverse);
10762             }
10763         }
10764     }
10765     ts.forEachReturnStatement = forEachReturnStatement;
10766     function forEachYieldExpression(body, visitor) {
10767         return traverse(body);
10768         function traverse(node) {
10769             switch (node.kind) {
10770                 case 212:
10771                     visitor(node);
10772                     var operand = node.expression;
10773                     if (operand) {
10774                         traverse(operand);
10775                     }
10776                     return;
10777                 case 248:
10778                 case 246:
10779                 case 249:
10780                 case 247:
10781                     return;
10782                 default:
10783                     if (ts.isFunctionLike(node)) {
10784                         if (node.name && node.name.kind === 154) {
10785                             traverse(node.name.expression);
10786                             return;
10787                         }
10788                     }
10789                     else if (!isPartOfTypeNode(node)) {
10790                         ts.forEachChild(node, traverse);
10791                     }
10792             }
10793         }
10794     }
10795     ts.forEachYieldExpression = forEachYieldExpression;
10796     function getRestParameterElementType(node) {
10797         if (node && node.kind === 174) {
10798             return node.elementType;
10799         }
10800         else if (node && node.kind === 169) {
10801             return ts.singleOrUndefined(node.typeArguments);
10802         }
10803         else {
10804             return undefined;
10805         }
10806     }
10807     ts.getRestParameterElementType = getRestParameterElementType;
10808     function getMembersOfDeclaration(node) {
10809         switch (node.kind) {
10810             case 246:
10811             case 245:
10812             case 214:
10813             case 173:
10814                 return node.members;
10815             case 193:
10816                 return node.properties;
10817         }
10818     }
10819     ts.getMembersOfDeclaration = getMembersOfDeclaration;
10820     function isVariableLike(node) {
10821         if (node) {
10822             switch (node.kind) {
10823                 case 191:
10824                 case 284:
10825                 case 156:
10826                 case 281:
10827                 case 159:
10828                 case 158:
10829                 case 282:
10830                 case 242:
10831                     return true;
10832             }
10833         }
10834         return false;
10835     }
10836     ts.isVariableLike = isVariableLike;
10837     function isVariableLikeOrAccessor(node) {
10838         return isVariableLike(node) || ts.isAccessor(node);
10839     }
10840     ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor;
10841     function isVariableDeclarationInVariableStatement(node) {
10842         return node.parent.kind === 243
10843             && node.parent.parent.kind === 225;
10844     }
10845     ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement;
10846     function isValidESSymbolDeclaration(node) {
10847         return ts.isVariableDeclaration(node) ? isVarConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) :
10848             ts.isPropertyDeclaration(node) ? hasReadonlyModifier(node) && hasStaticModifier(node) :
10849                 ts.isPropertySignature(node) && hasReadonlyModifier(node);
10850     }
10851     ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration;
10852     function introducesArgumentsExoticObject(node) {
10853         switch (node.kind) {
10854             case 161:
10855             case 160:
10856             case 162:
10857             case 163:
10858             case 164:
10859             case 244:
10860             case 201:
10861                 return true;
10862         }
10863         return false;
10864     }
10865     ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject;
10866     function unwrapInnermostStatementOfLabel(node, beforeUnwrapLabelCallback) {
10867         while (true) {
10868             if (beforeUnwrapLabelCallback) {
10869                 beforeUnwrapLabelCallback(node);
10870             }
10871             if (node.statement.kind !== 238) {
10872                 return node.statement;
10873             }
10874             node = node.statement;
10875         }
10876     }
10877     ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel;
10878     function isFunctionBlock(node) {
10879         return node && node.kind === 223 && ts.isFunctionLike(node.parent);
10880     }
10881     ts.isFunctionBlock = isFunctionBlock;
10882     function isObjectLiteralMethod(node) {
10883         return node && node.kind === 161 && node.parent.kind === 193;
10884     }
10885     ts.isObjectLiteralMethod = isObjectLiteralMethod;
10886     function isObjectLiteralOrClassExpressionMethod(node) {
10887         return node.kind === 161 &&
10888             (node.parent.kind === 193 ||
10889                 node.parent.kind === 214);
10890     }
10891     ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod;
10892     function isIdentifierTypePredicate(predicate) {
10893         return predicate && predicate.kind === 1;
10894     }
10895     ts.isIdentifierTypePredicate = isIdentifierTypePredicate;
10896     function isThisTypePredicate(predicate) {
10897         return predicate && predicate.kind === 0;
10898     }
10899     ts.isThisTypePredicate = isThisTypePredicate;
10900     function getPropertyAssignment(objectLiteral, key, key2) {
10901         return objectLiteral.properties.filter(function (property) {
10902             if (property.kind === 281) {
10903                 var propName = getTextOfPropertyName(property.name);
10904                 return key === propName || (!!key2 && key2 === propName);
10905             }
10906             return false;
10907         });
10908     }
10909     ts.getPropertyAssignment = getPropertyAssignment;
10910     function getTsConfigObjectLiteralExpression(tsConfigSourceFile) {
10911         if (tsConfigSourceFile && tsConfigSourceFile.statements.length) {
10912             var expression = tsConfigSourceFile.statements[0].expression;
10913             return ts.tryCast(expression, ts.isObjectLiteralExpression);
10914         }
10915     }
10916     ts.getTsConfigObjectLiteralExpression = getTsConfigObjectLiteralExpression;
10917     function getTsConfigPropArrayElementValue(tsConfigSourceFile, propKey, elementValue) {
10918         return ts.firstDefined(getTsConfigPropArray(tsConfigSourceFile, propKey), function (property) {
10919             return ts.isArrayLiteralExpression(property.initializer) ?
10920                 ts.find(property.initializer.elements, function (element) { return ts.isStringLiteral(element) && element.text === elementValue; }) :
10921                 undefined;
10922         });
10923     }
10924     ts.getTsConfigPropArrayElementValue = getTsConfigPropArrayElementValue;
10925     function getTsConfigPropArray(tsConfigSourceFile, propKey) {
10926         var jsonObjectLiteral = getTsConfigObjectLiteralExpression(tsConfigSourceFile);
10927         return jsonObjectLiteral ? getPropertyAssignment(jsonObjectLiteral, propKey) : ts.emptyArray;
10928     }
10929     ts.getTsConfigPropArray = getTsConfigPropArray;
10930     function getContainingFunction(node) {
10931         return findAncestor(node.parent, ts.isFunctionLike);
10932     }
10933     ts.getContainingFunction = getContainingFunction;
10934     function getContainingFunctionDeclaration(node) {
10935         return findAncestor(node.parent, ts.isFunctionLikeDeclaration);
10936     }
10937     ts.getContainingFunctionDeclaration = getContainingFunctionDeclaration;
10938     function getContainingClass(node) {
10939         return findAncestor(node.parent, ts.isClassLike);
10940     }
10941     ts.getContainingClass = getContainingClass;
10942     function getThisContainer(node, includeArrowFunctions) {
10943         ts.Debug.assert(node.kind !== 290);
10944         while (true) {
10945             node = node.parent;
10946             if (!node) {
10947                 return ts.Debug.fail();
10948             }
10949             switch (node.kind) {
10950                 case 154:
10951                     if (ts.isClassLike(node.parent.parent)) {
10952                         return node;
10953                     }
10954                     node = node.parent;
10955                     break;
10956                 case 157:
10957                     if (node.parent.kind === 156 && ts.isClassElement(node.parent.parent)) {
10958                         node = node.parent.parent;
10959                     }
10960                     else if (ts.isClassElement(node.parent)) {
10961                         node = node.parent;
10962                     }
10963                     break;
10964                 case 202:
10965                     if (!includeArrowFunctions) {
10966                         continue;
10967                     }
10968                 case 244:
10969                 case 201:
10970                 case 249:
10971                 case 159:
10972                 case 158:
10973                 case 161:
10974                 case 160:
10975                 case 162:
10976                 case 163:
10977                 case 164:
10978                 case 165:
10979                 case 166:
10980                 case 167:
10981                 case 248:
10982                 case 290:
10983                     return node;
10984             }
10985         }
10986     }
10987     ts.getThisContainer = getThisContainer;
10988     function getNewTargetContainer(node) {
10989         var container = getThisContainer(node, false);
10990         if (container) {
10991             switch (container.kind) {
10992                 case 162:
10993                 case 244:
10994                 case 201:
10995                     return container;
10996             }
10997         }
10998         return undefined;
10999     }
11000     ts.getNewTargetContainer = getNewTargetContainer;
11001     function getSuperContainer(node, stopOnFunctions) {
11002         while (true) {
11003             node = node.parent;
11004             if (!node) {
11005                 return node;
11006             }
11007             switch (node.kind) {
11008                 case 154:
11009                     node = node.parent;
11010                     break;
11011                 case 244:
11012                 case 201:
11013                 case 202:
11014                     if (!stopOnFunctions) {
11015                         continue;
11016                     }
11017                 case 159:
11018                 case 158:
11019                 case 161:
11020                 case 160:
11021                 case 162:
11022                 case 163:
11023                 case 164:
11024                     return node;
11025                 case 157:
11026                     if (node.parent.kind === 156 && ts.isClassElement(node.parent.parent)) {
11027                         node = node.parent.parent;
11028                     }
11029                     else if (ts.isClassElement(node.parent)) {
11030                         node = node.parent;
11031                     }
11032                     break;
11033             }
11034         }
11035     }
11036     ts.getSuperContainer = getSuperContainer;
11037     function getImmediatelyInvokedFunctionExpression(func) {
11038         if (func.kind === 201 || func.kind === 202) {
11039             var prev = func;
11040             var parent = func.parent;
11041             while (parent.kind === 200) {
11042                 prev = parent;
11043                 parent = parent.parent;
11044             }
11045             if (parent.kind === 196 && parent.expression === prev) {
11046                 return parent;
11047             }
11048         }
11049     }
11050     ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression;
11051     function isSuperOrSuperProperty(node) {
11052         return node.kind === 102
11053             || isSuperProperty(node);
11054     }
11055     ts.isSuperOrSuperProperty = isSuperOrSuperProperty;
11056     function isSuperProperty(node) {
11057         var kind = node.kind;
11058         return (kind === 194 || kind === 195)
11059             && node.expression.kind === 102;
11060     }
11061     ts.isSuperProperty = isSuperProperty;
11062     function isThisProperty(node) {
11063         var kind = node.kind;
11064         return (kind === 194 || kind === 195)
11065             && node.expression.kind === 104;
11066     }
11067     ts.isThisProperty = isThisProperty;
11068     function getEntityNameFromTypeNode(node) {
11069         switch (node.kind) {
11070             case 169:
11071                 return node.typeName;
11072             case 216:
11073                 return isEntityNameExpression(node.expression)
11074                     ? node.expression
11075                     : undefined;
11076             case 75:
11077             case 153:
11078                 return node;
11079         }
11080         return undefined;
11081     }
11082     ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode;
11083     function getInvokedExpression(node) {
11084         switch (node.kind) {
11085             case 198:
11086                 return node.tag;
11087             case 268:
11088             case 267:
11089                 return node.tagName;
11090             default:
11091                 return node.expression;
11092         }
11093     }
11094     ts.getInvokedExpression = getInvokedExpression;
11095     function nodeCanBeDecorated(node, parent, grandparent) {
11096         if (ts.isNamedDeclaration(node) && ts.isPrivateIdentifier(node.name)) {
11097             return false;
11098         }
11099         switch (node.kind) {
11100             case 245:
11101                 return true;
11102             case 159:
11103                 return parent.kind === 245;
11104             case 163:
11105             case 164:
11106             case 161:
11107                 return node.body !== undefined
11108                     && parent.kind === 245;
11109             case 156:
11110                 return parent.body !== undefined
11111                     && (parent.kind === 162
11112                         || parent.kind === 161
11113                         || parent.kind === 164)
11114                     && grandparent.kind === 245;
11115         }
11116         return false;
11117     }
11118     ts.nodeCanBeDecorated = nodeCanBeDecorated;
11119     function nodeIsDecorated(node, parent, grandparent) {
11120         return node.decorators !== undefined
11121             && nodeCanBeDecorated(node, parent, grandparent);
11122     }
11123     ts.nodeIsDecorated = nodeIsDecorated;
11124     function nodeOrChildIsDecorated(node, parent, grandparent) {
11125         return nodeIsDecorated(node, parent, grandparent) || childIsDecorated(node, parent);
11126     }
11127     ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated;
11128     function childIsDecorated(node, parent) {
11129         switch (node.kind) {
11130             case 245:
11131                 return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); });
11132             case 161:
11133             case 164:
11134                 return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); });
11135             default:
11136                 return false;
11137         }
11138     }
11139     ts.childIsDecorated = childIsDecorated;
11140     function isJSXTagName(node) {
11141         var parent = node.parent;
11142         if (parent.kind === 268 ||
11143             parent.kind === 267 ||
11144             parent.kind === 269) {
11145             return parent.tagName === node;
11146         }
11147         return false;
11148     }
11149     ts.isJSXTagName = isJSXTagName;
11150     function isExpressionNode(node) {
11151         switch (node.kind) {
11152             case 102:
11153             case 100:
11154             case 106:
11155             case 91:
11156             case 13:
11157             case 192:
11158             case 193:
11159             case 194:
11160             case 195:
11161             case 196:
11162             case 197:
11163             case 198:
11164             case 217:
11165             case 199:
11166             case 218:
11167             case 200:
11168             case 201:
11169             case 214:
11170             case 202:
11171             case 205:
11172             case 203:
11173             case 204:
11174             case 207:
11175             case 208:
11176             case 209:
11177             case 210:
11178             case 213:
11179             case 211:
11180             case 215:
11181             case 266:
11182             case 267:
11183             case 270:
11184             case 212:
11185             case 206:
11186             case 219:
11187                 return true;
11188             case 153:
11189                 while (node.parent.kind === 153) {
11190                     node = node.parent;
11191                 }
11192                 return node.parent.kind === 172 || isJSXTagName(node);
11193             case 75:
11194                 if (node.parent.kind === 172 || isJSXTagName(node)) {
11195                     return true;
11196                 }
11197             case 8:
11198             case 9:
11199             case 10:
11200             case 14:
11201             case 104:
11202                 return isInExpressionContext(node);
11203             default:
11204                 return false;
11205         }
11206     }
11207     ts.isExpressionNode = isExpressionNode;
11208     function isInExpressionContext(node) {
11209         var parent = node.parent;
11210         switch (parent.kind) {
11211             case 242:
11212             case 156:
11213             case 159:
11214             case 158:
11215             case 284:
11216             case 281:
11217             case 191:
11218                 return parent.initializer === node;
11219             case 226:
11220             case 227:
11221             case 228:
11222             case 229:
11223             case 235:
11224             case 236:
11225             case 237:
11226             case 277:
11227             case 239:
11228                 return parent.expression === node;
11229             case 230:
11230                 var forStatement = parent;
11231                 return (forStatement.initializer === node && forStatement.initializer.kind !== 243) ||
11232                     forStatement.condition === node ||
11233                     forStatement.incrementor === node;
11234             case 231:
11235             case 232:
11236                 var forInStatement = parent;
11237                 return (forInStatement.initializer === node && forInStatement.initializer.kind !== 243) ||
11238                     forInStatement.expression === node;
11239             case 199:
11240             case 217:
11241                 return node === parent.expression;
11242             case 221:
11243                 return node === parent.expression;
11244             case 154:
11245                 return node === parent.expression;
11246             case 157:
11247             case 276:
11248             case 275:
11249             case 283:
11250                 return true;
11251             case 216:
11252                 return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent);
11253             case 282:
11254                 return parent.objectAssignmentInitializer === node;
11255             default:
11256                 return isExpressionNode(parent);
11257         }
11258     }
11259     ts.isInExpressionContext = isInExpressionContext;
11260     function isPartOfTypeQuery(node) {
11261         while (node.kind === 153 || node.kind === 75) {
11262             node = node.parent;
11263         }
11264         return node.kind === 172;
11265     }
11266     ts.isPartOfTypeQuery = isPartOfTypeQuery;
11267     function isExternalModuleImportEqualsDeclaration(node) {
11268         return node.kind === 253 && node.moduleReference.kind === 265;
11269     }
11270     ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration;
11271     function getExternalModuleImportEqualsDeclarationExpression(node) {
11272         ts.Debug.assert(isExternalModuleImportEqualsDeclaration(node));
11273         return node.moduleReference.expression;
11274     }
11275     ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression;
11276     function isInternalModuleImportEqualsDeclaration(node) {
11277         return node.kind === 253 && node.moduleReference.kind !== 265;
11278     }
11279     ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration;
11280     function isSourceFileJS(file) {
11281         return isInJSFile(file);
11282     }
11283     ts.isSourceFileJS = isSourceFileJS;
11284     function isSourceFileNotJS(file) {
11285         return !isInJSFile(file);
11286     }
11287     ts.isSourceFileNotJS = isSourceFileNotJS;
11288     function isInJSFile(node) {
11289         return !!node && !!(node.flags & 131072);
11290     }
11291     ts.isInJSFile = isInJSFile;
11292     function isInJsonFile(node) {
11293         return !!node && !!(node.flags & 33554432);
11294     }
11295     ts.isInJsonFile = isInJsonFile;
11296     function isSourceFileNotJson(file) {
11297         return !isJsonSourceFile(file);
11298     }
11299     ts.isSourceFileNotJson = isSourceFileNotJson;
11300     function isInJSDoc(node) {
11301         return !!node && !!(node.flags & 4194304);
11302     }
11303     ts.isInJSDoc = isInJSDoc;
11304     function isJSDocIndexSignature(node) {
11305         return ts.isTypeReferenceNode(node) &&
11306             ts.isIdentifier(node.typeName) &&
11307             node.typeName.escapedText === "Object" &&
11308             node.typeArguments && node.typeArguments.length === 2 &&
11309             (node.typeArguments[0].kind === 143 || node.typeArguments[0].kind === 140);
11310     }
11311     ts.isJSDocIndexSignature = isJSDocIndexSignature;
11312     function isRequireCall(callExpression, requireStringLiteralLikeArgument) {
11313         if (callExpression.kind !== 196) {
11314             return false;
11315         }
11316         var _a = callExpression, expression = _a.expression, args = _a.arguments;
11317         if (expression.kind !== 75 || expression.escapedText !== "require") {
11318             return false;
11319         }
11320         if (args.length !== 1) {
11321             return false;
11322         }
11323         var arg = args[0];
11324         return !requireStringLiteralLikeArgument || ts.isStringLiteralLike(arg);
11325     }
11326     ts.isRequireCall = isRequireCall;
11327     function isRequireVariableDeclaration(node, requireStringLiteralLikeArgument) {
11328         return ts.isVariableDeclaration(node) && !!node.initializer && isRequireCall(node.initializer, requireStringLiteralLikeArgument);
11329     }
11330     ts.isRequireVariableDeclaration = isRequireVariableDeclaration;
11331     function isRequireVariableDeclarationStatement(node, requireStringLiteralLikeArgument) {
11332         if (requireStringLiteralLikeArgument === void 0) { requireStringLiteralLikeArgument = true; }
11333         return ts.isVariableStatement(node) && ts.every(node.declarationList.declarations, function (decl) { return isRequireVariableDeclaration(decl, requireStringLiteralLikeArgument); });
11334     }
11335     ts.isRequireVariableDeclarationStatement = isRequireVariableDeclarationStatement;
11336     function isSingleOrDoubleQuote(charCode) {
11337         return charCode === 39 || charCode === 34;
11338     }
11339     ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote;
11340     function isStringDoubleQuoted(str, sourceFile) {
11341         return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34;
11342     }
11343     ts.isStringDoubleQuoted = isStringDoubleQuoted;
11344     function getDeclarationOfExpando(node) {
11345         if (!node.parent) {
11346             return undefined;
11347         }
11348         var name;
11349         var decl;
11350         if (ts.isVariableDeclaration(node.parent) && node.parent.initializer === node) {
11351             if (!isInJSFile(node) && !isVarConst(node.parent)) {
11352                 return undefined;
11353             }
11354             name = node.parent.name;
11355             decl = node.parent;
11356         }
11357         else if (ts.isBinaryExpression(node.parent)) {
11358             var parentNode = node.parent;
11359             var parentNodeOperator = node.parent.operatorToken.kind;
11360             if (parentNodeOperator === 62 && parentNode.right === node) {
11361                 name = parentNode.left;
11362                 decl = name;
11363             }
11364             else if (parentNodeOperator === 56 || parentNodeOperator === 60) {
11365                 if (ts.isVariableDeclaration(parentNode.parent) && parentNode.parent.initializer === parentNode) {
11366                     name = parentNode.parent.name;
11367                     decl = parentNode.parent;
11368                 }
11369                 else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 62 && parentNode.parent.right === parentNode) {
11370                     name = parentNode.parent.left;
11371                     decl = name;
11372                 }
11373                 if (!name || !isBindableStaticNameExpression(name) || !isSameEntityName(name, parentNode.left)) {
11374                     return undefined;
11375                 }
11376             }
11377         }
11378         if (!name || !getExpandoInitializer(node, isPrototypeAccess(name))) {
11379             return undefined;
11380         }
11381         return decl;
11382     }
11383     ts.getDeclarationOfExpando = getDeclarationOfExpando;
11384     function isAssignmentDeclaration(decl) {
11385         return ts.isBinaryExpression(decl) || isAccessExpression(decl) || ts.isIdentifier(decl) || ts.isCallExpression(decl);
11386     }
11387     ts.isAssignmentDeclaration = isAssignmentDeclaration;
11388     function getEffectiveInitializer(node) {
11389         if (isInJSFile(node) && node.initializer &&
11390             ts.isBinaryExpression(node.initializer) &&
11391             (node.initializer.operatorToken.kind === 56 || node.initializer.operatorToken.kind === 60) &&
11392             node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) {
11393             return node.initializer.right;
11394         }
11395         return node.initializer;
11396     }
11397     ts.getEffectiveInitializer = getEffectiveInitializer;
11398     function getDeclaredExpandoInitializer(node) {
11399         var init = getEffectiveInitializer(node);
11400         return init && getExpandoInitializer(init, isPrototypeAccess(node.name));
11401     }
11402     ts.getDeclaredExpandoInitializer = getDeclaredExpandoInitializer;
11403     function hasExpandoValueProperty(node, isPrototypeAssignment) {
11404         return ts.forEach(node.properties, function (p) {
11405             return ts.isPropertyAssignment(p) &&
11406                 ts.isIdentifier(p.name) &&
11407                 p.name.escapedText === "value" &&
11408                 p.initializer &&
11409                 getExpandoInitializer(p.initializer, isPrototypeAssignment);
11410         });
11411     }
11412     function getAssignedExpandoInitializer(node) {
11413         if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62) {
11414             var isPrototypeAssignment = isPrototypeAccess(node.parent.left);
11415             return getExpandoInitializer(node.parent.right, isPrototypeAssignment) ||
11416                 getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment);
11417         }
11418         if (node && ts.isCallExpression(node) && isBindableObjectDefinePropertyCall(node)) {
11419             var result = hasExpandoValueProperty(node.arguments[2], node.arguments[1].text === "prototype");
11420             if (result) {
11421                 return result;
11422             }
11423         }
11424     }
11425     ts.getAssignedExpandoInitializer = getAssignedExpandoInitializer;
11426     function getExpandoInitializer(initializer, isPrototypeAssignment) {
11427         if (ts.isCallExpression(initializer)) {
11428             var e = skipParentheses(initializer.expression);
11429             return e.kind === 201 || e.kind === 202 ? initializer : undefined;
11430         }
11431         if (initializer.kind === 201 ||
11432             initializer.kind === 214 ||
11433             initializer.kind === 202) {
11434             return initializer;
11435         }
11436         if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) {
11437             return initializer;
11438         }
11439     }
11440     ts.getExpandoInitializer = getExpandoInitializer;
11441     function getDefaultedExpandoInitializer(name, initializer, isPrototypeAssignment) {
11442         var e = ts.isBinaryExpression(initializer)
11443             && (initializer.operatorToken.kind === 56 || initializer.operatorToken.kind === 60)
11444             && getExpandoInitializer(initializer.right, isPrototypeAssignment);
11445         if (e && isSameEntityName(name, initializer.left)) {
11446             return e;
11447         }
11448     }
11449     function isDefaultedExpandoInitializer(node) {
11450         var name = ts.isVariableDeclaration(node.parent) ? node.parent.name :
11451             ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 ? node.parent.left :
11452                 undefined;
11453         return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left);
11454     }
11455     ts.isDefaultedExpandoInitializer = isDefaultedExpandoInitializer;
11456     function getNameOfExpando(node) {
11457         if (ts.isBinaryExpression(node.parent)) {
11458             var parent = ((node.parent.operatorToken.kind === 56 || node.parent.operatorToken.kind === 60) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent;
11459             if (parent.operatorToken.kind === 62 && ts.isIdentifier(parent.left)) {
11460                 return parent.left;
11461             }
11462         }
11463         else if (ts.isVariableDeclaration(node.parent)) {
11464             return node.parent.name;
11465         }
11466     }
11467     ts.getNameOfExpando = getNameOfExpando;
11468     function isSameEntityName(name, initializer) {
11469         if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) {
11470             return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(name);
11471         }
11472         if (ts.isIdentifier(name) && isLiteralLikeAccess(initializer) &&
11473             (initializer.expression.kind === 104 ||
11474                 ts.isIdentifier(initializer.expression) &&
11475                     (initializer.expression.escapedText === "window" ||
11476                         initializer.expression.escapedText === "self" ||
11477                         initializer.expression.escapedText === "global"))) {
11478             var nameOrArgument = getNameOrArgument(initializer);
11479             if (ts.isPrivateIdentifier(nameOrArgument)) {
11480                 ts.Debug.fail("Unexpected PrivateIdentifier in name expression with literal-like access.");
11481             }
11482             return isSameEntityName(name, nameOrArgument);
11483         }
11484         if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) {
11485             return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer)
11486                 && isSameEntityName(name.expression, initializer.expression);
11487         }
11488         return false;
11489     }
11490     function getRightMostAssignedExpression(node) {
11491         while (isAssignmentExpression(node, true)) {
11492             node = node.right;
11493         }
11494         return node;
11495     }
11496     ts.getRightMostAssignedExpression = getRightMostAssignedExpression;
11497     function isExportsIdentifier(node) {
11498         return ts.isIdentifier(node) && node.escapedText === "exports";
11499     }
11500     ts.isExportsIdentifier = isExportsIdentifier;
11501     function isModuleIdentifier(node) {
11502         return ts.isIdentifier(node) && node.escapedText === "module";
11503     }
11504     ts.isModuleIdentifier = isModuleIdentifier;
11505     function isModuleExportsAccessExpression(node) {
11506         return (ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node))
11507             && isModuleIdentifier(node.expression)
11508             && getElementOrPropertyAccessName(node) === "exports";
11509     }
11510     ts.isModuleExportsAccessExpression = isModuleExportsAccessExpression;
11511     function getAssignmentDeclarationKind(expr) {
11512         var special = getAssignmentDeclarationKindWorker(expr);
11513         return special === 5 || isInJSFile(expr) ? special : 0;
11514     }
11515     ts.getAssignmentDeclarationKind = getAssignmentDeclarationKind;
11516     function isBindableObjectDefinePropertyCall(expr) {
11517         return ts.length(expr.arguments) === 3 &&
11518             ts.isPropertyAccessExpression(expr.expression) &&
11519             ts.isIdentifier(expr.expression.expression) &&
11520             ts.idText(expr.expression.expression) === "Object" &&
11521             ts.idText(expr.expression.name) === "defineProperty" &&
11522             isStringOrNumericLiteralLike(expr.arguments[1]) &&
11523             isBindableStaticNameExpression(expr.arguments[0], true);
11524     }
11525     ts.isBindableObjectDefinePropertyCall = isBindableObjectDefinePropertyCall;
11526     function isLiteralLikeAccess(node) {
11527         return ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node);
11528     }
11529     ts.isLiteralLikeAccess = isLiteralLikeAccess;
11530     function isLiteralLikeElementAccess(node) {
11531         return ts.isElementAccessExpression(node) && (isStringOrNumericLiteralLike(node.argumentExpression) ||
11532             isWellKnownSymbolSyntactically(node.argumentExpression));
11533     }
11534     ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess;
11535     function isBindableStaticAccessExpression(node, excludeThisKeyword) {
11536         return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 104 || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, true))
11537             || isBindableStaticElementAccessExpression(node, excludeThisKeyword);
11538     }
11539     ts.isBindableStaticAccessExpression = isBindableStaticAccessExpression;
11540     function isBindableStaticElementAccessExpression(node, excludeThisKeyword) {
11541         return isLiteralLikeElementAccess(node)
11542             && ((!excludeThisKeyword && node.expression.kind === 104) ||
11543                 isEntityNameExpression(node.expression) ||
11544                 isBindableStaticAccessExpression(node.expression, true));
11545     }
11546     ts.isBindableStaticElementAccessExpression = isBindableStaticElementAccessExpression;
11547     function isBindableStaticNameExpression(node, excludeThisKeyword) {
11548         return isEntityNameExpression(node) || isBindableStaticAccessExpression(node, excludeThisKeyword);
11549     }
11550     ts.isBindableStaticNameExpression = isBindableStaticNameExpression;
11551     function getNameOrArgument(expr) {
11552         if (ts.isPropertyAccessExpression(expr)) {
11553             return expr.name;
11554         }
11555         return expr.argumentExpression;
11556     }
11557     ts.getNameOrArgument = getNameOrArgument;
11558     function getAssignmentDeclarationKindWorker(expr) {
11559         if (ts.isCallExpression(expr)) {
11560             if (!isBindableObjectDefinePropertyCall(expr)) {
11561                 return 0;
11562             }
11563             var entityName = expr.arguments[0];
11564             if (isExportsIdentifier(entityName) || isModuleExportsAccessExpression(entityName)) {
11565                 return 8;
11566             }
11567             if (isBindableStaticAccessExpression(entityName) && getElementOrPropertyAccessName(entityName) === "prototype") {
11568                 return 9;
11569             }
11570             return 7;
11571         }
11572         if (expr.operatorToken.kind !== 62 || !isAccessExpression(expr.left)) {
11573             return 0;
11574         }
11575         if (isBindableStaticNameExpression(expr.left.expression, true) && getElementOrPropertyAccessName(expr.left) === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) {
11576             return 6;
11577         }
11578         return getAssignmentDeclarationPropertyAccessKind(expr.left);
11579     }
11580     function getElementOrPropertyAccessArgumentExpressionOrName(node) {
11581         if (ts.isPropertyAccessExpression(node)) {
11582             return node.name;
11583         }
11584         var arg = skipParentheses(node.argumentExpression);
11585         if (ts.isNumericLiteral(arg) || ts.isStringLiteralLike(arg)) {
11586             return arg;
11587         }
11588         return node;
11589     }
11590     ts.getElementOrPropertyAccessArgumentExpressionOrName = getElementOrPropertyAccessArgumentExpressionOrName;
11591     function getElementOrPropertyAccessName(node) {
11592         var name = getElementOrPropertyAccessArgumentExpressionOrName(node);
11593         if (name) {
11594             if (ts.isIdentifier(name)) {
11595                 return name.escapedText;
11596             }
11597             if (ts.isStringLiteralLike(name) || ts.isNumericLiteral(name)) {
11598                 return ts.escapeLeadingUnderscores(name.text);
11599             }
11600         }
11601         if (ts.isElementAccessExpression(node) && isWellKnownSymbolSyntactically(node.argumentExpression)) {
11602             return getPropertyNameForKnownSymbolName(ts.idText(node.argumentExpression.name));
11603         }
11604         return undefined;
11605     }
11606     ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName;
11607     function getAssignmentDeclarationPropertyAccessKind(lhs) {
11608         if (lhs.expression.kind === 104) {
11609             return 4;
11610         }
11611         else if (isModuleExportsAccessExpression(lhs)) {
11612             return 2;
11613         }
11614         else if (isBindableStaticNameExpression(lhs.expression, true)) {
11615             if (isPrototypeAccess(lhs.expression)) {
11616                 return 3;
11617             }
11618             var nextToLast = lhs;
11619             while (!ts.isIdentifier(nextToLast.expression)) {
11620                 nextToLast = nextToLast.expression;
11621             }
11622             var id = nextToLast.expression;
11623             if ((id.escapedText === "exports" ||
11624                 id.escapedText === "module" && getElementOrPropertyAccessName(nextToLast) === "exports") &&
11625                 isBindableStaticAccessExpression(lhs)) {
11626                 return 1;
11627             }
11628             if (isBindableStaticNameExpression(lhs, true) || (ts.isElementAccessExpression(lhs) && isDynamicName(lhs))) {
11629                 return 5;
11630             }
11631         }
11632         return 0;
11633     }
11634     ts.getAssignmentDeclarationPropertyAccessKind = getAssignmentDeclarationPropertyAccessKind;
11635     function getInitializerOfBinaryExpression(expr) {
11636         while (ts.isBinaryExpression(expr.right)) {
11637             expr = expr.right;
11638         }
11639         return expr.right;
11640     }
11641     ts.getInitializerOfBinaryExpression = getInitializerOfBinaryExpression;
11642     function isPrototypePropertyAssignment(node) {
11643         return ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 3;
11644     }
11645     ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment;
11646     function isSpecialPropertyDeclaration(expr) {
11647         return isInJSFile(expr) &&
11648             expr.parent && expr.parent.kind === 226 &&
11649             (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) &&
11650             !!ts.getJSDocTypeTag(expr.parent);
11651     }
11652     ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration;
11653     function setValueDeclaration(symbol, node) {
11654         var valueDeclaration = symbol.valueDeclaration;
11655         if (!valueDeclaration ||
11656             !(node.flags & 8388608 && !(valueDeclaration.flags & 8388608)) &&
11657                 (isAssignmentDeclaration(valueDeclaration) && !isAssignmentDeclaration(node)) ||
11658             (valueDeclaration.kind !== node.kind && isEffectiveModuleDeclaration(valueDeclaration))) {
11659             symbol.valueDeclaration = node;
11660         }
11661     }
11662     ts.setValueDeclaration = setValueDeclaration;
11663     function isFunctionSymbol(symbol) {
11664         if (!symbol || !symbol.valueDeclaration) {
11665             return false;
11666         }
11667         var decl = symbol.valueDeclaration;
11668         return decl.kind === 244 || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer);
11669     }
11670     ts.isFunctionSymbol = isFunctionSymbol;
11671     function importFromModuleSpecifier(node) {
11672         return tryGetImportFromModuleSpecifier(node) || ts.Debug.failBadSyntaxKind(node.parent);
11673     }
11674     ts.importFromModuleSpecifier = importFromModuleSpecifier;
11675     function tryGetImportFromModuleSpecifier(node) {
11676         switch (node.parent.kind) {
11677             case 254:
11678             case 260:
11679                 return node.parent;
11680             case 265:
11681                 return node.parent.parent;
11682             case 196:
11683                 return isImportCall(node.parent) || isRequireCall(node.parent, false) ? node.parent : undefined;
11684             case 187:
11685                 ts.Debug.assert(ts.isStringLiteral(node));
11686                 return ts.tryCast(node.parent.parent, ts.isImportTypeNode);
11687             default:
11688                 return undefined;
11689         }
11690     }
11691     ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier;
11692     function getExternalModuleName(node) {
11693         switch (node.kind) {
11694             case 254:
11695             case 260:
11696                 return node.moduleSpecifier;
11697             case 253:
11698                 return node.moduleReference.kind === 265 ? node.moduleReference.expression : undefined;
11699             case 188:
11700                 return isLiteralImportTypeNode(node) ? node.argument.literal : undefined;
11701             default:
11702                 return ts.Debug.assertNever(node);
11703         }
11704     }
11705     ts.getExternalModuleName = getExternalModuleName;
11706     function getNamespaceDeclarationNode(node) {
11707         switch (node.kind) {
11708             case 254:
11709                 return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport);
11710             case 253:
11711                 return node;
11712             case 260:
11713                 return node.exportClause && ts.tryCast(node.exportClause, ts.isNamespaceExport);
11714             default:
11715                 return ts.Debug.assertNever(node);
11716         }
11717     }
11718     ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode;
11719     function isDefaultImport(node) {
11720         return node.kind === 254 && !!node.importClause && !!node.importClause.name;
11721     }
11722     ts.isDefaultImport = isDefaultImport;
11723     function forEachImportClauseDeclaration(node, action) {
11724         if (node.name) {
11725             var result = action(node);
11726             if (result)
11727                 return result;
11728         }
11729         if (node.namedBindings) {
11730             var result = ts.isNamespaceImport(node.namedBindings)
11731                 ? action(node.namedBindings)
11732                 : ts.forEach(node.namedBindings.elements, action);
11733             if (result)
11734                 return result;
11735         }
11736     }
11737     ts.forEachImportClauseDeclaration = forEachImportClauseDeclaration;
11738     function hasQuestionToken(node) {
11739         if (node) {
11740             switch (node.kind) {
11741                 case 156:
11742                 case 161:
11743                 case 160:
11744                 case 282:
11745                 case 281:
11746                 case 159:
11747                 case 158:
11748                     return node.questionToken !== undefined;
11749             }
11750         }
11751         return false;
11752     }
11753     ts.hasQuestionToken = hasQuestionToken;
11754     function isJSDocConstructSignature(node) {
11755         var param = ts.isJSDocFunctionType(node) ? ts.firstOrUndefined(node.parameters) : undefined;
11756         var name = ts.tryCast(param && param.name, ts.isIdentifier);
11757         return !!name && name.escapedText === "new";
11758     }
11759     ts.isJSDocConstructSignature = isJSDocConstructSignature;
11760     function isJSDocTypeAlias(node) {
11761         return node.kind === 322 || node.kind === 315 || node.kind === 316;
11762     }
11763     ts.isJSDocTypeAlias = isJSDocTypeAlias;
11764     function isTypeAlias(node) {
11765         return isJSDocTypeAlias(node) || ts.isTypeAliasDeclaration(node);
11766     }
11767     ts.isTypeAlias = isTypeAlias;
11768     function getSourceOfAssignment(node) {
11769         return ts.isExpressionStatement(node) &&
11770             ts.isBinaryExpression(node.expression) &&
11771             node.expression.operatorToken.kind === 62
11772             ? getRightMostAssignedExpression(node.expression)
11773             : undefined;
11774     }
11775     function getSourceOfDefaultedAssignment(node) {
11776         return ts.isExpressionStatement(node) &&
11777             ts.isBinaryExpression(node.expression) &&
11778             getAssignmentDeclarationKind(node.expression) !== 0 &&
11779             ts.isBinaryExpression(node.expression.right) &&
11780             (node.expression.right.operatorToken.kind === 56 || node.expression.right.operatorToken.kind === 60)
11781             ? node.expression.right.right
11782             : undefined;
11783     }
11784     function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) {
11785         switch (node.kind) {
11786             case 225:
11787                 var v = getSingleVariableOfVariableStatement(node);
11788                 return v && v.initializer;
11789             case 159:
11790                 return node.initializer;
11791             case 281:
11792                 return node.initializer;
11793         }
11794     }
11795     ts.getSingleInitializerOfVariableStatementOrPropertyDeclaration = getSingleInitializerOfVariableStatementOrPropertyDeclaration;
11796     function getSingleVariableOfVariableStatement(node) {
11797         return ts.isVariableStatement(node) ? ts.firstOrUndefined(node.declarationList.declarations) : undefined;
11798     }
11799     function getNestedModuleDeclaration(node) {
11800         return ts.isModuleDeclaration(node) &&
11801             node.body &&
11802             node.body.kind === 249
11803             ? node.body
11804             : undefined;
11805     }
11806     function getJSDocCommentsAndTags(hostNode) {
11807         var result;
11808         if (isVariableLike(hostNode) && ts.hasInitializer(hostNode) && ts.hasJSDocNodes(hostNode.initializer)) {
11809             result = ts.append(result, ts.last(hostNode.initializer.jsDoc));
11810         }
11811         var node = hostNode;
11812         while (node && node.parent) {
11813             if (ts.hasJSDocNodes(node)) {
11814                 result = ts.append(result, ts.last(node.jsDoc));
11815             }
11816             if (node.kind === 156) {
11817                 result = ts.addRange(result, ts.getJSDocParameterTags(node));
11818                 break;
11819             }
11820             if (node.kind === 155) {
11821                 result = ts.addRange(result, ts.getJSDocTypeParameterTags(node));
11822                 break;
11823             }
11824             node = getNextJSDocCommentLocation(node);
11825         }
11826         return result || ts.emptyArray;
11827     }
11828     ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags;
11829     function getNextJSDocCommentLocation(node) {
11830         var parent = node.parent;
11831         if (parent.kind === 281 ||
11832             parent.kind === 259 ||
11833             parent.kind === 159 ||
11834             parent.kind === 226 && node.kind === 194 ||
11835             getNestedModuleDeclaration(parent) ||
11836             ts.isBinaryExpression(node) && node.operatorToken.kind === 62) {
11837             return parent;
11838         }
11839         else if (parent.parent &&
11840             (getSingleVariableOfVariableStatement(parent.parent) === node ||
11841                 ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62)) {
11842             return parent.parent;
11843         }
11844         else if (parent.parent && parent.parent.parent &&
11845             (getSingleVariableOfVariableStatement(parent.parent.parent) ||
11846                 getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent.parent.parent) === node ||
11847                 getSourceOfDefaultedAssignment(parent.parent.parent))) {
11848             return parent.parent.parent;
11849         }
11850     }
11851     function getParameterSymbolFromJSDoc(node) {
11852         if (node.symbol) {
11853             return node.symbol;
11854         }
11855         if (!ts.isIdentifier(node.name)) {
11856             return undefined;
11857         }
11858         var name = node.name.escapedText;
11859         var decl = getHostSignatureFromJSDoc(node);
11860         if (!decl) {
11861             return undefined;
11862         }
11863         var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 75 && p.name.escapedText === name; });
11864         return parameter && parameter.symbol;
11865     }
11866     ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc;
11867     function getHostSignatureFromJSDoc(node) {
11868         var host = getEffectiveJSDocHost(node);
11869         return host && ts.isFunctionLike(host) ? host : undefined;
11870     }
11871     ts.getHostSignatureFromJSDoc = getHostSignatureFromJSDoc;
11872     function getEffectiveJSDocHost(node) {
11873         var host = getJSDocHost(node);
11874         var decl = getSourceOfDefaultedAssignment(host) ||
11875             getSourceOfAssignment(host) ||
11876             getSingleInitializerOfVariableStatementOrPropertyDeclaration(host) ||
11877             getSingleVariableOfVariableStatement(host) ||
11878             getNestedModuleDeclaration(host) ||
11879             host;
11880         return decl;
11881     }
11882     ts.getEffectiveJSDocHost = getEffectiveJSDocHost;
11883     function getJSDocHost(node) {
11884         return ts.Debug.checkDefined(findAncestor(node.parent, ts.isJSDoc)).parent;
11885     }
11886     ts.getJSDocHost = getJSDocHost;
11887     function getTypeParameterFromJsDoc(node) {
11888         var name = node.name.escapedText;
11889         var typeParameters = node.parent.parent.parent.typeParameters;
11890         return typeParameters && ts.find(typeParameters, function (p) { return p.name.escapedText === name; });
11891     }
11892     ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc;
11893     function hasRestParameter(s) {
11894         var last = ts.lastOrUndefined(s.parameters);
11895         return !!last && isRestParameter(last);
11896     }
11897     ts.hasRestParameter = hasRestParameter;
11898     function isRestParameter(node) {
11899         var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type;
11900         return node.dotDotDotToken !== undefined || !!type && type.kind === 301;
11901     }
11902     ts.isRestParameter = isRestParameter;
11903     function hasTypeArguments(node) {
11904         return !!node.typeArguments;
11905     }
11906     ts.hasTypeArguments = hasTypeArguments;
11907     function getAssignmentTargetKind(node) {
11908         var parent = node.parent;
11909         while (true) {
11910             switch (parent.kind) {
11911                 case 209:
11912                     var binaryOperator = parent.operatorToken.kind;
11913                     return isAssignmentOperator(binaryOperator) && parent.left === node ?
11914                         binaryOperator === 62 ? 1 : 2 :
11915                         0;
11916                 case 207:
11917                 case 208:
11918                     var unaryOperator = parent.operator;
11919                     return unaryOperator === 45 || unaryOperator === 46 ? 2 : 0;
11920                 case 231:
11921                 case 232:
11922                     return parent.initializer === node ? 1 : 0;
11923                 case 200:
11924                 case 192:
11925                 case 213:
11926                 case 218:
11927                     node = parent;
11928                     break;
11929                 case 282:
11930                     if (parent.name !== node) {
11931                         return 0;
11932                     }
11933                     node = parent.parent;
11934                     break;
11935                 case 281:
11936                     if (parent.name === node) {
11937                         return 0;
11938                     }
11939                     node = parent.parent;
11940                     break;
11941                 default:
11942                     return 0;
11943             }
11944             parent = node.parent;
11945         }
11946     }
11947     ts.getAssignmentTargetKind = getAssignmentTargetKind;
11948     function isAssignmentTarget(node) {
11949         return getAssignmentTargetKind(node) !== 0;
11950     }
11951     ts.isAssignmentTarget = isAssignmentTarget;
11952     function isNodeWithPossibleHoistedDeclaration(node) {
11953         switch (node.kind) {
11954             case 223:
11955             case 225:
11956             case 236:
11957             case 227:
11958             case 237:
11959             case 251:
11960             case 277:
11961             case 278:
11962             case 238:
11963             case 230:
11964             case 231:
11965             case 232:
11966             case 228:
11967             case 229:
11968             case 240:
11969             case 280:
11970                 return true;
11971         }
11972         return false;
11973     }
11974     ts.isNodeWithPossibleHoistedDeclaration = isNodeWithPossibleHoistedDeclaration;
11975     function isValueSignatureDeclaration(node) {
11976         return ts.isFunctionExpression(node) || ts.isArrowFunction(node) || ts.isMethodOrAccessor(node) || ts.isFunctionDeclaration(node) || ts.isConstructorDeclaration(node);
11977     }
11978     ts.isValueSignatureDeclaration = isValueSignatureDeclaration;
11979     function walkUp(node, kind) {
11980         while (node && node.kind === kind) {
11981             node = node.parent;
11982         }
11983         return node;
11984     }
11985     function walkUpParenthesizedTypes(node) {
11986         return walkUp(node, 182);
11987     }
11988     ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes;
11989     function walkUpParenthesizedExpressions(node) {
11990         return walkUp(node, 200);
11991     }
11992     ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions;
11993     function skipParentheses(node) {
11994         return ts.skipOuterExpressions(node, 1);
11995     }
11996     ts.skipParentheses = skipParentheses;
11997     function skipParenthesesUp(node) {
11998         while (node.kind === 200) {
11999             node = node.parent;
12000         }
12001         return node;
12002     }
12003     function isDeleteTarget(node) {
12004         if (node.kind !== 194 && node.kind !== 195) {
12005             return false;
12006         }
12007         node = walkUpParenthesizedExpressions(node.parent);
12008         return node && node.kind === 203;
12009     }
12010     ts.isDeleteTarget = isDeleteTarget;
12011     function isNodeDescendantOf(node, ancestor) {
12012         while (node) {
12013             if (node === ancestor)
12014                 return true;
12015             node = node.parent;
12016         }
12017         return false;
12018     }
12019     ts.isNodeDescendantOf = isNodeDescendantOf;
12020     function isDeclarationName(name) {
12021         return !ts.isSourceFile(name) && !ts.isBindingPattern(name) && ts.isDeclaration(name.parent) && name.parent.name === name;
12022     }
12023     ts.isDeclarationName = isDeclarationName;
12024     function getDeclarationFromName(name) {
12025         var parent = name.parent;
12026         switch (name.kind) {
12027             case 10:
12028             case 14:
12029             case 8:
12030                 if (ts.isComputedPropertyName(parent))
12031                     return parent.parent;
12032             case 75:
12033                 if (ts.isDeclaration(parent)) {
12034                     return parent.name === name ? parent : undefined;
12035                 }
12036                 else if (ts.isQualifiedName(parent)) {
12037                     var tag = parent.parent;
12038                     return ts.isJSDocParameterTag(tag) && tag.name === parent ? tag : undefined;
12039                 }
12040                 else {
12041                     var binExp = parent.parent;
12042                     return ts.isBinaryExpression(binExp) &&
12043                         getAssignmentDeclarationKind(binExp) !== 0 &&
12044                         (binExp.left.symbol || binExp.symbol) &&
12045                         ts.getNameOfDeclaration(binExp) === name
12046                         ? binExp
12047                         : undefined;
12048                 }
12049             case 76:
12050                 return ts.isDeclaration(parent) && parent.name === name ? parent : undefined;
12051             default:
12052                 return undefined;
12053         }
12054     }
12055     ts.getDeclarationFromName = getDeclarationFromName;
12056     function isLiteralComputedPropertyDeclarationName(node) {
12057         return isStringOrNumericLiteralLike(node) &&
12058             node.parent.kind === 154 &&
12059             ts.isDeclaration(node.parent.parent);
12060     }
12061     ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName;
12062     function isIdentifierName(node) {
12063         var parent = node.parent;
12064         switch (parent.kind) {
12065             case 159:
12066             case 158:
12067             case 161:
12068             case 160:
12069             case 163:
12070             case 164:
12071             case 284:
12072             case 281:
12073             case 194:
12074                 return parent.name === node;
12075             case 153:
12076                 if (parent.right === node) {
12077                     while (parent.kind === 153) {
12078                         parent = parent.parent;
12079                     }
12080                     return parent.kind === 172 || parent.kind === 169;
12081                 }
12082                 return false;
12083             case 191:
12084             case 258:
12085                 return parent.propertyName === node;
12086             case 263:
12087             case 273:
12088                 return true;
12089         }
12090         return false;
12091     }
12092     ts.isIdentifierName = isIdentifierName;
12093     function isAliasSymbolDeclaration(node) {
12094         return node.kind === 253 ||
12095             node.kind === 252 ||
12096             node.kind === 255 && !!node.name ||
12097             node.kind === 256 ||
12098             node.kind === 262 ||
12099             node.kind === 258 ||
12100             node.kind === 263 ||
12101             node.kind === 259 && exportAssignmentIsAlias(node) ||
12102             ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 && exportAssignmentIsAlias(node) ||
12103             ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 && isAliasableExpression(node.parent.right) ||
12104             node.kind === 282 ||
12105             node.kind === 281 && isAliasableExpression(node.initializer);
12106     }
12107     ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration;
12108     function getAliasDeclarationFromName(node) {
12109         switch (node.parent.kind) {
12110             case 255:
12111             case 258:
12112             case 256:
12113             case 263:
12114             case 259:
12115             case 253:
12116                 return node.parent;
12117             case 153:
12118                 do {
12119                     node = node.parent;
12120                 } while (node.parent.kind === 153);
12121                 return getAliasDeclarationFromName(node);
12122         }
12123     }
12124     ts.getAliasDeclarationFromName = getAliasDeclarationFromName;
12125     function isAliasableExpression(e) {
12126         return isEntityNameExpression(e) || ts.isClassExpression(e);
12127     }
12128     ts.isAliasableExpression = isAliasableExpression;
12129     function exportAssignmentIsAlias(node) {
12130         var e = getExportAssignmentExpression(node);
12131         return isAliasableExpression(e);
12132     }
12133     ts.exportAssignmentIsAlias = exportAssignmentIsAlias;
12134     function getExportAssignmentExpression(node) {
12135         return ts.isExportAssignment(node) ? node.expression : node.right;
12136     }
12137     ts.getExportAssignmentExpression = getExportAssignmentExpression;
12138     function getPropertyAssignmentAliasLikeExpression(node) {
12139         return node.kind === 282 ? node.name : node.kind === 281 ? node.initializer :
12140             node.parent.right;
12141     }
12142     ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression;
12143     function getEffectiveBaseTypeNode(node) {
12144         var baseType = getClassExtendsHeritageElement(node);
12145         if (baseType && isInJSFile(node)) {
12146             var tag = ts.getJSDocAugmentsTag(node);
12147             if (tag) {
12148                 return tag.class;
12149             }
12150         }
12151         return baseType;
12152     }
12153     ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode;
12154     function getClassExtendsHeritageElement(node) {
12155         var heritageClause = getHeritageClause(node.heritageClauses, 90);
12156         return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined;
12157     }
12158     ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement;
12159     function getEffectiveImplementsTypeNodes(node) {
12160         if (isInJSFile(node)) {
12161             return ts.getJSDocImplementsTags(node).map(function (n) { return n.class; });
12162         }
12163         else {
12164             var heritageClause = getHeritageClause(node.heritageClauses, 113);
12165             return heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.types;
12166         }
12167     }
12168     ts.getEffectiveImplementsTypeNodes = getEffectiveImplementsTypeNodes;
12169     function getAllSuperTypeNodes(node) {
12170         return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray :
12171             ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getEffectiveImplementsTypeNodes(node)) || ts.emptyArray :
12172                 ts.emptyArray;
12173     }
12174     ts.getAllSuperTypeNodes = getAllSuperTypeNodes;
12175     function getInterfaceBaseTypeNodes(node) {
12176         var heritageClause = getHeritageClause(node.heritageClauses, 90);
12177         return heritageClause ? heritageClause.types : undefined;
12178     }
12179     ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes;
12180     function getHeritageClause(clauses, kind) {
12181         if (clauses) {
12182             for (var _i = 0, clauses_1 = clauses; _i < clauses_1.length; _i++) {
12183                 var clause = clauses_1[_i];
12184                 if (clause.token === kind) {
12185                     return clause;
12186                 }
12187             }
12188         }
12189         return undefined;
12190     }
12191     ts.getHeritageClause = getHeritageClause;
12192     function getAncestor(node, kind) {
12193         while (node) {
12194             if (node.kind === kind) {
12195                 return node;
12196             }
12197             node = node.parent;
12198         }
12199         return undefined;
12200     }
12201     ts.getAncestor = getAncestor;
12202     function isKeyword(token) {
12203         return 77 <= token && token <= 152;
12204     }
12205     ts.isKeyword = isKeyword;
12206     function isContextualKeyword(token) {
12207         return 122 <= token && token <= 152;
12208     }
12209     ts.isContextualKeyword = isContextualKeyword;
12210     function isNonContextualKeyword(token) {
12211         return isKeyword(token) && !isContextualKeyword(token);
12212     }
12213     ts.isNonContextualKeyword = isNonContextualKeyword;
12214     function isFutureReservedKeyword(token) {
12215         return 113 <= token && token <= 121;
12216     }
12217     ts.isFutureReservedKeyword = isFutureReservedKeyword;
12218     function isStringANonContextualKeyword(name) {
12219         var token = ts.stringToToken(name);
12220         return token !== undefined && isNonContextualKeyword(token);
12221     }
12222     ts.isStringANonContextualKeyword = isStringANonContextualKeyword;
12223     function isStringAKeyword(name) {
12224         var token = ts.stringToToken(name);
12225         return token !== undefined && isKeyword(token);
12226     }
12227     ts.isStringAKeyword = isStringAKeyword;
12228     function isIdentifierANonContextualKeyword(_a) {
12229         var originalKeywordKind = _a.originalKeywordKind;
12230         return !!originalKeywordKind && !isContextualKeyword(originalKeywordKind);
12231     }
12232     ts.isIdentifierANonContextualKeyword = isIdentifierANonContextualKeyword;
12233     function isTrivia(token) {
12234         return 2 <= token && token <= 7;
12235     }
12236     ts.isTrivia = isTrivia;
12237     function getFunctionFlags(node) {
12238         if (!node) {
12239             return 4;
12240         }
12241         var flags = 0;
12242         switch (node.kind) {
12243             case 244:
12244             case 201:
12245             case 161:
12246                 if (node.asteriskToken) {
12247                     flags |= 1;
12248                 }
12249             case 202:
12250                 if (hasModifier(node, 256)) {
12251                     flags |= 2;
12252                 }
12253                 break;
12254         }
12255         if (!node.body) {
12256             flags |= 4;
12257         }
12258         return flags;
12259     }
12260     ts.getFunctionFlags = getFunctionFlags;
12261     function isAsyncFunction(node) {
12262         switch (node.kind) {
12263             case 244:
12264             case 201:
12265             case 202:
12266             case 161:
12267                 return node.body !== undefined
12268                     && node.asteriskToken === undefined
12269                     && hasModifier(node, 256);
12270         }
12271         return false;
12272     }
12273     ts.isAsyncFunction = isAsyncFunction;
12274     function isStringOrNumericLiteralLike(node) {
12275         return ts.isStringLiteralLike(node) || ts.isNumericLiteral(node);
12276     }
12277     ts.isStringOrNumericLiteralLike = isStringOrNumericLiteralLike;
12278     function isSignedNumericLiteral(node) {
12279         return ts.isPrefixUnaryExpression(node) && (node.operator === 39 || node.operator === 40) && ts.isNumericLiteral(node.operand);
12280     }
12281     ts.isSignedNumericLiteral = isSignedNumericLiteral;
12282     function hasDynamicName(declaration) {
12283         var name = ts.getNameOfDeclaration(declaration);
12284         return !!name && isDynamicName(name);
12285     }
12286     ts.hasDynamicName = hasDynamicName;
12287     function isDynamicName(name) {
12288         if (!(name.kind === 154 || name.kind === 195)) {
12289             return false;
12290         }
12291         var expr = ts.isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression;
12292         return !isStringOrNumericLiteralLike(expr) &&
12293             !isSignedNumericLiteral(expr) &&
12294             !isWellKnownSymbolSyntactically(expr);
12295     }
12296     ts.isDynamicName = isDynamicName;
12297     function isWellKnownSymbolSyntactically(node) {
12298         return ts.isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression);
12299     }
12300     ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically;
12301     function getPropertyNameForPropertyNameNode(name) {
12302         switch (name.kind) {
12303             case 75:
12304             case 76:
12305                 return name.escapedText;
12306             case 10:
12307             case 8:
12308                 return ts.escapeLeadingUnderscores(name.text);
12309             case 154:
12310                 var nameExpression = name.expression;
12311                 if (isWellKnownSymbolSyntactically(nameExpression)) {
12312                     return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name));
12313                 }
12314                 else if (isStringOrNumericLiteralLike(nameExpression)) {
12315                     return ts.escapeLeadingUnderscores(nameExpression.text);
12316                 }
12317                 return undefined;
12318             default:
12319                 return ts.Debug.assertNever(name);
12320         }
12321     }
12322     ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode;
12323     function isPropertyNameLiteral(node) {
12324         switch (node.kind) {
12325             case 75:
12326             case 10:
12327             case 14:
12328             case 8:
12329                 return true;
12330             default:
12331                 return false;
12332         }
12333     }
12334     ts.isPropertyNameLiteral = isPropertyNameLiteral;
12335     function getTextOfIdentifierOrLiteral(node) {
12336         return ts.isIdentifierOrPrivateIdentifier(node) ? ts.idText(node) : node.text;
12337     }
12338     ts.getTextOfIdentifierOrLiteral = getTextOfIdentifierOrLiteral;
12339     function getEscapedTextOfIdentifierOrLiteral(node) {
12340         return ts.isIdentifierOrPrivateIdentifier(node) ? node.escapedText : ts.escapeLeadingUnderscores(node.text);
12341     }
12342     ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral;
12343     function getPropertyNameForUniqueESSymbol(symbol) {
12344         return "__@" + ts.getSymbolId(symbol) + "@" + symbol.escapedName;
12345     }
12346     ts.getPropertyNameForUniqueESSymbol = getPropertyNameForUniqueESSymbol;
12347     function getPropertyNameForKnownSymbolName(symbolName) {
12348         return "__@" + symbolName;
12349     }
12350     ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName;
12351     function getSymbolNameForPrivateIdentifier(containingClassSymbol, description) {
12352         return "__#" + ts.getSymbolId(containingClassSymbol) + "@" + description;
12353     }
12354     ts.getSymbolNameForPrivateIdentifier = getSymbolNameForPrivateIdentifier;
12355     function isKnownSymbol(symbol) {
12356         return ts.startsWith(symbol.escapedName, "__@");
12357     }
12358     ts.isKnownSymbol = isKnownSymbol;
12359     function isESSymbolIdentifier(node) {
12360         return node.kind === 75 && node.escapedText === "Symbol";
12361     }
12362     ts.isESSymbolIdentifier = isESSymbolIdentifier;
12363     function isPushOrUnshiftIdentifier(node) {
12364         return node.escapedText === "push" || node.escapedText === "unshift";
12365     }
12366     ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier;
12367     function isParameterDeclaration(node) {
12368         var root = getRootDeclaration(node);
12369         return root.kind === 156;
12370     }
12371     ts.isParameterDeclaration = isParameterDeclaration;
12372     function getRootDeclaration(node) {
12373         while (node.kind === 191) {
12374             node = node.parent.parent;
12375         }
12376         return node;
12377     }
12378     ts.getRootDeclaration = getRootDeclaration;
12379     function nodeStartsNewLexicalEnvironment(node) {
12380         var kind = node.kind;
12381         return kind === 162
12382             || kind === 201
12383             || kind === 244
12384             || kind === 202
12385             || kind === 161
12386             || kind === 163
12387             || kind === 164
12388             || kind === 249
12389             || kind === 290;
12390     }
12391     ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment;
12392     function nodeIsSynthesized(range) {
12393         return positionIsSynthesized(range.pos)
12394             || positionIsSynthesized(range.end);
12395     }
12396     ts.nodeIsSynthesized = nodeIsSynthesized;
12397     function getOriginalSourceFile(sourceFile) {
12398         return ts.getParseTreeNode(sourceFile, ts.isSourceFile) || sourceFile;
12399     }
12400     ts.getOriginalSourceFile = getOriginalSourceFile;
12401     function getExpressionAssociativity(expression) {
12402         var operator = getOperator(expression);
12403         var hasArguments = expression.kind === 197 && expression.arguments !== undefined;
12404         return getOperatorAssociativity(expression.kind, operator, hasArguments);
12405     }
12406     ts.getExpressionAssociativity = getExpressionAssociativity;
12407     function getOperatorAssociativity(kind, operator, hasArguments) {
12408         switch (kind) {
12409             case 197:
12410                 return hasArguments ? 0 : 1;
12411             case 207:
12412             case 204:
12413             case 205:
12414             case 203:
12415             case 206:
12416             case 210:
12417             case 212:
12418                 return 1;
12419             case 209:
12420                 switch (operator) {
12421                     case 42:
12422                     case 62:
12423                     case 63:
12424                     case 64:
12425                     case 66:
12426                     case 65:
12427                     case 67:
12428                     case 68:
12429                     case 69:
12430                     case 70:
12431                     case 71:
12432                     case 72:
12433                     case 74:
12434                     case 73:
12435                         return 1;
12436                 }
12437         }
12438         return 0;
12439     }
12440     ts.getOperatorAssociativity = getOperatorAssociativity;
12441     function getExpressionPrecedence(expression) {
12442         var operator = getOperator(expression);
12443         var hasArguments = expression.kind === 197 && expression.arguments !== undefined;
12444         return getOperatorPrecedence(expression.kind, operator, hasArguments);
12445     }
12446     ts.getExpressionPrecedence = getExpressionPrecedence;
12447     function getOperator(expression) {
12448         if (expression.kind === 209) {
12449             return expression.operatorToken.kind;
12450         }
12451         else if (expression.kind === 207 || expression.kind === 208) {
12452             return expression.operator;
12453         }
12454         else {
12455             return expression.kind;
12456         }
12457     }
12458     ts.getOperator = getOperator;
12459     function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) {
12460         switch (nodeKind) {
12461             case 327:
12462                 return 0;
12463             case 213:
12464                 return 1;
12465             case 212:
12466                 return 2;
12467             case 210:
12468                 return 4;
12469             case 209:
12470                 switch (operatorKind) {
12471                     case 27:
12472                         return 0;
12473                     case 62:
12474                     case 63:
12475                     case 64:
12476                     case 66:
12477                     case 65:
12478                     case 67:
12479                     case 68:
12480                     case 69:
12481                     case 70:
12482                     case 71:
12483                     case 72:
12484                     case 74:
12485                     case 73:
12486                         return 3;
12487                     default:
12488                         return getBinaryOperatorPrecedence(operatorKind);
12489                 }
12490             case 207:
12491             case 204:
12492             case 205:
12493             case 203:
12494             case 206:
12495                 return 16;
12496             case 208:
12497                 return 17;
12498             case 196:
12499                 return 18;
12500             case 197:
12501                 return hasArguments ? 19 : 18;
12502             case 198:
12503             case 194:
12504             case 195:
12505                 return 19;
12506             case 104:
12507             case 102:
12508             case 75:
12509             case 100:
12510             case 106:
12511             case 91:
12512             case 8:
12513             case 9:
12514             case 10:
12515             case 192:
12516             case 193:
12517             case 201:
12518             case 202:
12519             case 214:
12520             case 266:
12521             case 267:
12522             case 270:
12523             case 13:
12524             case 14:
12525             case 211:
12526             case 200:
12527             case 215:
12528                 return 20;
12529             default:
12530                 return -1;
12531         }
12532     }
12533     ts.getOperatorPrecedence = getOperatorPrecedence;
12534     function getBinaryOperatorPrecedence(kind) {
12535         switch (kind) {
12536             case 60:
12537                 return 4;
12538             case 56:
12539                 return 5;
12540             case 55:
12541                 return 6;
12542             case 51:
12543                 return 7;
12544             case 52:
12545                 return 8;
12546             case 50:
12547                 return 9;
12548             case 34:
12549             case 35:
12550             case 36:
12551             case 37:
12552                 return 10;
12553             case 29:
12554             case 31:
12555             case 32:
12556             case 33:
12557             case 98:
12558             case 97:
12559             case 123:
12560                 return 11;
12561             case 47:
12562             case 48:
12563             case 49:
12564                 return 12;
12565             case 39:
12566             case 40:
12567                 return 13;
12568             case 41:
12569             case 43:
12570             case 44:
12571                 return 14;
12572             case 42:
12573                 return 15;
12574         }
12575         return -1;
12576     }
12577     ts.getBinaryOperatorPrecedence = getBinaryOperatorPrecedence;
12578     function createDiagnosticCollection() {
12579         var nonFileDiagnostics = [];
12580         var filesWithDiagnostics = [];
12581         var fileDiagnostics = ts.createMap();
12582         var hasReadNonFileDiagnostics = false;
12583         return {
12584             add: add,
12585             lookup: lookup,
12586             getGlobalDiagnostics: getGlobalDiagnostics,
12587             getDiagnostics: getDiagnostics,
12588             reattachFileDiagnostics: reattachFileDiagnostics
12589         };
12590         function reattachFileDiagnostics(newFile) {
12591             ts.forEach(fileDiagnostics.get(newFile.fileName), function (diagnostic) { return diagnostic.file = newFile; });
12592         }
12593         function lookup(diagnostic) {
12594             var diagnostics;
12595             if (diagnostic.file) {
12596                 diagnostics = fileDiagnostics.get(diagnostic.file.fileName);
12597             }
12598             else {
12599                 diagnostics = nonFileDiagnostics;
12600             }
12601             if (!diagnostics) {
12602                 return undefined;
12603             }
12604             var result = ts.binarySearch(diagnostics, diagnostic, ts.identity, compareDiagnosticsSkipRelatedInformation);
12605             if (result >= 0) {
12606                 return diagnostics[result];
12607             }
12608             return undefined;
12609         }
12610         function add(diagnostic) {
12611             var diagnostics;
12612             if (diagnostic.file) {
12613                 diagnostics = fileDiagnostics.get(diagnostic.file.fileName);
12614                 if (!diagnostics) {
12615                     diagnostics = [];
12616                     fileDiagnostics.set(diagnostic.file.fileName, diagnostics);
12617                     ts.insertSorted(filesWithDiagnostics, diagnostic.file.fileName, ts.compareStringsCaseSensitive);
12618                 }
12619             }
12620             else {
12621                 if (hasReadNonFileDiagnostics) {
12622                     hasReadNonFileDiagnostics = false;
12623                     nonFileDiagnostics = nonFileDiagnostics.slice();
12624                 }
12625                 diagnostics = nonFileDiagnostics;
12626             }
12627             ts.insertSorted(diagnostics, diagnostic, compareDiagnostics);
12628         }
12629         function getGlobalDiagnostics() {
12630             hasReadNonFileDiagnostics = true;
12631             return nonFileDiagnostics;
12632         }
12633         function getDiagnostics(fileName) {
12634             if (fileName) {
12635                 return fileDiagnostics.get(fileName) || [];
12636             }
12637             var fileDiags = ts.flatMapToMutable(filesWithDiagnostics, function (f) { return fileDiagnostics.get(f); });
12638             if (!nonFileDiagnostics.length) {
12639                 return fileDiags;
12640             }
12641             fileDiags.unshift.apply(fileDiags, nonFileDiagnostics);
12642             return fileDiags;
12643         }
12644     }
12645     ts.createDiagnosticCollection = createDiagnosticCollection;
12646     var templateSubstitutionRegExp = /\$\{/g;
12647     function escapeTemplateSubstitution(str) {
12648         return str.replace(templateSubstitutionRegExp, "\\${");
12649     }
12650     function hasInvalidEscape(template) {
12651         return template && !!(ts.isNoSubstitutionTemplateLiteral(template)
12652             ? template.templateFlags
12653             : (template.head.templateFlags || ts.some(template.templateSpans, function (span) { return !!span.literal.templateFlags; })));
12654     }
12655     ts.hasInvalidEscape = hasInvalidEscape;
12656     var doubleQuoteEscapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g;
12657     var singleQuoteEscapedCharsRegExp = /[\\\'\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g;
12658     var backtickQuoteEscapedCharsRegExp = /[\\`]/g;
12659     var escapedCharsMap = ts.createMapFromTemplate({
12660         "\t": "\\t",
12661         "\v": "\\v",
12662         "\f": "\\f",
12663         "\b": "\\b",
12664         "\r": "\\r",
12665         "\n": "\\n",
12666         "\\": "\\\\",
12667         "\"": "\\\"",
12668         "\'": "\\\'",
12669         "\`": "\\\`",
12670         "\u2028": "\\u2028",
12671         "\u2029": "\\u2029",
12672         "\u0085": "\\u0085"
12673     });
12674     function encodeUtf16EscapeSequence(charCode) {
12675         var hexCharCode = charCode.toString(16).toUpperCase();
12676         var paddedHexCode = ("0000" + hexCharCode).slice(-4);
12677         return "\\u" + paddedHexCode;
12678     }
12679     function getReplacement(c, offset, input) {
12680         if (c.charCodeAt(0) === 0) {
12681             var lookAhead = input.charCodeAt(offset + c.length);
12682             if (lookAhead >= 48 && lookAhead <= 57) {
12683                 return "\\x00";
12684             }
12685             return "\\0";
12686         }
12687         return escapedCharsMap.get(c) || encodeUtf16EscapeSequence(c.charCodeAt(0));
12688     }
12689     function escapeString(s, quoteChar) {
12690         var escapedCharsRegExp = quoteChar === 96 ? backtickQuoteEscapedCharsRegExp :
12691             quoteChar === 39 ? singleQuoteEscapedCharsRegExp :
12692                 doubleQuoteEscapedCharsRegExp;
12693         return s.replace(escapedCharsRegExp, getReplacement);
12694     }
12695     ts.escapeString = escapeString;
12696     var nonAsciiCharacters = /[^\u0000-\u007F]/g;
12697     function escapeNonAsciiString(s, quoteChar) {
12698         s = escapeString(s, quoteChar);
12699         return nonAsciiCharacters.test(s) ?
12700             s.replace(nonAsciiCharacters, function (c) { return encodeUtf16EscapeSequence(c.charCodeAt(0)); }) :
12701             s;
12702     }
12703     ts.escapeNonAsciiString = escapeNonAsciiString;
12704     var jsxDoubleQuoteEscapedCharsRegExp = /[\"\u0000-\u001f\u2028\u2029\u0085]/g;
12705     var jsxSingleQuoteEscapedCharsRegExp = /[\'\u0000-\u001f\u2028\u2029\u0085]/g;
12706     var jsxEscapedCharsMap = ts.createMapFromTemplate({
12707         "\"": "&quot;",
12708         "\'": "&apos;"
12709     });
12710     function encodeJsxCharacterEntity(charCode) {
12711         var hexCharCode = charCode.toString(16).toUpperCase();
12712         return "&#x" + hexCharCode + ";";
12713     }
12714     function getJsxAttributeStringReplacement(c) {
12715         if (c.charCodeAt(0) === 0) {
12716             return "&#0;";
12717         }
12718         return jsxEscapedCharsMap.get(c) || encodeJsxCharacterEntity(c.charCodeAt(0));
12719     }
12720     function escapeJsxAttributeString(s, quoteChar) {
12721         var escapedCharsRegExp = quoteChar === 39 ? jsxSingleQuoteEscapedCharsRegExp :
12722             jsxDoubleQuoteEscapedCharsRegExp;
12723         return s.replace(escapedCharsRegExp, getJsxAttributeStringReplacement);
12724     }
12725     ts.escapeJsxAttributeString = escapeJsxAttributeString;
12726     function stripQuotes(name) {
12727         var length = name.length;
12728         if (length >= 2 && name.charCodeAt(0) === name.charCodeAt(length - 1) && isQuoteOrBacktick(name.charCodeAt(0))) {
12729             return name.substring(1, length - 1);
12730         }
12731         return name;
12732     }
12733     ts.stripQuotes = stripQuotes;
12734     function isQuoteOrBacktick(charCode) {
12735         return charCode === 39 ||
12736             charCode === 34 ||
12737             charCode === 96;
12738     }
12739     function isIntrinsicJsxName(name) {
12740         var ch = name.charCodeAt(0);
12741         return (ch >= 97 && ch <= 122) || ts.stringContains(name, "-");
12742     }
12743     ts.isIntrinsicJsxName = isIntrinsicJsxName;
12744     var indentStrings = ["", "    "];
12745     function getIndentString(level) {
12746         if (indentStrings[level] === undefined) {
12747             indentStrings[level] = getIndentString(level - 1) + indentStrings[1];
12748         }
12749         return indentStrings[level];
12750     }
12751     ts.getIndentString = getIndentString;
12752     function getIndentSize() {
12753         return indentStrings[1].length;
12754     }
12755     ts.getIndentSize = getIndentSize;
12756     function createTextWriter(newLine) {
12757         var output;
12758         var indent;
12759         var lineStart;
12760         var lineCount;
12761         var linePos;
12762         var hasTrailingComment = false;
12763         function updateLineCountAndPosFor(s) {
12764             var lineStartsOfS = ts.computeLineStarts(s);
12765             if (lineStartsOfS.length > 1) {
12766                 lineCount = lineCount + lineStartsOfS.length - 1;
12767                 linePos = output.length - s.length + ts.last(lineStartsOfS);
12768                 lineStart = (linePos - output.length) === 0;
12769             }
12770             else {
12771                 lineStart = false;
12772             }
12773         }
12774         function writeText(s) {
12775             if (s && s.length) {
12776                 if (lineStart) {
12777                     s = getIndentString(indent) + s;
12778                     lineStart = false;
12779                 }
12780                 output += s;
12781                 updateLineCountAndPosFor(s);
12782             }
12783         }
12784         function write(s) {
12785             if (s)
12786                 hasTrailingComment = false;
12787             writeText(s);
12788         }
12789         function writeComment(s) {
12790             if (s)
12791                 hasTrailingComment = true;
12792             writeText(s);
12793         }
12794         function reset() {
12795             output = "";
12796             indent = 0;
12797             lineStart = true;
12798             lineCount = 0;
12799             linePos = 0;
12800             hasTrailingComment = false;
12801         }
12802         function rawWrite(s) {
12803             if (s !== undefined) {
12804                 output += s;
12805                 updateLineCountAndPosFor(s);
12806                 hasTrailingComment = false;
12807             }
12808         }
12809         function writeLiteral(s) {
12810             if (s && s.length) {
12811                 write(s);
12812             }
12813         }
12814         function writeLine(force) {
12815             if (!lineStart || force) {
12816                 output += newLine;
12817                 lineCount++;
12818                 linePos = output.length;
12819                 lineStart = true;
12820                 hasTrailingComment = false;
12821             }
12822         }
12823         function getTextPosWithWriteLine() {
12824             return lineStart ? output.length : (output.length + newLine.length);
12825         }
12826         reset();
12827         return {
12828             write: write,
12829             rawWrite: rawWrite,
12830             writeLiteral: writeLiteral,
12831             writeLine: writeLine,
12832             increaseIndent: function () { indent++; },
12833             decreaseIndent: function () { indent--; },
12834             getIndent: function () { return indent; },
12835             getTextPos: function () { return output.length; },
12836             getLine: function () { return lineCount; },
12837             getColumn: function () { return lineStart ? indent * getIndentSize() : output.length - linePos; },
12838             getText: function () { return output; },
12839             isAtStartOfLine: function () { return lineStart; },
12840             hasTrailingComment: function () { return hasTrailingComment; },
12841             hasTrailingWhitespace: function () { return !!output.length && ts.isWhiteSpaceLike(output.charCodeAt(output.length - 1)); },
12842             clear: reset,
12843             reportInaccessibleThisError: ts.noop,
12844             reportPrivateInBaseOfClassExpression: ts.noop,
12845             reportInaccessibleUniqueSymbolError: ts.noop,
12846             trackSymbol: ts.noop,
12847             writeKeyword: write,
12848             writeOperator: write,
12849             writeParameter: write,
12850             writeProperty: write,
12851             writePunctuation: write,
12852             writeSpace: write,
12853             writeStringLiteral: write,
12854             writeSymbol: function (s, _) { return write(s); },
12855             writeTrailingSemicolon: write,
12856             writeComment: writeComment,
12857             getTextPosWithWriteLine: getTextPosWithWriteLine
12858         };
12859     }
12860     ts.createTextWriter = createTextWriter;
12861     function getTrailingSemicolonDeferringWriter(writer) {
12862         var pendingTrailingSemicolon = false;
12863         function commitPendingTrailingSemicolon() {
12864             if (pendingTrailingSemicolon) {
12865                 writer.writeTrailingSemicolon(";");
12866                 pendingTrailingSemicolon = false;
12867             }
12868         }
12869         return __assign(__assign({}, writer), { writeTrailingSemicolon: function () {
12870                 pendingTrailingSemicolon = true;
12871             },
12872             writeLiteral: function (s) {
12873                 commitPendingTrailingSemicolon();
12874                 writer.writeLiteral(s);
12875             },
12876             writeStringLiteral: function (s) {
12877                 commitPendingTrailingSemicolon();
12878                 writer.writeStringLiteral(s);
12879             },
12880             writeSymbol: function (s, sym) {
12881                 commitPendingTrailingSemicolon();
12882                 writer.writeSymbol(s, sym);
12883             },
12884             writePunctuation: function (s) {
12885                 commitPendingTrailingSemicolon();
12886                 writer.writePunctuation(s);
12887             },
12888             writeKeyword: function (s) {
12889                 commitPendingTrailingSemicolon();
12890                 writer.writeKeyword(s);
12891             },
12892             writeOperator: function (s) {
12893                 commitPendingTrailingSemicolon();
12894                 writer.writeOperator(s);
12895             },
12896             writeParameter: function (s) {
12897                 commitPendingTrailingSemicolon();
12898                 writer.writeParameter(s);
12899             },
12900             writeSpace: function (s) {
12901                 commitPendingTrailingSemicolon();
12902                 writer.writeSpace(s);
12903             },
12904             writeProperty: function (s) {
12905                 commitPendingTrailingSemicolon();
12906                 writer.writeProperty(s);
12907             },
12908             writeComment: function (s) {
12909                 commitPendingTrailingSemicolon();
12910                 writer.writeComment(s);
12911             },
12912             writeLine: function () {
12913                 commitPendingTrailingSemicolon();
12914                 writer.writeLine();
12915             },
12916             increaseIndent: function () {
12917                 commitPendingTrailingSemicolon();
12918                 writer.increaseIndent();
12919             },
12920             decreaseIndent: function () {
12921                 commitPendingTrailingSemicolon();
12922                 writer.decreaseIndent();
12923             } });
12924     }
12925     ts.getTrailingSemicolonDeferringWriter = getTrailingSemicolonDeferringWriter;
12926     function hostUsesCaseSensitiveFileNames(host) {
12927         return host.useCaseSensitiveFileNames ? host.useCaseSensitiveFileNames() : false;
12928     }
12929     ts.hostUsesCaseSensitiveFileNames = hostUsesCaseSensitiveFileNames;
12930     function hostGetCanonicalFileName(host) {
12931         return ts.createGetCanonicalFileName(hostUsesCaseSensitiveFileNames(host));
12932     }
12933     ts.hostGetCanonicalFileName = hostGetCanonicalFileName;
12934     function getResolvedExternalModuleName(host, file, referenceFile) {
12935         return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName);
12936     }
12937     ts.getResolvedExternalModuleName = getResolvedExternalModuleName;
12938     function getExternalModuleNameFromDeclaration(host, resolver, declaration) {
12939         var file = resolver.getExternalModuleFileFromDeclaration(declaration);
12940         if (!file || file.isDeclarationFile) {
12941             return undefined;
12942         }
12943         return getResolvedExternalModuleName(host, file);
12944     }
12945     ts.getExternalModuleNameFromDeclaration = getExternalModuleNameFromDeclaration;
12946     function getExternalModuleNameFromPath(host, fileName, referencePath) {
12947         var getCanonicalFileName = function (f) { return host.getCanonicalFileName(f); };
12948         var dir = ts.toPath(referencePath ? ts.getDirectoryPath(referencePath) : host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName);
12949         var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory());
12950         var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, false);
12951         var extensionless = removeFileExtension(relativePath);
12952         return referencePath ? ts.ensurePathIsNonModuleName(extensionless) : extensionless;
12953     }
12954     ts.getExternalModuleNameFromPath = getExternalModuleNameFromPath;
12955     function getOwnEmitOutputFilePath(fileName, host, extension) {
12956         var compilerOptions = host.getCompilerOptions();
12957         var emitOutputFilePathWithoutExtension;
12958         if (compilerOptions.outDir) {
12959             emitOutputFilePathWithoutExtension = removeFileExtension(getSourceFilePathInNewDir(fileName, host, compilerOptions.outDir));
12960         }
12961         else {
12962             emitOutputFilePathWithoutExtension = removeFileExtension(fileName);
12963         }
12964         return emitOutputFilePathWithoutExtension + extension;
12965     }
12966     ts.getOwnEmitOutputFilePath = getOwnEmitOutputFilePath;
12967     function getDeclarationEmitOutputFilePath(fileName, host) {
12968         return getDeclarationEmitOutputFilePathWorker(fileName, host.getCompilerOptions(), host.getCurrentDirectory(), host.getCommonSourceDirectory(), function (f) { return host.getCanonicalFileName(f); });
12969     }
12970     ts.getDeclarationEmitOutputFilePath = getDeclarationEmitOutputFilePath;
12971     function getDeclarationEmitOutputFilePathWorker(fileName, options, currentDirectory, commonSourceDirectory, getCanonicalFileName) {
12972         var outputDir = options.declarationDir || options.outDir;
12973         var path = outputDir
12974             ? getSourceFilePathInNewDirWorker(fileName, outputDir, currentDirectory, commonSourceDirectory, getCanonicalFileName)
12975             : fileName;
12976         return removeFileExtension(path) + ".d.ts";
12977     }
12978     ts.getDeclarationEmitOutputFilePathWorker = getDeclarationEmitOutputFilePathWorker;
12979     function getSourceFilesToEmit(host, targetSourceFile, forceDtsEmit) {
12980         var options = host.getCompilerOptions();
12981         if (options.outFile || options.out) {
12982             var moduleKind = getEmitModuleKind(options);
12983             var moduleEmitEnabled_1 = options.emitDeclarationOnly || moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System;
12984             return ts.filter(host.getSourceFiles(), function (sourceFile) {
12985                 return (moduleEmitEnabled_1 || !ts.isExternalModule(sourceFile)) &&
12986                     sourceFileMayBeEmitted(sourceFile, host, forceDtsEmit);
12987             });
12988         }
12989         else {
12990             var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile];
12991             return ts.filter(sourceFiles, function (sourceFile) { return sourceFileMayBeEmitted(sourceFile, host, forceDtsEmit); });
12992         }
12993     }
12994     ts.getSourceFilesToEmit = getSourceFilesToEmit;
12995     function sourceFileMayBeEmitted(sourceFile, host, forceDtsEmit) {
12996         var options = host.getCompilerOptions();
12997         return !(options.noEmitForJsFiles && isSourceFileJS(sourceFile)) &&
12998             !sourceFile.isDeclarationFile &&
12999             !host.isSourceFileFromExternalLibrary(sourceFile) &&
13000             !(isJsonSourceFile(sourceFile) && host.getResolvedProjectReferenceToRedirect(sourceFile.fileName)) &&
13001             (forceDtsEmit || !host.isSourceOfProjectReferenceRedirect(sourceFile.fileName));
13002     }
13003     ts.sourceFileMayBeEmitted = sourceFileMayBeEmitted;
13004     function getSourceFilePathInNewDir(fileName, host, newDirPath) {
13005         return getSourceFilePathInNewDirWorker(fileName, newDirPath, host.getCurrentDirectory(), host.getCommonSourceDirectory(), function (f) { return host.getCanonicalFileName(f); });
13006     }
13007     ts.getSourceFilePathInNewDir = getSourceFilePathInNewDir;
13008     function getSourceFilePathInNewDirWorker(fileName, newDirPath, currentDirectory, commonSourceDirectory, getCanonicalFileName) {
13009         var sourceFilePath = ts.getNormalizedAbsolutePath(fileName, currentDirectory);
13010         var isSourceFileInCommonSourceDirectory = getCanonicalFileName(sourceFilePath).indexOf(getCanonicalFileName(commonSourceDirectory)) === 0;
13011         sourceFilePath = isSourceFileInCommonSourceDirectory ? sourceFilePath.substring(commonSourceDirectory.length) : sourceFilePath;
13012         return ts.combinePaths(newDirPath, sourceFilePath);
13013     }
13014     ts.getSourceFilePathInNewDirWorker = getSourceFilePathInNewDirWorker;
13015     function writeFile(host, diagnostics, fileName, data, writeByteOrderMark, sourceFiles) {
13016         host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) {
13017             diagnostics.add(createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage));
13018         }, sourceFiles);
13019     }
13020     ts.writeFile = writeFile;
13021     function ensureDirectoriesExist(directoryPath, createDirectory, directoryExists) {
13022         if (directoryPath.length > ts.getRootLength(directoryPath) && !directoryExists(directoryPath)) {
13023             var parentDirectory = ts.getDirectoryPath(directoryPath);
13024             ensureDirectoriesExist(parentDirectory, createDirectory, directoryExists);
13025             createDirectory(directoryPath);
13026         }
13027     }
13028     function writeFileEnsuringDirectories(path, data, writeByteOrderMark, writeFile, createDirectory, directoryExists) {
13029         try {
13030             writeFile(path, data, writeByteOrderMark);
13031         }
13032         catch (_a) {
13033             ensureDirectoriesExist(ts.getDirectoryPath(ts.normalizePath(path)), createDirectory, directoryExists);
13034             writeFile(path, data, writeByteOrderMark);
13035         }
13036     }
13037     ts.writeFileEnsuringDirectories = writeFileEnsuringDirectories;
13038     function getLineOfLocalPosition(sourceFile, pos) {
13039         var lineStarts = ts.getLineStarts(sourceFile);
13040         return ts.computeLineOfPosition(lineStarts, pos);
13041     }
13042     ts.getLineOfLocalPosition = getLineOfLocalPosition;
13043     function getLineOfLocalPositionFromLineMap(lineMap, pos) {
13044         return ts.computeLineOfPosition(lineMap, pos);
13045     }
13046     ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap;
13047     function getFirstConstructorWithBody(node) {
13048         return ts.find(node.members, function (member) { return ts.isConstructorDeclaration(member) && nodeIsPresent(member.body); });
13049     }
13050     ts.getFirstConstructorWithBody = getFirstConstructorWithBody;
13051     function getSetAccessorValueParameter(accessor) {
13052         if (accessor && accessor.parameters.length > 0) {
13053             var hasThis = accessor.parameters.length === 2 && parameterIsThisKeyword(accessor.parameters[0]);
13054             return accessor.parameters[hasThis ? 1 : 0];
13055         }
13056     }
13057     ts.getSetAccessorValueParameter = getSetAccessorValueParameter;
13058     function getSetAccessorTypeAnnotationNode(accessor) {
13059         var parameter = getSetAccessorValueParameter(accessor);
13060         return parameter && parameter.type;
13061     }
13062     ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode;
13063     function getThisParameter(signature) {
13064         if (signature.parameters.length && !ts.isJSDocSignature(signature)) {
13065             var thisParameter = signature.parameters[0];
13066             if (parameterIsThisKeyword(thisParameter)) {
13067                 return thisParameter;
13068             }
13069         }
13070     }
13071     ts.getThisParameter = getThisParameter;
13072     function parameterIsThisKeyword(parameter) {
13073         return isThisIdentifier(parameter.name);
13074     }
13075     ts.parameterIsThisKeyword = parameterIsThisKeyword;
13076     function isThisIdentifier(node) {
13077         return !!node && node.kind === 75 && identifierIsThisKeyword(node);
13078     }
13079     ts.isThisIdentifier = isThisIdentifier;
13080     function identifierIsThisKeyword(id) {
13081         return id.originalKeywordKind === 104;
13082     }
13083     ts.identifierIsThisKeyword = identifierIsThisKeyword;
13084     function getAllAccessorDeclarations(declarations, accessor) {
13085         var firstAccessor;
13086         var secondAccessor;
13087         var getAccessor;
13088         var setAccessor;
13089         if (hasDynamicName(accessor)) {
13090             firstAccessor = accessor;
13091             if (accessor.kind === 163) {
13092                 getAccessor = accessor;
13093             }
13094             else if (accessor.kind === 164) {
13095                 setAccessor = accessor;
13096             }
13097             else {
13098                 ts.Debug.fail("Accessor has wrong kind");
13099             }
13100         }
13101         else {
13102             ts.forEach(declarations, function (member) {
13103                 if (ts.isAccessor(member)
13104                     && hasModifier(member, 32) === hasModifier(accessor, 32)) {
13105                     var memberName = getPropertyNameForPropertyNameNode(member.name);
13106                     var accessorName = getPropertyNameForPropertyNameNode(accessor.name);
13107                     if (memberName === accessorName) {
13108                         if (!firstAccessor) {
13109                             firstAccessor = member;
13110                         }
13111                         else if (!secondAccessor) {
13112                             secondAccessor = member;
13113                         }
13114                         if (member.kind === 163 && !getAccessor) {
13115                             getAccessor = member;
13116                         }
13117                         if (member.kind === 164 && !setAccessor) {
13118                             setAccessor = member;
13119                         }
13120                     }
13121                 }
13122             });
13123         }
13124         return {
13125             firstAccessor: firstAccessor,
13126             secondAccessor: secondAccessor,
13127             getAccessor: getAccessor,
13128             setAccessor: setAccessor
13129         };
13130     }
13131     ts.getAllAccessorDeclarations = getAllAccessorDeclarations;
13132     function getEffectiveTypeAnnotationNode(node) {
13133         if (!isInJSFile(node) && ts.isFunctionDeclaration(node))
13134             return undefined;
13135         var type = node.type;
13136         if (type || !isInJSFile(node))
13137             return type;
13138         return ts.isJSDocPropertyLikeTag(node) ? node.typeExpression && node.typeExpression.type : ts.getJSDocType(node);
13139     }
13140     ts.getEffectiveTypeAnnotationNode = getEffectiveTypeAnnotationNode;
13141     function getTypeAnnotationNode(node) {
13142         return node.type;
13143     }
13144     ts.getTypeAnnotationNode = getTypeAnnotationNode;
13145     function getEffectiveReturnTypeNode(node) {
13146         return ts.isJSDocSignature(node) ?
13147             node.type && node.type.typeExpression && node.type.typeExpression.type :
13148             node.type || (isInJSFile(node) ? ts.getJSDocReturnType(node) : undefined);
13149     }
13150     ts.getEffectiveReturnTypeNode = getEffectiveReturnTypeNode;
13151     function getJSDocTypeParameterDeclarations(node) {
13152         return ts.flatMap(ts.getJSDocTags(node), function (tag) { return isNonTypeAliasTemplate(tag) ? tag.typeParameters : undefined; });
13153     }
13154     ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations;
13155     function isNonTypeAliasTemplate(tag) {
13156         return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 303 && tag.parent.tags.some(isJSDocTypeAlias));
13157     }
13158     function getEffectiveSetAccessorTypeAnnotationNode(node) {
13159         var parameter = getSetAccessorValueParameter(node);
13160         return parameter && getEffectiveTypeAnnotationNode(parameter);
13161     }
13162     ts.getEffectiveSetAccessorTypeAnnotationNode = getEffectiveSetAccessorTypeAnnotationNode;
13163     function emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments) {
13164         emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, node.pos, leadingComments);
13165     }
13166     ts.emitNewLineBeforeLeadingComments = emitNewLineBeforeLeadingComments;
13167     function emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, pos, leadingComments) {
13168         if (leadingComments && leadingComments.length && pos !== leadingComments[0].pos &&
13169             getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, leadingComments[0].pos)) {
13170             writer.writeLine();
13171         }
13172     }
13173     ts.emitNewLineBeforeLeadingCommentsOfPosition = emitNewLineBeforeLeadingCommentsOfPosition;
13174     function emitNewLineBeforeLeadingCommentOfPosition(lineMap, writer, pos, commentPos) {
13175         if (pos !== commentPos &&
13176             getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, commentPos)) {
13177             writer.writeLine();
13178         }
13179     }
13180     ts.emitNewLineBeforeLeadingCommentOfPosition = emitNewLineBeforeLeadingCommentOfPosition;
13181     function emitComments(text, lineMap, writer, comments, leadingSeparator, trailingSeparator, newLine, writeComment) {
13182         if (comments && comments.length > 0) {
13183             if (leadingSeparator) {
13184                 writer.writeSpace(" ");
13185             }
13186             var emitInterveningSeparator = false;
13187             for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) {
13188                 var comment = comments_1[_i];
13189                 if (emitInterveningSeparator) {
13190                     writer.writeSpace(" ");
13191                     emitInterveningSeparator = false;
13192                 }
13193                 writeComment(text, lineMap, writer, comment.pos, comment.end, newLine);
13194                 if (comment.hasTrailingNewLine) {
13195                     writer.writeLine();
13196                 }
13197                 else {
13198                     emitInterveningSeparator = true;
13199                 }
13200             }
13201             if (emitInterveningSeparator && trailingSeparator) {
13202                 writer.writeSpace(" ");
13203             }
13204         }
13205     }
13206     ts.emitComments = emitComments;
13207     function emitDetachedComments(text, lineMap, writer, writeComment, node, newLine, removeComments) {
13208         var leadingComments;
13209         var currentDetachedCommentInfo;
13210         if (removeComments) {
13211             if (node.pos === 0) {
13212                 leadingComments = ts.filter(ts.getLeadingCommentRanges(text, node.pos), isPinnedCommentLocal);
13213             }
13214         }
13215         else {
13216             leadingComments = ts.getLeadingCommentRanges(text, node.pos);
13217         }
13218         if (leadingComments) {
13219             var detachedComments = [];
13220             var lastComment = void 0;
13221             for (var _i = 0, leadingComments_1 = leadingComments; _i < leadingComments_1.length; _i++) {
13222                 var comment = leadingComments_1[_i];
13223                 if (lastComment) {
13224                     var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, lastComment.end);
13225                     var commentLine = getLineOfLocalPositionFromLineMap(lineMap, comment.pos);
13226                     if (commentLine >= lastCommentLine + 2) {
13227                         break;
13228                     }
13229                 }
13230                 detachedComments.push(comment);
13231                 lastComment = comment;
13232             }
13233             if (detachedComments.length) {
13234                 var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, ts.last(detachedComments).end);
13235                 var nodeLine = getLineOfLocalPositionFromLineMap(lineMap, ts.skipTrivia(text, node.pos));
13236                 if (nodeLine >= lastCommentLine + 2) {
13237                     emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments);
13238                     emitComments(text, lineMap, writer, detachedComments, false, true, newLine, writeComment);
13239                     currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.last(detachedComments).end };
13240                 }
13241             }
13242         }
13243         return currentDetachedCommentInfo;
13244         function isPinnedCommentLocal(comment) {
13245             return isPinnedComment(text, comment.pos);
13246         }
13247     }
13248     ts.emitDetachedComments = emitDetachedComments;
13249     function writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine) {
13250         if (text.charCodeAt(commentPos + 1) === 42) {
13251             var firstCommentLineAndCharacter = ts.computeLineAndCharacterOfPosition(lineMap, commentPos);
13252             var lineCount = lineMap.length;
13253             var firstCommentLineIndent = void 0;
13254             for (var pos = commentPos, currentLine = firstCommentLineAndCharacter.line; pos < commentEnd; currentLine++) {
13255                 var nextLineStart = (currentLine + 1) === lineCount
13256                     ? text.length + 1
13257                     : lineMap[currentLine + 1];
13258                 if (pos !== commentPos) {
13259                     if (firstCommentLineIndent === undefined) {
13260                         firstCommentLineIndent = calculateIndent(text, lineMap[firstCommentLineAndCharacter.line], commentPos);
13261                     }
13262                     var currentWriterIndentSpacing = writer.getIndent() * getIndentSize();
13263                     var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(text, pos, nextLineStart);
13264                     if (spacesToEmit > 0) {
13265                         var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize();
13266                         var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize());
13267                         writer.rawWrite(indentSizeSpaceString);
13268                         while (numberOfSingleSpacesToEmit) {
13269                             writer.rawWrite(" ");
13270                             numberOfSingleSpacesToEmit--;
13271                         }
13272                     }
13273                     else {
13274                         writer.rawWrite("");
13275                     }
13276                 }
13277                 writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart);
13278                 pos = nextLineStart;
13279             }
13280         }
13281         else {
13282             writer.writeComment(text.substring(commentPos, commentEnd));
13283         }
13284     }
13285     ts.writeCommentRange = writeCommentRange;
13286     function writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart) {
13287         var end = Math.min(commentEnd, nextLineStart - 1);
13288         var currentLineText = text.substring(pos, end).replace(/^\s+|\s+$/g, "");
13289         if (currentLineText) {
13290             writer.writeComment(currentLineText);
13291             if (end !== commentEnd) {
13292                 writer.writeLine();
13293             }
13294         }
13295         else {
13296             writer.rawWrite(newLine);
13297         }
13298     }
13299     function calculateIndent(text, pos, end) {
13300         var currentLineIndent = 0;
13301         for (; pos < end && ts.isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) {
13302             if (text.charCodeAt(pos) === 9) {
13303                 currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize());
13304             }
13305             else {
13306                 currentLineIndent++;
13307             }
13308         }
13309         return currentLineIndent;
13310     }
13311     function hasModifiers(node) {
13312         return getModifierFlags(node) !== 0;
13313     }
13314     ts.hasModifiers = hasModifiers;
13315     function hasModifier(node, flags) {
13316         return !!getSelectedModifierFlags(node, flags);
13317     }
13318     ts.hasModifier = hasModifier;
13319     function hasStaticModifier(node) {
13320         return hasModifier(node, 32);
13321     }
13322     ts.hasStaticModifier = hasStaticModifier;
13323     function hasReadonlyModifier(node) {
13324         return hasModifier(node, 64);
13325     }
13326     ts.hasReadonlyModifier = hasReadonlyModifier;
13327     function getSelectedModifierFlags(node, flags) {
13328         return getModifierFlags(node) & flags;
13329     }
13330     ts.getSelectedModifierFlags = getSelectedModifierFlags;
13331     function getModifierFlags(node) {
13332         if (node.kind >= 0 && node.kind <= 152) {
13333             return 0;
13334         }
13335         if (node.modifierFlagsCache & 536870912) {
13336             return node.modifierFlagsCache & ~536870912;
13337         }
13338         var flags = getModifierFlagsNoCache(node);
13339         node.modifierFlagsCache = flags | 536870912;
13340         return flags;
13341     }
13342     ts.getModifierFlags = getModifierFlags;
13343     function getModifierFlagsNoCache(node) {
13344         var flags = 0;
13345         if (node.modifiers) {
13346             for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) {
13347                 var modifier = _a[_i];
13348                 flags |= modifierToFlag(modifier.kind);
13349             }
13350         }
13351         if (isInJSFile(node) && !!node.parent) {
13352             var tags = (ts.getJSDocPublicTag(node) ? 4 : 0)
13353                 | (ts.getJSDocPrivateTag(node) ? 8 : 0)
13354                 | (ts.getJSDocProtectedTag(node) ? 16 : 0)
13355                 | (ts.getJSDocReadonlyTag(node) ? 64 : 0);
13356             flags |= tags;
13357         }
13358         if (node.flags & 4 || (node.kind === 75 && node.isInJSDocNamespace)) {
13359             flags |= 1;
13360         }
13361         return flags;
13362     }
13363     ts.getModifierFlagsNoCache = getModifierFlagsNoCache;
13364     function modifierToFlag(token) {
13365         switch (token) {
13366             case 120: return 32;
13367             case 119: return 4;
13368             case 118: return 16;
13369             case 117: return 8;
13370             case 122: return 128;
13371             case 89: return 1;
13372             case 130: return 2;
13373             case 81: return 2048;
13374             case 84: return 512;
13375             case 126: return 256;
13376             case 138: return 64;
13377         }
13378         return 0;
13379     }
13380     ts.modifierToFlag = modifierToFlag;
13381     function isLogicalOperator(token) {
13382         return token === 56
13383             || token === 55
13384             || token === 53;
13385     }
13386     ts.isLogicalOperator = isLogicalOperator;
13387     function isAssignmentOperator(token) {
13388         return token >= 62 && token <= 74;
13389     }
13390     ts.isAssignmentOperator = isAssignmentOperator;
13391     function tryGetClassExtendingExpressionWithTypeArguments(node) {
13392         var cls = tryGetClassImplementingOrExtendingExpressionWithTypeArguments(node);
13393         return cls && !cls.isImplements ? cls.class : undefined;
13394     }
13395     ts.tryGetClassExtendingExpressionWithTypeArguments = tryGetClassExtendingExpressionWithTypeArguments;
13396     function tryGetClassImplementingOrExtendingExpressionWithTypeArguments(node) {
13397         return ts.isExpressionWithTypeArguments(node)
13398             && ts.isHeritageClause(node.parent)
13399             && ts.isClassLike(node.parent.parent)
13400             ? { class: node.parent.parent, isImplements: node.parent.token === 113 }
13401             : undefined;
13402     }
13403     ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments;
13404     function isAssignmentExpression(node, excludeCompoundAssignment) {
13405         return ts.isBinaryExpression(node)
13406             && (excludeCompoundAssignment
13407                 ? node.operatorToken.kind === 62
13408                 : isAssignmentOperator(node.operatorToken.kind))
13409             && ts.isLeftHandSideExpression(node.left);
13410     }
13411     ts.isAssignmentExpression = isAssignmentExpression;
13412     function isDestructuringAssignment(node) {
13413         if (isAssignmentExpression(node, true)) {
13414             var kind = node.left.kind;
13415             return kind === 193
13416                 || kind === 192;
13417         }
13418         return false;
13419     }
13420     ts.isDestructuringAssignment = isDestructuringAssignment;
13421     function isExpressionWithTypeArgumentsInClassExtendsClause(node) {
13422         return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined;
13423     }
13424     ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause;
13425     function isEntityNameExpression(node) {
13426         return node.kind === 75 || isPropertyAccessEntityNameExpression(node);
13427     }
13428     ts.isEntityNameExpression = isEntityNameExpression;
13429     function getFirstIdentifier(node) {
13430         switch (node.kind) {
13431             case 75:
13432                 return node;
13433             case 153:
13434                 do {
13435                     node = node.left;
13436                 } while (node.kind !== 75);
13437                 return node;
13438             case 194:
13439                 do {
13440                     node = node.expression;
13441                 } while (node.kind !== 75);
13442                 return node;
13443         }
13444     }
13445     ts.getFirstIdentifier = getFirstIdentifier;
13446     function isDottedName(node) {
13447         return node.kind === 75 || node.kind === 104 || node.kind === 102 ||
13448             node.kind === 194 && isDottedName(node.expression) ||
13449             node.kind === 200 && isDottedName(node.expression);
13450     }
13451     ts.isDottedName = isDottedName;
13452     function isPropertyAccessEntityNameExpression(node) {
13453         return ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.name) && isEntityNameExpression(node.expression);
13454     }
13455     ts.isPropertyAccessEntityNameExpression = isPropertyAccessEntityNameExpression;
13456     function tryGetPropertyAccessOrIdentifierToString(expr) {
13457         if (ts.isPropertyAccessExpression(expr)) {
13458             var baseStr = tryGetPropertyAccessOrIdentifierToString(expr.expression);
13459             if (baseStr !== undefined) {
13460                 return baseStr + "." + expr.name;
13461             }
13462         }
13463         else if (ts.isIdentifier(expr)) {
13464             return ts.unescapeLeadingUnderscores(expr.escapedText);
13465         }
13466         return undefined;
13467     }
13468     ts.tryGetPropertyAccessOrIdentifierToString = tryGetPropertyAccessOrIdentifierToString;
13469     function isPrototypeAccess(node) {
13470         return isBindableStaticAccessExpression(node) && getElementOrPropertyAccessName(node) === "prototype";
13471     }
13472     ts.isPrototypeAccess = isPrototypeAccess;
13473     function isRightSideOfQualifiedNameOrPropertyAccess(node) {
13474         return (node.parent.kind === 153 && node.parent.right === node) ||
13475             (node.parent.kind === 194 && node.parent.name === node);
13476     }
13477     ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess;
13478     function isEmptyObjectLiteral(expression) {
13479         return expression.kind === 193 &&
13480             expression.properties.length === 0;
13481     }
13482     ts.isEmptyObjectLiteral = isEmptyObjectLiteral;
13483     function isEmptyArrayLiteral(expression) {
13484         return expression.kind === 192 &&
13485             expression.elements.length === 0;
13486     }
13487     ts.isEmptyArrayLiteral = isEmptyArrayLiteral;
13488     function getLocalSymbolForExportDefault(symbol) {
13489         return isExportDefaultSymbol(symbol) ? symbol.declarations[0].localSymbol : undefined;
13490     }
13491     ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault;
13492     function isExportDefaultSymbol(symbol) {
13493         return symbol && ts.length(symbol.declarations) > 0 && hasModifier(symbol.declarations[0], 512);
13494     }
13495     function tryExtractTSExtension(fileName) {
13496         return ts.find(ts.supportedTSExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); });
13497     }
13498     ts.tryExtractTSExtension = tryExtractTSExtension;
13499     function getExpandedCharCodes(input) {
13500         var output = [];
13501         var length = input.length;
13502         for (var i = 0; i < length; i++) {
13503             var charCode = input.charCodeAt(i);
13504             if (charCode < 0x80) {
13505                 output.push(charCode);
13506             }
13507             else if (charCode < 0x800) {
13508                 output.push((charCode >> 6) | 192);
13509                 output.push((charCode & 63) | 128);
13510             }
13511             else if (charCode < 0x10000) {
13512                 output.push((charCode >> 12) | 224);
13513                 output.push(((charCode >> 6) & 63) | 128);
13514                 output.push((charCode & 63) | 128);
13515             }
13516             else if (charCode < 0x20000) {
13517                 output.push((charCode >> 18) | 240);
13518                 output.push(((charCode >> 12) & 63) | 128);
13519                 output.push(((charCode >> 6) & 63) | 128);
13520                 output.push((charCode & 63) | 128);
13521             }
13522             else {
13523                 ts.Debug.assert(false, "Unexpected code point");
13524             }
13525         }
13526         return output;
13527     }
13528     var base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
13529     function convertToBase64(input) {
13530         var result = "";
13531         var charCodes = getExpandedCharCodes(input);
13532         var i = 0;
13533         var length = charCodes.length;
13534         var byte1, byte2, byte3, byte4;
13535         while (i < length) {
13536             byte1 = charCodes[i] >> 2;
13537             byte2 = (charCodes[i] & 3) << 4 | charCodes[i + 1] >> 4;
13538             byte3 = (charCodes[i + 1] & 15) << 2 | charCodes[i + 2] >> 6;
13539             byte4 = charCodes[i + 2] & 63;
13540             if (i + 1 >= length) {
13541                 byte3 = byte4 = 64;
13542             }
13543             else if (i + 2 >= length) {
13544                 byte4 = 64;
13545             }
13546             result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4);
13547             i += 3;
13548         }
13549         return result;
13550     }
13551     ts.convertToBase64 = convertToBase64;
13552     function getStringFromExpandedCharCodes(codes) {
13553         var output = "";
13554         var i = 0;
13555         var length = codes.length;
13556         while (i < length) {
13557             var charCode = codes[i];
13558             if (charCode < 0x80) {
13559                 output += String.fromCharCode(charCode);
13560                 i++;
13561             }
13562             else if ((charCode & 192) === 192) {
13563                 var value = charCode & 63;
13564                 i++;
13565                 var nextCode = codes[i];
13566                 while ((nextCode & 192) === 128) {
13567                     value = (value << 6) | (nextCode & 63);
13568                     i++;
13569                     nextCode = codes[i];
13570                 }
13571                 output += String.fromCharCode(value);
13572             }
13573             else {
13574                 output += String.fromCharCode(charCode);
13575                 i++;
13576             }
13577         }
13578         return output;
13579     }
13580     function base64encode(host, input) {
13581         if (host && host.base64encode) {
13582             return host.base64encode(input);
13583         }
13584         return convertToBase64(input);
13585     }
13586     ts.base64encode = base64encode;
13587     function base64decode(host, input) {
13588         if (host && host.base64decode) {
13589             return host.base64decode(input);
13590         }
13591         var length = input.length;
13592         var expandedCharCodes = [];
13593         var i = 0;
13594         while (i < length) {
13595             if (input.charCodeAt(i) === base64Digits.charCodeAt(64)) {
13596                 break;
13597             }
13598             var ch1 = base64Digits.indexOf(input[i]);
13599             var ch2 = base64Digits.indexOf(input[i + 1]);
13600             var ch3 = base64Digits.indexOf(input[i + 2]);
13601             var ch4 = base64Digits.indexOf(input[i + 3]);
13602             var code1 = ((ch1 & 63) << 2) | ((ch2 >> 4) & 3);
13603             var code2 = ((ch2 & 15) << 4) | ((ch3 >> 2) & 15);
13604             var code3 = ((ch3 & 3) << 6) | (ch4 & 63);
13605             if (code2 === 0 && ch3 !== 0) {
13606                 expandedCharCodes.push(code1);
13607             }
13608             else if (code3 === 0 && ch4 !== 0) {
13609                 expandedCharCodes.push(code1, code2);
13610             }
13611             else {
13612                 expandedCharCodes.push(code1, code2, code3);
13613             }
13614             i += 4;
13615         }
13616         return getStringFromExpandedCharCodes(expandedCharCodes);
13617     }
13618     ts.base64decode = base64decode;
13619     function readJson(path, host) {
13620         try {
13621             var jsonText = host.readFile(path);
13622             if (!jsonText)
13623                 return {};
13624             var result = ts.parseConfigFileTextToJson(path, jsonText);
13625             if (result.error) {
13626                 return {};
13627             }
13628             return result.config;
13629         }
13630         catch (e) {
13631             return {};
13632         }
13633     }
13634     ts.readJson = readJson;
13635     function directoryProbablyExists(directoryName, host) {
13636         return !host.directoryExists || host.directoryExists(directoryName);
13637     }
13638     ts.directoryProbablyExists = directoryProbablyExists;
13639     var carriageReturnLineFeed = "\r\n";
13640     var lineFeed = "\n";
13641     function getNewLineCharacter(options, getNewLine) {
13642         switch (options.newLine) {
13643             case 0:
13644                 return carriageReturnLineFeed;
13645             case 1:
13646                 return lineFeed;
13647         }
13648         return getNewLine ? getNewLine() : ts.sys ? ts.sys.newLine : carriageReturnLineFeed;
13649     }
13650     ts.getNewLineCharacter = getNewLineCharacter;
13651     function createRange(pos, end) {
13652         if (end === void 0) { end = pos; }
13653         ts.Debug.assert(end >= pos || end === -1);
13654         return { pos: pos, end: end };
13655     }
13656     ts.createRange = createRange;
13657     function moveRangeEnd(range, end) {
13658         return createRange(range.pos, end);
13659     }
13660     ts.moveRangeEnd = moveRangeEnd;
13661     function moveRangePos(range, pos) {
13662         return createRange(pos, range.end);
13663     }
13664     ts.moveRangePos = moveRangePos;
13665     function moveRangePastDecorators(node) {
13666         return node.decorators && node.decorators.length > 0
13667             ? moveRangePos(node, node.decorators.end)
13668             : node;
13669     }
13670     ts.moveRangePastDecorators = moveRangePastDecorators;
13671     function moveRangePastModifiers(node) {
13672         return node.modifiers && node.modifiers.length > 0
13673             ? moveRangePos(node, node.modifiers.end)
13674             : moveRangePastDecorators(node);
13675     }
13676     ts.moveRangePastModifiers = moveRangePastModifiers;
13677     function isCollapsedRange(range) {
13678         return range.pos === range.end;
13679     }
13680     ts.isCollapsedRange = isCollapsedRange;
13681     function createTokenRange(pos, token) {
13682         return createRange(pos, pos + ts.tokenToString(token).length);
13683     }
13684     ts.createTokenRange = createTokenRange;
13685     function rangeIsOnSingleLine(range, sourceFile) {
13686         return rangeStartIsOnSameLineAsRangeEnd(range, range, sourceFile);
13687     }
13688     ts.rangeIsOnSingleLine = rangeIsOnSingleLine;
13689     function rangeStartPositionsAreOnSameLine(range1, range2, sourceFile) {
13690         return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile, false), getStartPositionOfRange(range2, sourceFile, false), sourceFile);
13691     }
13692     ts.rangeStartPositionsAreOnSameLine = rangeStartPositionsAreOnSameLine;
13693     function rangeEndPositionsAreOnSameLine(range1, range2, sourceFile) {
13694         return positionsAreOnSameLine(range1.end, range2.end, sourceFile);
13695     }
13696     ts.rangeEndPositionsAreOnSameLine = rangeEndPositionsAreOnSameLine;
13697     function rangeStartIsOnSameLineAsRangeEnd(range1, range2, sourceFile) {
13698         return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile, false), range2.end, sourceFile);
13699     }
13700     ts.rangeStartIsOnSameLineAsRangeEnd = rangeStartIsOnSameLineAsRangeEnd;
13701     function rangeEndIsOnSameLineAsRangeStart(range1, range2, sourceFile) {
13702         return positionsAreOnSameLine(range1.end, getStartPositionOfRange(range2, sourceFile, false), sourceFile);
13703     }
13704     ts.rangeEndIsOnSameLineAsRangeStart = rangeEndIsOnSameLineAsRangeStart;
13705     function getLinesBetweenRangeEndAndRangeStart(range1, range2, sourceFile, includeSecondRangeComments) {
13706         var range2Start = getStartPositionOfRange(range2, sourceFile, includeSecondRangeComments);
13707         return ts.getLinesBetweenPositions(sourceFile, range1.end, range2Start);
13708     }
13709     ts.getLinesBetweenRangeEndAndRangeStart = getLinesBetweenRangeEndAndRangeStart;
13710     function getLinesBetweenRangeEndPositions(range1, range2, sourceFile) {
13711         return ts.getLinesBetweenPositions(sourceFile, range1.end, range2.end);
13712     }
13713     ts.getLinesBetweenRangeEndPositions = getLinesBetweenRangeEndPositions;
13714     function isNodeArrayMultiLine(list, sourceFile) {
13715         return !positionsAreOnSameLine(list.pos, list.end, sourceFile);
13716     }
13717     ts.isNodeArrayMultiLine = isNodeArrayMultiLine;
13718     function positionsAreOnSameLine(pos1, pos2, sourceFile) {
13719         return ts.getLinesBetweenPositions(sourceFile, pos1, pos2) === 0;
13720     }
13721     ts.positionsAreOnSameLine = positionsAreOnSameLine;
13722     function getStartPositionOfRange(range, sourceFile, includeComments) {
13723         return positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos, false, includeComments);
13724     }
13725     ts.getStartPositionOfRange = getStartPositionOfRange;
13726     function getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter(pos, stopPos, sourceFile, includeComments) {
13727         var startPos = ts.skipTrivia(sourceFile.text, pos, false, includeComments);
13728         var prevPos = getPreviousNonWhitespacePosition(startPos, stopPos, sourceFile);
13729         return ts.getLinesBetweenPositions(sourceFile, prevPos !== null && prevPos !== void 0 ? prevPos : stopPos, startPos);
13730     }
13731     ts.getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter = getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter;
13732     function getLinesBetweenPositionAndNextNonWhitespaceCharacter(pos, stopPos, sourceFile, includeComments) {
13733         var nextPos = ts.skipTrivia(sourceFile.text, pos, false, includeComments);
13734         return ts.getLinesBetweenPositions(sourceFile, pos, Math.min(stopPos, nextPos));
13735     }
13736     ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter = getLinesBetweenPositionAndNextNonWhitespaceCharacter;
13737     function getPreviousNonWhitespacePosition(pos, stopPos, sourceFile) {
13738         if (stopPos === void 0) { stopPos = 0; }
13739         while (pos-- > stopPos) {
13740             if (!ts.isWhiteSpaceLike(sourceFile.text.charCodeAt(pos))) {
13741                 return pos;
13742             }
13743         }
13744     }
13745     function isDeclarationNameOfEnumOrNamespace(node) {
13746         var parseNode = ts.getParseTreeNode(node);
13747         if (parseNode) {
13748             switch (parseNode.parent.kind) {
13749                 case 248:
13750                 case 249:
13751                     return parseNode === parseNode.parent.name;
13752             }
13753         }
13754         return false;
13755     }
13756     ts.isDeclarationNameOfEnumOrNamespace = isDeclarationNameOfEnumOrNamespace;
13757     function getInitializedVariables(node) {
13758         return ts.filter(node.declarations, isInitializedVariable);
13759     }
13760     ts.getInitializedVariables = getInitializedVariables;
13761     function isInitializedVariable(node) {
13762         return node.initializer !== undefined;
13763     }
13764     function isWatchSet(options) {
13765         return options.watch && options.hasOwnProperty("watch");
13766     }
13767     ts.isWatchSet = isWatchSet;
13768     function closeFileWatcher(watcher) {
13769         watcher.close();
13770     }
13771     ts.closeFileWatcher = closeFileWatcher;
13772     function getCheckFlags(symbol) {
13773         return symbol.flags & 33554432 ? symbol.checkFlags : 0;
13774     }
13775     ts.getCheckFlags = getCheckFlags;
13776     function getDeclarationModifierFlagsFromSymbol(s) {
13777         if (s.valueDeclaration) {
13778             var flags = ts.getCombinedModifierFlags(s.valueDeclaration);
13779             return s.parent && s.parent.flags & 32 ? flags : flags & ~28;
13780         }
13781         if (getCheckFlags(s) & 6) {
13782             var checkFlags = s.checkFlags;
13783             var accessModifier = checkFlags & 1024 ? 8 :
13784                 checkFlags & 256 ? 4 :
13785                     16;
13786             var staticModifier = checkFlags & 2048 ? 32 : 0;
13787             return accessModifier | staticModifier;
13788         }
13789         if (s.flags & 4194304) {
13790             return 4 | 32;
13791         }
13792         return 0;
13793     }
13794     ts.getDeclarationModifierFlagsFromSymbol = getDeclarationModifierFlagsFromSymbol;
13795     function skipAlias(symbol, checker) {
13796         return symbol.flags & 2097152 ? checker.getAliasedSymbol(symbol) : symbol;
13797     }
13798     ts.skipAlias = skipAlias;
13799     function getCombinedLocalAndExportSymbolFlags(symbol) {
13800         return symbol.exportSymbol ? symbol.exportSymbol.flags | symbol.flags : symbol.flags;
13801     }
13802     ts.getCombinedLocalAndExportSymbolFlags = getCombinedLocalAndExportSymbolFlags;
13803     function isWriteOnlyAccess(node) {
13804         return accessKind(node) === 1;
13805     }
13806     ts.isWriteOnlyAccess = isWriteOnlyAccess;
13807     function isWriteAccess(node) {
13808         return accessKind(node) !== 0;
13809     }
13810     ts.isWriteAccess = isWriteAccess;
13811     function accessKind(node) {
13812         var parent = node.parent;
13813         if (!parent)
13814             return 0;
13815         switch (parent.kind) {
13816             case 200:
13817                 return accessKind(parent);
13818             case 208:
13819             case 207:
13820                 var operator = parent.operator;
13821                 return operator === 45 || operator === 46 ? writeOrReadWrite() : 0;
13822             case 209:
13823                 var _a = parent, left = _a.left, operatorToken = _a.operatorToken;
13824                 return left === node && isAssignmentOperator(operatorToken.kind) ?
13825                     operatorToken.kind === 62 ? 1 : writeOrReadWrite()
13826                     : 0;
13827             case 194:
13828                 return parent.name !== node ? 0 : accessKind(parent);
13829             case 281: {
13830                 var parentAccess = accessKind(parent.parent);
13831                 return node === parent.name ? reverseAccessKind(parentAccess) : parentAccess;
13832             }
13833             case 282:
13834                 return node === parent.objectAssignmentInitializer ? 0 : accessKind(parent.parent);
13835             case 192:
13836                 return accessKind(parent);
13837             default:
13838                 return 0;
13839         }
13840         function writeOrReadWrite() {
13841             return parent.parent && skipParenthesesUp(parent.parent).kind === 226 ? 1 : 2;
13842         }
13843     }
13844     function reverseAccessKind(a) {
13845         switch (a) {
13846             case 0:
13847                 return 1;
13848             case 1:
13849                 return 0;
13850             case 2:
13851                 return 2;
13852             default:
13853                 return ts.Debug.assertNever(a);
13854         }
13855     }
13856     function compareDataObjects(dst, src) {
13857         if (!dst || !src || Object.keys(dst).length !== Object.keys(src).length) {
13858             return false;
13859         }
13860         for (var e in dst) {
13861             if (typeof dst[e] === "object") {
13862                 if (!compareDataObjects(dst[e], src[e])) {
13863                     return false;
13864                 }
13865             }
13866             else if (typeof dst[e] !== "function") {
13867                 if (dst[e] !== src[e]) {
13868                     return false;
13869                 }
13870             }
13871         }
13872         return true;
13873     }
13874     ts.compareDataObjects = compareDataObjects;
13875     function clearMap(map, onDeleteValue) {
13876         map.forEach(onDeleteValue);
13877         map.clear();
13878     }
13879     ts.clearMap = clearMap;
13880     function mutateMapSkippingNewValues(map, newMap, options) {
13881         var onDeleteValue = options.onDeleteValue, onExistingValue = options.onExistingValue;
13882         map.forEach(function (existingValue, key) {
13883             var valueInNewMap = newMap.get(key);
13884             if (valueInNewMap === undefined) {
13885                 map.delete(key);
13886                 onDeleteValue(existingValue, key);
13887             }
13888             else if (onExistingValue) {
13889                 onExistingValue(existingValue, valueInNewMap, key);
13890             }
13891         });
13892     }
13893     ts.mutateMapSkippingNewValues = mutateMapSkippingNewValues;
13894     function mutateMap(map, newMap, options) {
13895         mutateMapSkippingNewValues(map, newMap, options);
13896         var createNewValue = options.createNewValue;
13897         newMap.forEach(function (valueInNewMap, key) {
13898             if (!map.has(key)) {
13899                 map.set(key, createNewValue(key, valueInNewMap));
13900             }
13901         });
13902     }
13903     ts.mutateMap = mutateMap;
13904     function isAbstractConstructorType(type) {
13905         return !!(getObjectFlags(type) & 16) && !!type.symbol && isAbstractConstructorSymbol(type.symbol);
13906     }
13907     ts.isAbstractConstructorType = isAbstractConstructorType;
13908     function isAbstractConstructorSymbol(symbol) {
13909         if (symbol.flags & 32) {
13910             var declaration = getClassLikeDeclarationOfSymbol(symbol);
13911             return !!declaration && hasModifier(declaration, 128);
13912         }
13913         return false;
13914     }
13915     ts.isAbstractConstructorSymbol = isAbstractConstructorSymbol;
13916     function getClassLikeDeclarationOfSymbol(symbol) {
13917         return ts.find(symbol.declarations, ts.isClassLike);
13918     }
13919     ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol;
13920     function getObjectFlags(type) {
13921         return type.flags & 3899393 ? type.objectFlags : 0;
13922     }
13923     ts.getObjectFlags = getObjectFlags;
13924     function typeHasCallOrConstructSignatures(type, checker) {
13925         return checker.getSignaturesOfType(type, 0).length !== 0 || checker.getSignaturesOfType(type, 1).length !== 0;
13926     }
13927     ts.typeHasCallOrConstructSignatures = typeHasCallOrConstructSignatures;
13928     function forSomeAncestorDirectory(directory, callback) {
13929         return !!ts.forEachAncestorDirectory(directory, function (d) { return callback(d) ? true : undefined; });
13930     }
13931     ts.forSomeAncestorDirectory = forSomeAncestorDirectory;
13932     function isUMDExportSymbol(symbol) {
13933         return !!symbol && !!symbol.declarations && !!symbol.declarations[0] && ts.isNamespaceExportDeclaration(symbol.declarations[0]);
13934     }
13935     ts.isUMDExportSymbol = isUMDExportSymbol;
13936     function showModuleSpecifier(_a) {
13937         var moduleSpecifier = _a.moduleSpecifier;
13938         return ts.isStringLiteral(moduleSpecifier) ? moduleSpecifier.text : getTextOfNode(moduleSpecifier);
13939     }
13940     ts.showModuleSpecifier = showModuleSpecifier;
13941     function getLastChild(node) {
13942         var lastChild;
13943         ts.forEachChild(node, function (child) {
13944             if (nodeIsPresent(child))
13945                 lastChild = child;
13946         }, function (children) {
13947             for (var i = children.length - 1; i >= 0; i--) {
13948                 if (nodeIsPresent(children[i])) {
13949                     lastChild = children[i];
13950                     break;
13951                 }
13952             }
13953         });
13954         return lastChild;
13955     }
13956     ts.getLastChild = getLastChild;
13957     function addToSeen(seen, key, value) {
13958         if (value === void 0) { value = true; }
13959         key = String(key);
13960         if (seen.has(key)) {
13961             return false;
13962         }
13963         seen.set(key, value);
13964         return true;
13965     }
13966     ts.addToSeen = addToSeen;
13967     function isObjectTypeDeclaration(node) {
13968         return ts.isClassLike(node) || ts.isInterfaceDeclaration(node) || ts.isTypeLiteralNode(node);
13969     }
13970     ts.isObjectTypeDeclaration = isObjectTypeDeclaration;
13971     function isTypeNodeKind(kind) {
13972         return (kind >= 168 && kind <= 188)
13973             || kind === 125
13974             || kind === 148
13975             || kind === 140
13976             || kind === 151
13977             || kind === 141
13978             || kind === 128
13979             || kind === 143
13980             || kind === 144
13981             || kind === 104
13982             || kind === 110
13983             || kind === 146
13984             || kind === 100
13985             || kind === 137
13986             || kind === 216
13987             || kind === 295
13988             || kind === 296
13989             || kind === 297
13990             || kind === 298
13991             || kind === 299
13992             || kind === 300
13993             || kind === 301;
13994     }
13995     ts.isTypeNodeKind = isTypeNodeKind;
13996     function isAccessExpression(node) {
13997         return node.kind === 194 || node.kind === 195;
13998     }
13999     ts.isAccessExpression = isAccessExpression;
14000     function getNameOfAccessExpression(node) {
14001         if (node.kind === 194) {
14002             return node.name;
14003         }
14004         ts.Debug.assert(node.kind === 195);
14005         return node.argumentExpression;
14006     }
14007     ts.getNameOfAccessExpression = getNameOfAccessExpression;
14008     function isBundleFileTextLike(section) {
14009         switch (section.kind) {
14010             case "text":
14011             case "internal":
14012                 return true;
14013             default:
14014                 return false;
14015         }
14016     }
14017     ts.isBundleFileTextLike = isBundleFileTextLike;
14018     function isNamedImportsOrExports(node) {
14019         return node.kind === 257 || node.kind === 261;
14020     }
14021     ts.isNamedImportsOrExports = isNamedImportsOrExports;
14022     function Symbol(flags, name) {
14023         this.flags = flags;
14024         this.escapedName = name;
14025         this.declarations = undefined;
14026         this.valueDeclaration = undefined;
14027         this.id = undefined;
14028         this.mergeId = undefined;
14029         this.parent = undefined;
14030     }
14031     function Type(checker, flags) {
14032         this.flags = flags;
14033         if (ts.Debug.isDebugging) {
14034             this.checker = checker;
14035         }
14036     }
14037     function Signature(checker, flags) {
14038         this.flags = flags;
14039         if (ts.Debug.isDebugging) {
14040             this.checker = checker;
14041         }
14042     }
14043     function Node(kind, pos, end) {
14044         this.pos = pos;
14045         this.end = end;
14046         this.kind = kind;
14047         this.id = 0;
14048         this.flags = 0;
14049         this.modifierFlagsCache = 0;
14050         this.transformFlags = 0;
14051         this.parent = undefined;
14052         this.original = undefined;
14053     }
14054     function Token(kind, pos, end) {
14055         this.pos = pos;
14056         this.end = end;
14057         this.kind = kind;
14058         this.id = 0;
14059         this.flags = 0;
14060         this.transformFlags = 0;
14061         this.parent = undefined;
14062     }
14063     function Identifier(kind, pos, end) {
14064         this.pos = pos;
14065         this.end = end;
14066         this.kind = kind;
14067         this.id = 0;
14068         this.flags = 0;
14069         this.transformFlags = 0;
14070         this.parent = undefined;
14071         this.original = undefined;
14072         this.flowNode = undefined;
14073     }
14074     function SourceMapSource(fileName, text, skipTrivia) {
14075         this.fileName = fileName;
14076         this.text = text;
14077         this.skipTrivia = skipTrivia || (function (pos) { return pos; });
14078     }
14079     ts.objectAllocator = {
14080         getNodeConstructor: function () { return Node; },
14081         getTokenConstructor: function () { return Token; },
14082         getIdentifierConstructor: function () { return Identifier; },
14083         getPrivateIdentifierConstructor: function () { return Node; },
14084         getSourceFileConstructor: function () { return Node; },
14085         getSymbolConstructor: function () { return Symbol; },
14086         getTypeConstructor: function () { return Type; },
14087         getSignatureConstructor: function () { return Signature; },
14088         getSourceMapSourceConstructor: function () { return SourceMapSource; },
14089     };
14090     function setObjectAllocator(alloc) {
14091         ts.objectAllocator = alloc;
14092     }
14093     ts.setObjectAllocator = setObjectAllocator;
14094     function formatStringFromArgs(text, args, baseIndex) {
14095         if (baseIndex === void 0) { baseIndex = 0; }
14096         return text.replace(/{(\d+)}/g, function (_match, index) { return "" + ts.Debug.checkDefined(args[+index + baseIndex]); });
14097     }
14098     ts.formatStringFromArgs = formatStringFromArgs;
14099     function setLocalizedDiagnosticMessages(messages) {
14100         ts.localizedDiagnosticMessages = messages;
14101     }
14102     ts.setLocalizedDiagnosticMessages = setLocalizedDiagnosticMessages;
14103     function getLocaleSpecificMessage(message) {
14104         return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message;
14105     }
14106     ts.getLocaleSpecificMessage = getLocaleSpecificMessage;
14107     function createFileDiagnostic(file, start, length, message) {
14108         ts.Debug.assertGreaterThanOrEqual(start, 0);
14109         ts.Debug.assertGreaterThanOrEqual(length, 0);
14110         if (file) {
14111             ts.Debug.assertLessThanOrEqual(start, file.text.length);
14112             ts.Debug.assertLessThanOrEqual(start + length, file.text.length);
14113         }
14114         var text = getLocaleSpecificMessage(message);
14115         if (arguments.length > 4) {
14116             text = formatStringFromArgs(text, arguments, 4);
14117         }
14118         return {
14119             file: file,
14120             start: start,
14121             length: length,
14122             messageText: text,
14123             category: message.category,
14124             code: message.code,
14125             reportsUnnecessary: message.reportsUnnecessary,
14126         };
14127     }
14128     ts.createFileDiagnostic = createFileDiagnostic;
14129     function formatMessage(_dummy, message) {
14130         var text = getLocaleSpecificMessage(message);
14131         if (arguments.length > 2) {
14132             text = formatStringFromArgs(text, arguments, 2);
14133         }
14134         return text;
14135     }
14136     ts.formatMessage = formatMessage;
14137     function createCompilerDiagnostic(message) {
14138         var text = getLocaleSpecificMessage(message);
14139         if (arguments.length > 1) {
14140             text = formatStringFromArgs(text, arguments, 1);
14141         }
14142         return {
14143             file: undefined,
14144             start: undefined,
14145             length: undefined,
14146             messageText: text,
14147             category: message.category,
14148             code: message.code,
14149             reportsUnnecessary: message.reportsUnnecessary,
14150         };
14151     }
14152     ts.createCompilerDiagnostic = createCompilerDiagnostic;
14153     function createCompilerDiagnosticFromMessageChain(chain) {
14154         return {
14155             file: undefined,
14156             start: undefined,
14157             length: undefined,
14158             code: chain.code,
14159             category: chain.category,
14160             messageText: chain.next ? chain : chain.messageText,
14161         };
14162     }
14163     ts.createCompilerDiagnosticFromMessageChain = createCompilerDiagnosticFromMessageChain;
14164     function chainDiagnosticMessages(details, message) {
14165         var text = getLocaleSpecificMessage(message);
14166         if (arguments.length > 2) {
14167             text = formatStringFromArgs(text, arguments, 2);
14168         }
14169         return {
14170             messageText: text,
14171             category: message.category,
14172             code: message.code,
14173             next: details === undefined || Array.isArray(details) ? details : [details]
14174         };
14175     }
14176     ts.chainDiagnosticMessages = chainDiagnosticMessages;
14177     function concatenateDiagnosticMessageChains(headChain, tailChain) {
14178         var lastChain = headChain;
14179         while (lastChain.next) {
14180             lastChain = lastChain.next[0];
14181         }
14182         lastChain.next = [tailChain];
14183     }
14184     ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains;
14185     function getDiagnosticFilePath(diagnostic) {
14186         return diagnostic.file ? diagnostic.file.path : undefined;
14187     }
14188     function compareDiagnostics(d1, d2) {
14189         return compareDiagnosticsSkipRelatedInformation(d1, d2) ||
14190             compareRelatedInformation(d1, d2) ||
14191             0;
14192     }
14193     ts.compareDiagnostics = compareDiagnostics;
14194     function compareDiagnosticsSkipRelatedInformation(d1, d2) {
14195         return ts.compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) ||
14196             ts.compareValues(d1.start, d2.start) ||
14197             ts.compareValues(d1.length, d2.length) ||
14198             ts.compareValues(d1.code, d2.code) ||
14199             compareMessageText(d1.messageText, d2.messageText) ||
14200             0;
14201     }
14202     ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation;
14203     function compareRelatedInformation(d1, d2) {
14204         if (!d1.relatedInformation && !d2.relatedInformation) {
14205             return 0;
14206         }
14207         if (d1.relatedInformation && d2.relatedInformation) {
14208             return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) {
14209                 var d2i = d2.relatedInformation[index];
14210                 return compareDiagnostics(d1i, d2i);
14211             }) || 0;
14212         }
14213         return d1.relatedInformation ? -1 : 1;
14214     }
14215     function compareMessageText(t1, t2) {
14216         if (typeof t1 === "string" && typeof t2 === "string") {
14217             return ts.compareStringsCaseSensitive(t1, t2);
14218         }
14219         else if (typeof t1 === "string") {
14220             return -1;
14221         }
14222         else if (typeof t2 === "string") {
14223             return 1;
14224         }
14225         var res = ts.compareStringsCaseSensitive(t1.messageText, t2.messageText);
14226         if (res) {
14227             return res;
14228         }
14229         if (!t1.next && !t2.next) {
14230             return 0;
14231         }
14232         if (!t1.next) {
14233             return -1;
14234         }
14235         if (!t2.next) {
14236             return 1;
14237         }
14238         var len = Math.min(t1.next.length, t2.next.length);
14239         for (var i = 0; i < len; i++) {
14240             res = compareMessageText(t1.next[i], t2.next[i]);
14241             if (res) {
14242                 return res;
14243             }
14244         }
14245         if (t1.next.length < t2.next.length) {
14246             return -1;
14247         }
14248         else if (t1.next.length > t2.next.length) {
14249             return 1;
14250         }
14251         return 0;
14252     }
14253     function getEmitScriptTarget(compilerOptions) {
14254         return compilerOptions.target || 0;
14255     }
14256     ts.getEmitScriptTarget = getEmitScriptTarget;
14257     function getEmitModuleKind(compilerOptions) {
14258         return typeof compilerOptions.module === "number" ?
14259             compilerOptions.module :
14260             getEmitScriptTarget(compilerOptions) >= 2 ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS;
14261     }
14262     ts.getEmitModuleKind = getEmitModuleKind;
14263     function getEmitModuleResolutionKind(compilerOptions) {
14264         var moduleResolution = compilerOptions.moduleResolution;
14265         if (moduleResolution === undefined) {
14266             moduleResolution = getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic;
14267         }
14268         return moduleResolution;
14269     }
14270     ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind;
14271     function hasJsonModuleEmitEnabled(options) {
14272         switch (getEmitModuleKind(options)) {
14273             case ts.ModuleKind.CommonJS:
14274             case ts.ModuleKind.AMD:
14275             case ts.ModuleKind.ES2015:
14276             case ts.ModuleKind.ES2020:
14277             case ts.ModuleKind.ESNext:
14278                 return true;
14279             default:
14280                 return false;
14281         }
14282     }
14283     ts.hasJsonModuleEmitEnabled = hasJsonModuleEmitEnabled;
14284     function unreachableCodeIsError(options) {
14285         return options.allowUnreachableCode === false;
14286     }
14287     ts.unreachableCodeIsError = unreachableCodeIsError;
14288     function unusedLabelIsError(options) {
14289         return options.allowUnusedLabels === false;
14290     }
14291     ts.unusedLabelIsError = unusedLabelIsError;
14292     function getAreDeclarationMapsEnabled(options) {
14293         return !!(getEmitDeclarations(options) && options.declarationMap);
14294     }
14295     ts.getAreDeclarationMapsEnabled = getAreDeclarationMapsEnabled;
14296     function getAllowSyntheticDefaultImports(compilerOptions) {
14297         var moduleKind = getEmitModuleKind(compilerOptions);
14298         return compilerOptions.allowSyntheticDefaultImports !== undefined
14299             ? compilerOptions.allowSyntheticDefaultImports
14300             : compilerOptions.esModuleInterop ||
14301                 moduleKind === ts.ModuleKind.System;
14302     }
14303     ts.getAllowSyntheticDefaultImports = getAllowSyntheticDefaultImports;
14304     function getEmitDeclarations(compilerOptions) {
14305         return !!(compilerOptions.declaration || compilerOptions.composite);
14306     }
14307     ts.getEmitDeclarations = getEmitDeclarations;
14308     function isIncrementalCompilation(options) {
14309         return !!(options.incremental || options.composite);
14310     }
14311     ts.isIncrementalCompilation = isIncrementalCompilation;
14312     function getStrictOptionValue(compilerOptions, flag) {
14313         return compilerOptions[flag] === undefined ? !!compilerOptions.strict : !!compilerOptions[flag];
14314     }
14315     ts.getStrictOptionValue = getStrictOptionValue;
14316     function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) {
14317         return oldOptions !== newOptions &&
14318             ts.semanticDiagnosticsOptionDeclarations.some(function (option) { return !isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); });
14319     }
14320     ts.compilerOptionsAffectSemanticDiagnostics = compilerOptionsAffectSemanticDiagnostics;
14321     function compilerOptionsAffectEmit(newOptions, oldOptions) {
14322         return oldOptions !== newOptions &&
14323             ts.affectsEmitOptionDeclarations.some(function (option) { return !isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); });
14324     }
14325     ts.compilerOptionsAffectEmit = compilerOptionsAffectEmit;
14326     function getCompilerOptionValue(options, option) {
14327         return option.strictFlag ? getStrictOptionValue(options, option.name) : options[option.name];
14328     }
14329     ts.getCompilerOptionValue = getCompilerOptionValue;
14330     function hasZeroOrOneAsteriskCharacter(str) {
14331         var seenAsterisk = false;
14332         for (var i = 0; i < str.length; i++) {
14333             if (str.charCodeAt(i) === 42) {
14334                 if (!seenAsterisk) {
14335                     seenAsterisk = true;
14336                 }
14337                 else {
14338                     return false;
14339                 }
14340             }
14341         }
14342         return true;
14343     }
14344     ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter;
14345     function discoverProbableSymlinks(files, getCanonicalFileName, cwd) {
14346         var result = ts.createMap();
14347         var symlinks = ts.flatten(ts.mapDefined(files, function (sf) {
14348             return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) {
14349                 return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined;
14350             })));
14351         }));
14352         for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) {
14353             var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1];
14354             var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName), commonResolved = _b[0], commonOriginal = _b[1];
14355             result.set(commonOriginal, commonResolved);
14356         }
14357         return result;
14358     }
14359     ts.discoverProbableSymlinks = discoverProbableSymlinks;
14360     function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) {
14361         var aParts = ts.getPathComponents(ts.toPath(a, cwd, getCanonicalFileName));
14362         var bParts = ts.getPathComponents(ts.toPath(b, cwd, getCanonicalFileName));
14363         while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) &&
14364             !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) &&
14365             getCanonicalFileName(aParts[aParts.length - 1]) === getCanonicalFileName(bParts[bParts.length - 1])) {
14366             aParts.pop();
14367             bParts.pop();
14368         }
14369         return [ts.getPathFromPathComponents(aParts), ts.getPathFromPathComponents(bParts)];
14370     }
14371     function isNodeModulesOrScopedPackageDirectory(s, getCanonicalFileName) {
14372         return getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@");
14373     }
14374     function stripLeadingDirectorySeparator(s) {
14375         return ts.isAnyDirectorySeparator(s.charCodeAt(0)) ? s.slice(1) : undefined;
14376     }
14377     function tryRemoveDirectoryPrefix(path, dirPath, getCanonicalFileName) {
14378         var withoutPrefix = ts.tryRemovePrefix(path, dirPath, getCanonicalFileName);
14379         return withoutPrefix === undefined ? undefined : stripLeadingDirectorySeparator(withoutPrefix);
14380     }
14381     ts.tryRemoveDirectoryPrefix = tryRemoveDirectoryPrefix;
14382     var reservedCharacterPattern = /[^\w\s\/]/g;
14383     function regExpEscape(text) {
14384         return text.replace(reservedCharacterPattern, escapeRegExpCharacter);
14385     }
14386     ts.regExpEscape = regExpEscape;
14387     function escapeRegExpCharacter(match) {
14388         return "\\" + match;
14389     }
14390     var wildcardCharCodes = [42, 63];
14391     ts.commonPackageFolders = ["node_modules", "bower_components", "jspm_packages"];
14392     var implicitExcludePathRegexPattern = "(?!(" + ts.commonPackageFolders.join("|") + ")(/|$))";
14393     var filesMatcher = {
14394         singleAsteriskRegexFragment: "([^./]|(\\.(?!min\\.js$))?)*",
14395         doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?",
14396         replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, filesMatcher.singleAsteriskRegexFragment); }
14397     };
14398     var directoriesMatcher = {
14399         singleAsteriskRegexFragment: "[^/]*",
14400         doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?",
14401         replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, directoriesMatcher.singleAsteriskRegexFragment); }
14402     };
14403     var excludeMatcher = {
14404         singleAsteriskRegexFragment: "[^/]*",
14405         doubleAsteriskRegexFragment: "(/.+?)?",
14406         replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, excludeMatcher.singleAsteriskRegexFragment); }
14407     };
14408     var wildcardMatchers = {
14409         files: filesMatcher,
14410         directories: directoriesMatcher,
14411         exclude: excludeMatcher
14412     };
14413     function getRegularExpressionForWildcard(specs, basePath, usage) {
14414         var patterns = getRegularExpressionsForWildcards(specs, basePath, usage);
14415         if (!patterns || !patterns.length) {
14416             return undefined;
14417         }
14418         var pattern = patterns.map(function (pattern) { return "(" + pattern + ")"; }).join("|");
14419         var terminator = usage === "exclude" ? "($|/)" : "$";
14420         return "^(" + pattern + ")" + terminator;
14421     }
14422     ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard;
14423     function getRegularExpressionsForWildcards(specs, basePath, usage) {
14424         if (specs === undefined || specs.length === 0) {
14425             return undefined;
14426         }
14427         return ts.flatMap(specs, function (spec) {
14428             return spec && getSubPatternFromSpec(spec, basePath, usage, wildcardMatchers[usage]);
14429         });
14430     }
14431     ts.getRegularExpressionsForWildcards = getRegularExpressionsForWildcards;
14432     function isImplicitGlob(lastPathComponent) {
14433         return !/[.*?]/.test(lastPathComponent);
14434     }
14435     ts.isImplicitGlob = isImplicitGlob;
14436     function getSubPatternFromSpec(spec, basePath, usage, _a) {
14437         var singleAsteriskRegexFragment = _a.singleAsteriskRegexFragment, doubleAsteriskRegexFragment = _a.doubleAsteriskRegexFragment, replaceWildcardCharacter = _a.replaceWildcardCharacter;
14438         var subpattern = "";
14439         var hasWrittenComponent = false;
14440         var components = ts.getNormalizedPathComponents(spec, basePath);
14441         var lastComponent = ts.last(components);
14442         if (usage !== "exclude" && lastComponent === "**") {
14443             return undefined;
14444         }
14445         components[0] = ts.removeTrailingDirectorySeparator(components[0]);
14446         if (isImplicitGlob(lastComponent)) {
14447             components.push("**", "*");
14448         }
14449         var optionalCount = 0;
14450         for (var _i = 0, components_1 = components; _i < components_1.length; _i++) {
14451             var component = components_1[_i];
14452             if (component === "**") {
14453                 subpattern += doubleAsteriskRegexFragment;
14454             }
14455             else {
14456                 if (usage === "directories") {
14457                     subpattern += "(";
14458                     optionalCount++;
14459                 }
14460                 if (hasWrittenComponent) {
14461                     subpattern += ts.directorySeparator;
14462                 }
14463                 if (usage !== "exclude") {
14464                     var componentPattern = "";
14465                     if (component.charCodeAt(0) === 42) {
14466                         componentPattern += "([^./]" + singleAsteriskRegexFragment + ")?";
14467                         component = component.substr(1);
14468                     }
14469                     else if (component.charCodeAt(0) === 63) {
14470                         componentPattern += "[^./]";
14471                         component = component.substr(1);
14472                     }
14473                     componentPattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter);
14474                     if (componentPattern !== component) {
14475                         subpattern += implicitExcludePathRegexPattern;
14476                     }
14477                     subpattern += componentPattern;
14478                 }
14479                 else {
14480                     subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter);
14481                 }
14482             }
14483             hasWrittenComponent = true;
14484         }
14485         while (optionalCount > 0) {
14486             subpattern += ")?";
14487             optionalCount--;
14488         }
14489         return subpattern;
14490     }
14491     function replaceWildcardCharacter(match, singleAsteriskRegexFragment) {
14492         return match === "*" ? singleAsteriskRegexFragment : match === "?" ? "[^/]" : "\\" + match;
14493     }
14494     function getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory) {
14495         path = ts.normalizePath(path);
14496         currentDirectory = ts.normalizePath(currentDirectory);
14497         var absolutePath = ts.combinePaths(currentDirectory, path);
14498         return {
14499             includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }),
14500             includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"),
14501             includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"),
14502             excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"),
14503             basePaths: getBasePaths(path, includes, useCaseSensitiveFileNames)
14504         };
14505     }
14506     ts.getFileMatcherPatterns = getFileMatcherPatterns;
14507     function getRegexFromPattern(pattern, useCaseSensitiveFileNames) {
14508         return new RegExp(pattern, useCaseSensitiveFileNames ? "" : "i");
14509     }
14510     ts.getRegexFromPattern = getRegexFromPattern;
14511     function matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath) {
14512         path = ts.normalizePath(path);
14513         currentDirectory = ts.normalizePath(currentDirectory);
14514         var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory);
14515         var includeFileRegexes = patterns.includeFilePatterns && patterns.includeFilePatterns.map(function (pattern) { return getRegexFromPattern(pattern, useCaseSensitiveFileNames); });
14516         var includeDirectoryRegex = patterns.includeDirectoryPattern && getRegexFromPattern(patterns.includeDirectoryPattern, useCaseSensitiveFileNames);
14517         var excludeRegex = patterns.excludePattern && getRegexFromPattern(patterns.excludePattern, useCaseSensitiveFileNames);
14518         var results = includeFileRegexes ? includeFileRegexes.map(function () { return []; }) : [[]];
14519         var visited = ts.createMap();
14520         var toCanonical = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
14521         for (var _i = 0, _a = patterns.basePaths; _i < _a.length; _i++) {
14522             var basePath = _a[_i];
14523             visitDirectory(basePath, ts.combinePaths(currentDirectory, basePath), depth);
14524         }
14525         return ts.flatten(results);
14526         function visitDirectory(path, absolutePath, depth) {
14527             var canonicalPath = toCanonical(realpath(absolutePath));
14528             if (visited.has(canonicalPath))
14529                 return;
14530             visited.set(canonicalPath, true);
14531             var _a = getFileSystemEntries(path), files = _a.files, directories = _a.directories;
14532             var _loop_1 = function (current) {
14533                 var name = ts.combinePaths(path, current);
14534                 var absoluteName = ts.combinePaths(absolutePath, current);
14535                 if (extensions && !ts.fileExtensionIsOneOf(name, extensions))
14536                     return "continue";
14537                 if (excludeRegex && excludeRegex.test(absoluteName))
14538                     return "continue";
14539                 if (!includeFileRegexes) {
14540                     results[0].push(name);
14541                 }
14542                 else {
14543                     var includeIndex = ts.findIndex(includeFileRegexes, function (re) { return re.test(absoluteName); });
14544                     if (includeIndex !== -1) {
14545                         results[includeIndex].push(name);
14546                     }
14547                 }
14548             };
14549             for (var _i = 0, _b = ts.sort(files, ts.compareStringsCaseSensitive); _i < _b.length; _i++) {
14550                 var current = _b[_i];
14551                 _loop_1(current);
14552             }
14553             if (depth !== undefined) {
14554                 depth--;
14555                 if (depth === 0) {
14556                     return;
14557                 }
14558             }
14559             for (var _c = 0, _d = ts.sort(directories, ts.compareStringsCaseSensitive); _c < _d.length; _c++) {
14560                 var current = _d[_c];
14561                 var name = ts.combinePaths(path, current);
14562                 var absoluteName = ts.combinePaths(absolutePath, current);
14563                 if ((!includeDirectoryRegex || includeDirectoryRegex.test(absoluteName)) &&
14564                     (!excludeRegex || !excludeRegex.test(absoluteName))) {
14565                     visitDirectory(name, absoluteName, depth);
14566                 }
14567             }
14568         }
14569     }
14570     ts.matchFiles = matchFiles;
14571     function getBasePaths(path, includes, useCaseSensitiveFileNames) {
14572         var basePaths = [path];
14573         if (includes) {
14574             var includeBasePaths = [];
14575             for (var _i = 0, includes_1 = includes; _i < includes_1.length; _i++) {
14576                 var include = includes_1[_i];
14577                 var absolute = ts.isRootedDiskPath(include) ? include : ts.normalizePath(ts.combinePaths(path, include));
14578                 includeBasePaths.push(getIncludeBasePath(absolute));
14579             }
14580             includeBasePaths.sort(ts.getStringComparer(!useCaseSensitiveFileNames));
14581             var _loop_2 = function (includeBasePath) {
14582                 if (ts.every(basePaths, function (basePath) { return !ts.containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) {
14583                     basePaths.push(includeBasePath);
14584                 }
14585             };
14586             for (var _a = 0, includeBasePaths_1 = includeBasePaths; _a < includeBasePaths_1.length; _a++) {
14587                 var includeBasePath = includeBasePaths_1[_a];
14588                 _loop_2(includeBasePath);
14589             }
14590         }
14591         return basePaths;
14592     }
14593     function getIncludeBasePath(absolute) {
14594         var wildcardOffset = ts.indexOfAnyCharCode(absolute, wildcardCharCodes);
14595         if (wildcardOffset < 0) {
14596             return !ts.hasExtension(absolute)
14597                 ? absolute
14598                 : ts.removeTrailingDirectorySeparator(ts.getDirectoryPath(absolute));
14599         }
14600         return absolute.substring(0, absolute.lastIndexOf(ts.directorySeparator, wildcardOffset));
14601     }
14602     function ensureScriptKind(fileName, scriptKind) {
14603         return scriptKind || getScriptKindFromFileName(fileName) || 3;
14604     }
14605     ts.ensureScriptKind = ensureScriptKind;
14606     function getScriptKindFromFileName(fileName) {
14607         var ext = fileName.substr(fileName.lastIndexOf("."));
14608         switch (ext.toLowerCase()) {
14609             case ".js":
14610                 return 1;
14611             case ".jsx":
14612                 return 2;
14613             case ".ts":
14614                 return 3;
14615             case ".tsx":
14616                 return 4;
14617             case ".json":
14618                 return 6;
14619             default:
14620                 return 0;
14621         }
14622     }
14623     ts.getScriptKindFromFileName = getScriptKindFromFileName;
14624     ts.supportedTSExtensions = [".ts", ".tsx", ".d.ts"];
14625     ts.supportedTSExtensionsWithJson = [".ts", ".tsx", ".d.ts", ".json"];
14626     ts.supportedTSExtensionsForExtractExtension = [".d.ts", ".ts", ".tsx"];
14627     ts.supportedJSExtensions = [".js", ".jsx"];
14628     ts.supportedJSAndJsonExtensions = [".js", ".jsx", ".json"];
14629     var allSupportedExtensions = __spreadArrays(ts.supportedTSExtensions, ts.supportedJSExtensions);
14630     var allSupportedExtensionsWithJson = __spreadArrays(ts.supportedTSExtensions, ts.supportedJSExtensions, [".json"]);
14631     function getSupportedExtensions(options, extraFileExtensions) {
14632         var needJsExtensions = options && options.allowJs;
14633         if (!extraFileExtensions || extraFileExtensions.length === 0) {
14634             return needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions;
14635         }
14636         var extensions = __spreadArrays(needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions, ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 || needJsExtensions && isJSLike(x.scriptKind) ? x.extension : undefined; }));
14637         return ts.deduplicate(extensions, ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive);
14638     }
14639     ts.getSupportedExtensions = getSupportedExtensions;
14640     function getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions) {
14641         if (!options || !options.resolveJsonModule) {
14642             return supportedExtensions;
14643         }
14644         if (supportedExtensions === allSupportedExtensions) {
14645             return allSupportedExtensionsWithJson;
14646         }
14647         if (supportedExtensions === ts.supportedTSExtensions) {
14648             return ts.supportedTSExtensionsWithJson;
14649         }
14650         return __spreadArrays(supportedExtensions, [".json"]);
14651     }
14652     ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule = getSuppoertedExtensionsWithJsonIfResolveJsonModule;
14653     function isJSLike(scriptKind) {
14654         return scriptKind === 1 || scriptKind === 2;
14655     }
14656     function hasJSFileExtension(fileName) {
14657         return ts.some(ts.supportedJSExtensions, function (extension) { return ts.fileExtensionIs(fileName, extension); });
14658     }
14659     ts.hasJSFileExtension = hasJSFileExtension;
14660     function hasTSFileExtension(fileName) {
14661         return ts.some(ts.supportedTSExtensions, function (extension) { return ts.fileExtensionIs(fileName, extension); });
14662     }
14663     ts.hasTSFileExtension = hasTSFileExtension;
14664     function isSupportedSourceFileName(fileName, compilerOptions, extraFileExtensions) {
14665         if (!fileName) {
14666             return false;
14667         }
14668         var supportedExtensions = getSupportedExtensions(compilerOptions, extraFileExtensions);
14669         for (var _i = 0, _a = getSuppoertedExtensionsWithJsonIfResolveJsonModule(compilerOptions, supportedExtensions); _i < _a.length; _i++) {
14670             var extension = _a[_i];
14671             if (ts.fileExtensionIs(fileName, extension)) {
14672                 return true;
14673             }
14674         }
14675         return false;
14676     }
14677     ts.isSupportedSourceFileName = isSupportedSourceFileName;
14678     function getExtensionPriority(path, supportedExtensions) {
14679         for (var i = supportedExtensions.length - 1; i >= 0; i--) {
14680             if (ts.fileExtensionIs(path, supportedExtensions[i])) {
14681                 return adjustExtensionPriority(i, supportedExtensions);
14682             }
14683         }
14684         return 0;
14685     }
14686     ts.getExtensionPriority = getExtensionPriority;
14687     function adjustExtensionPriority(extensionPriority, supportedExtensions) {
14688         if (extensionPriority < 2) {
14689             return 0;
14690         }
14691         else if (extensionPriority < supportedExtensions.length) {
14692             return 2;
14693         }
14694         else {
14695             return supportedExtensions.length;
14696         }
14697     }
14698     ts.adjustExtensionPriority = adjustExtensionPriority;
14699     function getNextLowestExtensionPriority(extensionPriority, supportedExtensions) {
14700         if (extensionPriority < 2) {
14701             return 2;
14702         }
14703         else {
14704             return supportedExtensions.length;
14705         }
14706     }
14707     ts.getNextLowestExtensionPriority = getNextLowestExtensionPriority;
14708     var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx", ".json"];
14709     function removeFileExtension(path) {
14710         for (var _i = 0, extensionsToRemove_1 = extensionsToRemove; _i < extensionsToRemove_1.length; _i++) {
14711             var ext = extensionsToRemove_1[_i];
14712             var extensionless = tryRemoveExtension(path, ext);
14713             if (extensionless !== undefined) {
14714                 return extensionless;
14715             }
14716         }
14717         return path;
14718     }
14719     ts.removeFileExtension = removeFileExtension;
14720     function tryRemoveExtension(path, extension) {
14721         return ts.fileExtensionIs(path, extension) ? removeExtension(path, extension) : undefined;
14722     }
14723     ts.tryRemoveExtension = tryRemoveExtension;
14724     function removeExtension(path, extension) {
14725         return path.substring(0, path.length - extension.length);
14726     }
14727     ts.removeExtension = removeExtension;
14728     function changeExtension(path, newExtension) {
14729         return ts.changeAnyExtension(path, newExtension, extensionsToRemove, false);
14730     }
14731     ts.changeExtension = changeExtension;
14732     function tryParsePattern(pattern) {
14733         ts.Debug.assert(hasZeroOrOneAsteriskCharacter(pattern));
14734         var indexOfStar = pattern.indexOf("*");
14735         return indexOfStar === -1 ? undefined : {
14736             prefix: pattern.substr(0, indexOfStar),
14737             suffix: pattern.substr(indexOfStar + 1)
14738         };
14739     }
14740     ts.tryParsePattern = tryParsePattern;
14741     function positionIsSynthesized(pos) {
14742         return !(pos >= 0);
14743     }
14744     ts.positionIsSynthesized = positionIsSynthesized;
14745     function extensionIsTS(ext) {
14746         return ext === ".ts" || ext === ".tsx" || ext === ".d.ts";
14747     }
14748     ts.extensionIsTS = extensionIsTS;
14749     function resolutionExtensionIsTSOrJson(ext) {
14750         return extensionIsTS(ext) || ext === ".json";
14751     }
14752     ts.resolutionExtensionIsTSOrJson = resolutionExtensionIsTSOrJson;
14753     function extensionFromPath(path) {
14754         var ext = tryGetExtensionFromPath(path);
14755         return ext !== undefined ? ext : ts.Debug.fail("File " + path + " has unknown extension.");
14756     }
14757     ts.extensionFromPath = extensionFromPath;
14758     function isAnySupportedFileExtension(path) {
14759         return tryGetExtensionFromPath(path) !== undefined;
14760     }
14761     ts.isAnySupportedFileExtension = isAnySupportedFileExtension;
14762     function tryGetExtensionFromPath(path) {
14763         return ts.find(extensionsToRemove, function (e) { return ts.fileExtensionIs(path, e); });
14764     }
14765     ts.tryGetExtensionFromPath = tryGetExtensionFromPath;
14766     function isCheckJsEnabledForFile(sourceFile, compilerOptions) {
14767         return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs;
14768     }
14769     ts.isCheckJsEnabledForFile = isCheckJsEnabledForFile;
14770     ts.emptyFileSystemEntries = {
14771         files: ts.emptyArray,
14772         directories: ts.emptyArray
14773     };
14774     function matchPatternOrExact(patternStrings, candidate) {
14775         var patterns = [];
14776         for (var _i = 0, patternStrings_1 = patternStrings; _i < patternStrings_1.length; _i++) {
14777             var patternString = patternStrings_1[_i];
14778             if (!hasZeroOrOneAsteriskCharacter(patternString))
14779                 continue;
14780             var pattern = tryParsePattern(patternString);
14781             if (pattern) {
14782                 patterns.push(pattern);
14783             }
14784             else if (patternString === candidate) {
14785                 return patternString;
14786             }
14787         }
14788         return ts.findBestPatternMatch(patterns, function (_) { return _; }, candidate);
14789     }
14790     ts.matchPatternOrExact = matchPatternOrExact;
14791     function sliceAfter(arr, value) {
14792         var index = arr.indexOf(value);
14793         ts.Debug.assert(index !== -1);
14794         return arr.slice(index);
14795     }
14796     ts.sliceAfter = sliceAfter;
14797     function addRelatedInfo(diagnostic) {
14798         var _a;
14799         var relatedInformation = [];
14800         for (var _i = 1; _i < arguments.length; _i++) {
14801             relatedInformation[_i - 1] = arguments[_i];
14802         }
14803         if (!relatedInformation.length) {
14804             return diagnostic;
14805         }
14806         if (!diagnostic.relatedInformation) {
14807             diagnostic.relatedInformation = [];
14808         }
14809         (_a = diagnostic.relatedInformation).push.apply(_a, relatedInformation);
14810         return diagnostic;
14811     }
14812     ts.addRelatedInfo = addRelatedInfo;
14813     function minAndMax(arr, getValue) {
14814         ts.Debug.assert(arr.length !== 0);
14815         var min = getValue(arr[0]);
14816         var max = min;
14817         for (var i = 1; i < arr.length; i++) {
14818             var value = getValue(arr[i]);
14819             if (value < min) {
14820                 min = value;
14821             }
14822             else if (value > max) {
14823                 max = value;
14824             }
14825         }
14826         return { min: min, max: max };
14827     }
14828     ts.minAndMax = minAndMax;
14829     var NodeSet = (function () {
14830         function NodeSet() {
14831             this.map = ts.createMap();
14832         }
14833         NodeSet.prototype.add = function (node) {
14834             this.map.set(String(ts.getNodeId(node)), node);
14835         };
14836         NodeSet.prototype.tryAdd = function (node) {
14837             if (this.has(node))
14838                 return false;
14839             this.add(node);
14840             return true;
14841         };
14842         NodeSet.prototype.has = function (node) {
14843             return this.map.has(String(ts.getNodeId(node)));
14844         };
14845         NodeSet.prototype.forEach = function (cb) {
14846             this.map.forEach(cb);
14847         };
14848         NodeSet.prototype.some = function (pred) {
14849             return forEachEntry(this.map, pred) || false;
14850         };
14851         return NodeSet;
14852     }());
14853     ts.NodeSet = NodeSet;
14854     var NodeMap = (function () {
14855         function NodeMap() {
14856             this.map = ts.createMap();
14857         }
14858         NodeMap.prototype.get = function (node) {
14859             var res = this.map.get(String(ts.getNodeId(node)));
14860             return res && res.value;
14861         };
14862         NodeMap.prototype.getOrUpdate = function (node, setValue) {
14863             var res = this.get(node);
14864             if (res)
14865                 return res;
14866             var value = setValue();
14867             this.set(node, value);
14868             return value;
14869         };
14870         NodeMap.prototype.set = function (node, value) {
14871             this.map.set(String(ts.getNodeId(node)), { node: node, value: value });
14872         };
14873         NodeMap.prototype.has = function (node) {
14874             return this.map.has(String(ts.getNodeId(node)));
14875         };
14876         NodeMap.prototype.forEach = function (cb) {
14877             this.map.forEach(function (_a) {
14878                 var node = _a.node, value = _a.value;
14879                 return cb(value, node);
14880             });
14881         };
14882         return NodeMap;
14883     }());
14884     ts.NodeMap = NodeMap;
14885     function rangeOfNode(node) {
14886         return { pos: getTokenPosOfNode(node), end: node.end };
14887     }
14888     ts.rangeOfNode = rangeOfNode;
14889     function rangeOfTypeParameters(typeParameters) {
14890         return { pos: typeParameters.pos - 1, end: typeParameters.end + 1 };
14891     }
14892     ts.rangeOfTypeParameters = rangeOfTypeParameters;
14893     function skipTypeChecking(sourceFile, options, host) {
14894         return (options.skipLibCheck && sourceFile.isDeclarationFile ||
14895             options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib) ||
14896             host.isSourceOfProjectReferenceRedirect(sourceFile.fileName);
14897     }
14898     ts.skipTypeChecking = skipTypeChecking;
14899     function isJsonEqual(a, b) {
14900         return a === b || typeof a === "object" && a !== null && typeof b === "object" && b !== null && ts.equalOwnProperties(a, b, isJsonEqual);
14901     }
14902     ts.isJsonEqual = isJsonEqual;
14903     function getOrUpdate(map, key, getDefault) {
14904         var got = map.get(key);
14905         if (got === undefined) {
14906             var value = getDefault();
14907             map.set(key, value);
14908             return value;
14909         }
14910         else {
14911             return got;
14912         }
14913     }
14914     ts.getOrUpdate = getOrUpdate;
14915     function parsePseudoBigInt(stringValue) {
14916         var log2Base;
14917         switch (stringValue.charCodeAt(1)) {
14918             case 98:
14919             case 66:
14920                 log2Base = 1;
14921                 break;
14922             case 111:
14923             case 79:
14924                 log2Base = 3;
14925                 break;
14926             case 120:
14927             case 88:
14928                 log2Base = 4;
14929                 break;
14930             default:
14931                 var nIndex = stringValue.length - 1;
14932                 var nonZeroStart = 0;
14933                 while (stringValue.charCodeAt(nonZeroStart) === 48) {
14934                     nonZeroStart++;
14935                 }
14936                 return stringValue.slice(nonZeroStart, nIndex) || "0";
14937         }
14938         var startIndex = 2, endIndex = stringValue.length - 1;
14939         var bitsNeeded = (endIndex - startIndex) * log2Base;
14940         var segments = new Uint16Array((bitsNeeded >>> 4) + (bitsNeeded & 15 ? 1 : 0));
14941         for (var i = endIndex - 1, bitOffset = 0; i >= startIndex; i--, bitOffset += log2Base) {
14942             var segment = bitOffset >>> 4;
14943             var digitChar = stringValue.charCodeAt(i);
14944             var digit = digitChar <= 57
14945                 ? digitChar - 48
14946                 : 10 + digitChar -
14947                     (digitChar <= 70 ? 65 : 97);
14948             var shiftedDigit = digit << (bitOffset & 15);
14949             segments[segment] |= shiftedDigit;
14950             var residual = shiftedDigit >>> 16;
14951             if (residual)
14952                 segments[segment + 1] |= residual;
14953         }
14954         var base10Value = "";
14955         var firstNonzeroSegment = segments.length - 1;
14956         var segmentsRemaining = true;
14957         while (segmentsRemaining) {
14958             var mod10 = 0;
14959             segmentsRemaining = false;
14960             for (var segment = firstNonzeroSegment; segment >= 0; segment--) {
14961                 var newSegment = mod10 << 16 | segments[segment];
14962                 var segmentValue = (newSegment / 10) | 0;
14963                 segments[segment] = segmentValue;
14964                 mod10 = newSegment - segmentValue * 10;
14965                 if (segmentValue && !segmentsRemaining) {
14966                     firstNonzeroSegment = segment;
14967                     segmentsRemaining = true;
14968                 }
14969             }
14970             base10Value = mod10 + base10Value;
14971         }
14972         return base10Value;
14973     }
14974     ts.parsePseudoBigInt = parsePseudoBigInt;
14975     function pseudoBigIntToString(_a) {
14976         var negative = _a.negative, base10Value = _a.base10Value;
14977         return (negative && base10Value !== "0" ? "-" : "") + base10Value;
14978     }
14979     ts.pseudoBigIntToString = pseudoBigIntToString;
14980     function isValidTypeOnlyAliasUseSite(useSite) {
14981         return !!(useSite.flags & 8388608)
14982             || isPartOfTypeQuery(useSite)
14983             || isIdentifierInNonEmittingHeritageClause(useSite)
14984             || isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite)
14985             || !isExpressionNode(useSite);
14986     }
14987     ts.isValidTypeOnlyAliasUseSite = isValidTypeOnlyAliasUseSite;
14988     function typeOnlyDeclarationIsExport(typeOnlyDeclaration) {
14989         return typeOnlyDeclaration.kind === 263;
14990     }
14991     ts.typeOnlyDeclarationIsExport = typeOnlyDeclarationIsExport;
14992     function isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(node) {
14993         while (node.kind === 75 || node.kind === 194) {
14994             node = node.parent;
14995         }
14996         if (node.kind !== 154) {
14997             return false;
14998         }
14999         if (hasModifier(node.parent, 128)) {
15000             return true;
15001         }
15002         var containerKind = node.parent.parent.kind;
15003         return containerKind === 246 || containerKind === 173;
15004     }
15005     function isIdentifierInNonEmittingHeritageClause(node) {
15006         if (node.kind !== 75)
15007             return false;
15008         var heritageClause = findAncestor(node.parent, function (parent) {
15009             switch (parent.kind) {
15010                 case 279:
15011                     return true;
15012                 case 194:
15013                 case 216:
15014                     return false;
15015                 default:
15016                     return "quit";
15017             }
15018         });
15019         return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 113 || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 246;
15020     }
15021     function isIdentifierTypeReference(node) {
15022         return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName);
15023     }
15024     ts.isIdentifierTypeReference = isIdentifierTypeReference;
15025     function arrayIsHomogeneous(array, comparer) {
15026         if (comparer === void 0) { comparer = ts.equateValues; }
15027         if (array.length < 2)
15028             return true;
15029         var first = array[0];
15030         for (var i = 1, length_1 = array.length; i < length_1; i++) {
15031             var target = array[i];
15032             if (!comparer(first, target))
15033                 return false;
15034         }
15035         return true;
15036     }
15037     ts.arrayIsHomogeneous = arrayIsHomogeneous;
15038 })(ts || (ts = {}));
15039 var ts;
15040 (function (ts) {
15041     var NodeConstructor;
15042     var TokenConstructor;
15043     var IdentifierConstructor;
15044     var PrivateIdentifierConstructor;
15045     var SourceFileConstructor;
15046     function createNode(kind, pos, end) {
15047         if (kind === 290) {
15048             return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end);
15049         }
15050         else if (kind === 75) {
15051             return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end);
15052         }
15053         else if (kind === 76) {
15054             return new (PrivateIdentifierConstructor || (PrivateIdentifierConstructor = ts.objectAllocator.getPrivateIdentifierConstructor()))(kind, pos, end);
15055         }
15056         else if (!ts.isNodeKind(kind)) {
15057             return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end);
15058         }
15059         else {
15060             return new (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor()))(kind, pos, end);
15061         }
15062     }
15063     ts.createNode = createNode;
15064     function visitNode(cbNode, node) {
15065         return node && cbNode(node);
15066     }
15067     function visitNodes(cbNode, cbNodes, nodes) {
15068         if (nodes) {
15069             if (cbNodes) {
15070                 return cbNodes(nodes);
15071             }
15072             for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
15073                 var node = nodes_1[_i];
15074                 var result = cbNode(node);
15075                 if (result) {
15076                     return result;
15077                 }
15078             }
15079         }
15080     }
15081     function isJSDocLikeText(text, start) {
15082         return text.charCodeAt(start + 1) === 42 &&
15083             text.charCodeAt(start + 2) === 42 &&
15084             text.charCodeAt(start + 3) !== 47;
15085     }
15086     ts.isJSDocLikeText = isJSDocLikeText;
15087     function forEachChild(node, cbNode, cbNodes) {
15088         if (!node || node.kind <= 152) {
15089             return;
15090         }
15091         switch (node.kind) {
15092             case 153:
15093                 return visitNode(cbNode, node.left) ||
15094                     visitNode(cbNode, node.right);
15095             case 155:
15096                 return visitNode(cbNode, node.name) ||
15097                     visitNode(cbNode, node.constraint) ||
15098                     visitNode(cbNode, node.default) ||
15099                     visitNode(cbNode, node.expression);
15100             case 282:
15101                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15102                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15103                     visitNode(cbNode, node.name) ||
15104                     visitNode(cbNode, node.questionToken) ||
15105                     visitNode(cbNode, node.exclamationToken) ||
15106                     visitNode(cbNode, node.equalsToken) ||
15107                     visitNode(cbNode, node.objectAssignmentInitializer);
15108             case 283:
15109                 return visitNode(cbNode, node.expression);
15110             case 156:
15111                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15112                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15113                     visitNode(cbNode, node.dotDotDotToken) ||
15114                     visitNode(cbNode, node.name) ||
15115                     visitNode(cbNode, node.questionToken) ||
15116                     visitNode(cbNode, node.type) ||
15117                     visitNode(cbNode, node.initializer);
15118             case 159:
15119                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15120                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15121                     visitNode(cbNode, node.name) ||
15122                     visitNode(cbNode, node.questionToken) ||
15123                     visitNode(cbNode, node.exclamationToken) ||
15124                     visitNode(cbNode, node.type) ||
15125                     visitNode(cbNode, node.initializer);
15126             case 158:
15127                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15128                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15129                     visitNode(cbNode, node.name) ||
15130                     visitNode(cbNode, node.questionToken) ||
15131                     visitNode(cbNode, node.type) ||
15132                     visitNode(cbNode, node.initializer);
15133             case 281:
15134                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15135                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15136                     visitNode(cbNode, node.name) ||
15137                     visitNode(cbNode, node.questionToken) ||
15138                     visitNode(cbNode, node.initializer);
15139             case 242:
15140                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15141                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15142                     visitNode(cbNode, node.name) ||
15143                     visitNode(cbNode, node.exclamationToken) ||
15144                     visitNode(cbNode, node.type) ||
15145                     visitNode(cbNode, node.initializer);
15146             case 191:
15147                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15148                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15149                     visitNode(cbNode, node.dotDotDotToken) ||
15150                     visitNode(cbNode, node.propertyName) ||
15151                     visitNode(cbNode, node.name) ||
15152                     visitNode(cbNode, node.initializer);
15153             case 170:
15154             case 171:
15155             case 165:
15156             case 166:
15157             case 167:
15158                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15159                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15160                     visitNodes(cbNode, cbNodes, node.typeParameters) ||
15161                     visitNodes(cbNode, cbNodes, node.parameters) ||
15162                     visitNode(cbNode, node.type);
15163             case 161:
15164             case 160:
15165             case 162:
15166             case 163:
15167             case 164:
15168             case 201:
15169             case 244:
15170             case 202:
15171                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15172                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15173                     visitNode(cbNode, node.asteriskToken) ||
15174                     visitNode(cbNode, node.name) ||
15175                     visitNode(cbNode, node.questionToken) ||
15176                     visitNode(cbNode, node.exclamationToken) ||
15177                     visitNodes(cbNode, cbNodes, node.typeParameters) ||
15178                     visitNodes(cbNode, cbNodes, node.parameters) ||
15179                     visitNode(cbNode, node.type) ||
15180                     visitNode(cbNode, node.equalsGreaterThanToken) ||
15181                     visitNode(cbNode, node.body);
15182             case 169:
15183                 return visitNode(cbNode, node.typeName) ||
15184                     visitNodes(cbNode, cbNodes, node.typeArguments);
15185             case 168:
15186                 return visitNode(cbNode, node.assertsModifier) ||
15187                     visitNode(cbNode, node.parameterName) ||
15188                     visitNode(cbNode, node.type);
15189             case 172:
15190                 return visitNode(cbNode, node.exprName);
15191             case 173:
15192                 return visitNodes(cbNode, cbNodes, node.members);
15193             case 174:
15194                 return visitNode(cbNode, node.elementType);
15195             case 175:
15196                 return visitNodes(cbNode, cbNodes, node.elementTypes);
15197             case 178:
15198             case 179:
15199                 return visitNodes(cbNode, cbNodes, node.types);
15200             case 180:
15201                 return visitNode(cbNode, node.checkType) ||
15202                     visitNode(cbNode, node.extendsType) ||
15203                     visitNode(cbNode, node.trueType) ||
15204                     visitNode(cbNode, node.falseType);
15205             case 181:
15206                 return visitNode(cbNode, node.typeParameter);
15207             case 188:
15208                 return visitNode(cbNode, node.argument) ||
15209                     visitNode(cbNode, node.qualifier) ||
15210                     visitNodes(cbNode, cbNodes, node.typeArguments);
15211             case 182:
15212             case 184:
15213                 return visitNode(cbNode, node.type);
15214             case 185:
15215                 return visitNode(cbNode, node.objectType) ||
15216                     visitNode(cbNode, node.indexType);
15217             case 186:
15218                 return visitNode(cbNode, node.readonlyToken) ||
15219                     visitNode(cbNode, node.typeParameter) ||
15220                     visitNode(cbNode, node.questionToken) ||
15221                     visitNode(cbNode, node.type);
15222             case 187:
15223                 return visitNode(cbNode, node.literal);
15224             case 189:
15225             case 190:
15226                 return visitNodes(cbNode, cbNodes, node.elements);
15227             case 192:
15228                 return visitNodes(cbNode, cbNodes, node.elements);
15229             case 193:
15230                 return visitNodes(cbNode, cbNodes, node.properties);
15231             case 194:
15232                 return visitNode(cbNode, node.expression) ||
15233                     visitNode(cbNode, node.questionDotToken) ||
15234                     visitNode(cbNode, node.name);
15235             case 195:
15236                 return visitNode(cbNode, node.expression) ||
15237                     visitNode(cbNode, node.questionDotToken) ||
15238                     visitNode(cbNode, node.argumentExpression);
15239             case 196:
15240             case 197:
15241                 return visitNode(cbNode, node.expression) ||
15242                     visitNode(cbNode, node.questionDotToken) ||
15243                     visitNodes(cbNode, cbNodes, node.typeArguments) ||
15244                     visitNodes(cbNode, cbNodes, node.arguments);
15245             case 198:
15246                 return visitNode(cbNode, node.tag) ||
15247                     visitNode(cbNode, node.questionDotToken) ||
15248                     visitNodes(cbNode, cbNodes, node.typeArguments) ||
15249                     visitNode(cbNode, node.template);
15250             case 199:
15251                 return visitNode(cbNode, node.type) ||
15252                     visitNode(cbNode, node.expression);
15253             case 200:
15254                 return visitNode(cbNode, node.expression);
15255             case 203:
15256                 return visitNode(cbNode, node.expression);
15257             case 204:
15258                 return visitNode(cbNode, node.expression);
15259             case 205:
15260                 return visitNode(cbNode, node.expression);
15261             case 207:
15262                 return visitNode(cbNode, node.operand);
15263             case 212:
15264                 return visitNode(cbNode, node.asteriskToken) ||
15265                     visitNode(cbNode, node.expression);
15266             case 206:
15267                 return visitNode(cbNode, node.expression);
15268             case 208:
15269                 return visitNode(cbNode, node.operand);
15270             case 209:
15271                 return visitNode(cbNode, node.left) ||
15272                     visitNode(cbNode, node.operatorToken) ||
15273                     visitNode(cbNode, node.right);
15274             case 217:
15275                 return visitNode(cbNode, node.expression) ||
15276                     visitNode(cbNode, node.type);
15277             case 218:
15278                 return visitNode(cbNode, node.expression);
15279             case 219:
15280                 return visitNode(cbNode, node.name);
15281             case 210:
15282                 return visitNode(cbNode, node.condition) ||
15283                     visitNode(cbNode, node.questionToken) ||
15284                     visitNode(cbNode, node.whenTrue) ||
15285                     visitNode(cbNode, node.colonToken) ||
15286                     visitNode(cbNode, node.whenFalse);
15287             case 213:
15288                 return visitNode(cbNode, node.expression);
15289             case 223:
15290             case 250:
15291                 return visitNodes(cbNode, cbNodes, node.statements);
15292             case 290:
15293                 return visitNodes(cbNode, cbNodes, node.statements) ||
15294                     visitNode(cbNode, node.endOfFileToken);
15295             case 225:
15296                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15297                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15298                     visitNode(cbNode, node.declarationList);
15299             case 243:
15300                 return visitNodes(cbNode, cbNodes, node.declarations);
15301             case 226:
15302                 return visitNode(cbNode, node.expression);
15303             case 227:
15304                 return visitNode(cbNode, node.expression) ||
15305                     visitNode(cbNode, node.thenStatement) ||
15306                     visitNode(cbNode, node.elseStatement);
15307             case 228:
15308                 return visitNode(cbNode, node.statement) ||
15309                     visitNode(cbNode, node.expression);
15310             case 229:
15311                 return visitNode(cbNode, node.expression) ||
15312                     visitNode(cbNode, node.statement);
15313             case 230:
15314                 return visitNode(cbNode, node.initializer) ||
15315                     visitNode(cbNode, node.condition) ||
15316                     visitNode(cbNode, node.incrementor) ||
15317                     visitNode(cbNode, node.statement);
15318             case 231:
15319                 return visitNode(cbNode, node.initializer) ||
15320                     visitNode(cbNode, node.expression) ||
15321                     visitNode(cbNode, node.statement);
15322             case 232:
15323                 return visitNode(cbNode, node.awaitModifier) ||
15324                     visitNode(cbNode, node.initializer) ||
15325                     visitNode(cbNode, node.expression) ||
15326                     visitNode(cbNode, node.statement);
15327             case 233:
15328             case 234:
15329                 return visitNode(cbNode, node.label);
15330             case 235:
15331                 return visitNode(cbNode, node.expression);
15332             case 236:
15333                 return visitNode(cbNode, node.expression) ||
15334                     visitNode(cbNode, node.statement);
15335             case 237:
15336                 return visitNode(cbNode, node.expression) ||
15337                     visitNode(cbNode, node.caseBlock);
15338             case 251:
15339                 return visitNodes(cbNode, cbNodes, node.clauses);
15340             case 277:
15341                 return visitNode(cbNode, node.expression) ||
15342                     visitNodes(cbNode, cbNodes, node.statements);
15343             case 278:
15344                 return visitNodes(cbNode, cbNodes, node.statements);
15345             case 238:
15346                 return visitNode(cbNode, node.label) ||
15347                     visitNode(cbNode, node.statement);
15348             case 239:
15349                 return visitNode(cbNode, node.expression);
15350             case 240:
15351                 return visitNode(cbNode, node.tryBlock) ||
15352                     visitNode(cbNode, node.catchClause) ||
15353                     visitNode(cbNode, node.finallyBlock);
15354             case 280:
15355                 return visitNode(cbNode, node.variableDeclaration) ||
15356                     visitNode(cbNode, node.block);
15357             case 157:
15358                 return visitNode(cbNode, node.expression);
15359             case 245:
15360             case 214:
15361                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15362                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15363                     visitNode(cbNode, node.name) ||
15364                     visitNodes(cbNode, cbNodes, node.typeParameters) ||
15365                     visitNodes(cbNode, cbNodes, node.heritageClauses) ||
15366                     visitNodes(cbNode, cbNodes, node.members);
15367             case 246:
15368                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15369                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15370                     visitNode(cbNode, node.name) ||
15371                     visitNodes(cbNode, cbNodes, node.typeParameters) ||
15372                     visitNodes(cbNode, cbNodes, node.heritageClauses) ||
15373                     visitNodes(cbNode, cbNodes, node.members);
15374             case 247:
15375                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15376                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15377                     visitNode(cbNode, node.name) ||
15378                     visitNodes(cbNode, cbNodes, node.typeParameters) ||
15379                     visitNode(cbNode, node.type);
15380             case 248:
15381                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15382                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15383                     visitNode(cbNode, node.name) ||
15384                     visitNodes(cbNode, cbNodes, node.members);
15385             case 284:
15386                 return visitNode(cbNode, node.name) ||
15387                     visitNode(cbNode, node.initializer);
15388             case 249:
15389                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15390                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15391                     visitNode(cbNode, node.name) ||
15392                     visitNode(cbNode, node.body);
15393             case 253:
15394                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15395                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15396                     visitNode(cbNode, node.name) ||
15397                     visitNode(cbNode, node.moduleReference);
15398             case 254:
15399                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15400                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15401                     visitNode(cbNode, node.importClause) ||
15402                     visitNode(cbNode, node.moduleSpecifier);
15403             case 255:
15404                 return visitNode(cbNode, node.name) ||
15405                     visitNode(cbNode, node.namedBindings);
15406             case 252:
15407                 return visitNode(cbNode, node.name);
15408             case 256:
15409                 return visitNode(cbNode, node.name);
15410             case 262:
15411                 return visitNode(cbNode, node.name);
15412             case 257:
15413             case 261:
15414                 return visitNodes(cbNode, cbNodes, node.elements);
15415             case 260:
15416                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15417                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15418                     visitNode(cbNode, node.exportClause) ||
15419                     visitNode(cbNode, node.moduleSpecifier);
15420             case 258:
15421             case 263:
15422                 return visitNode(cbNode, node.propertyName) ||
15423                     visitNode(cbNode, node.name);
15424             case 259:
15425                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15426                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15427                     visitNode(cbNode, node.expression);
15428             case 211:
15429                 return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans);
15430             case 221:
15431                 return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal);
15432             case 154:
15433                 return visitNode(cbNode, node.expression);
15434             case 279:
15435                 return visitNodes(cbNode, cbNodes, node.types);
15436             case 216:
15437                 return visitNode(cbNode, node.expression) ||
15438                     visitNodes(cbNode, cbNodes, node.typeArguments);
15439             case 265:
15440                 return visitNode(cbNode, node.expression);
15441             case 264:
15442                 return visitNodes(cbNode, cbNodes, node.decorators);
15443             case 327:
15444                 return visitNodes(cbNode, cbNodes, node.elements);
15445             case 266:
15446                 return visitNode(cbNode, node.openingElement) ||
15447                     visitNodes(cbNode, cbNodes, node.children) ||
15448                     visitNode(cbNode, node.closingElement);
15449             case 270:
15450                 return visitNode(cbNode, node.openingFragment) ||
15451                     visitNodes(cbNode, cbNodes, node.children) ||
15452                     visitNode(cbNode, node.closingFragment);
15453             case 267:
15454             case 268:
15455                 return visitNode(cbNode, node.tagName) ||
15456                     visitNodes(cbNode, cbNodes, node.typeArguments) ||
15457                     visitNode(cbNode, node.attributes);
15458             case 274:
15459                 return visitNodes(cbNode, cbNodes, node.properties);
15460             case 273:
15461                 return visitNode(cbNode, node.name) ||
15462                     visitNode(cbNode, node.initializer);
15463             case 275:
15464                 return visitNode(cbNode, node.expression);
15465             case 276:
15466                 return visitNode(cbNode, node.dotDotDotToken) ||
15467                     visitNode(cbNode, node.expression);
15468             case 269:
15469                 return visitNode(cbNode, node.tagName);
15470             case 176:
15471             case 177:
15472             case 294:
15473             case 298:
15474             case 297:
15475             case 299:
15476             case 301:
15477                 return visitNode(cbNode, node.type);
15478             case 300:
15479                 return visitNodes(cbNode, cbNodes, node.parameters) ||
15480                     visitNode(cbNode, node.type);
15481             case 303:
15482                 return visitNodes(cbNode, cbNodes, node.tags);
15483             case 317:
15484             case 323:
15485                 return visitNode(cbNode, node.tagName) ||
15486                     (node.isNameFirst
15487                         ? visitNode(cbNode, node.name) ||
15488                             visitNode(cbNode, node.typeExpression)
15489                         : visitNode(cbNode, node.typeExpression) ||
15490                             visitNode(cbNode, node.name));
15491             case 309:
15492                 return visitNode(cbNode, node.tagName);
15493             case 308:
15494                 return visitNode(cbNode, node.tagName) ||
15495                     visitNode(cbNode, node.class);
15496             case 307:
15497                 return visitNode(cbNode, node.tagName) ||
15498                     visitNode(cbNode, node.class);
15499             case 321:
15500                 return visitNode(cbNode, node.tagName) ||
15501                     visitNode(cbNode, node.constraint) ||
15502                     visitNodes(cbNode, cbNodes, node.typeParameters);
15503             case 322:
15504                 return visitNode(cbNode, node.tagName) ||
15505                     (node.typeExpression &&
15506                         node.typeExpression.kind === 294
15507                         ? visitNode(cbNode, node.typeExpression) ||
15508                             visitNode(cbNode, node.fullName)
15509                         : visitNode(cbNode, node.fullName) ||
15510                             visitNode(cbNode, node.typeExpression));
15511             case 315:
15512                 return visitNode(cbNode, node.tagName) ||
15513                     visitNode(cbNode, node.fullName) ||
15514                     visitNode(cbNode, node.typeExpression);
15515             case 318:
15516             case 320:
15517             case 319:
15518             case 316:
15519                 return visitNode(cbNode, node.tagName) ||
15520                     visitNode(cbNode, node.typeExpression);
15521             case 305:
15522                 return ts.forEach(node.typeParameters, cbNode) ||
15523                     ts.forEach(node.parameters, cbNode) ||
15524                     visitNode(cbNode, node.type);
15525             case 304:
15526                 return ts.forEach(node.jsDocPropertyTags, cbNode);
15527             case 306:
15528             case 310:
15529             case 311:
15530             case 312:
15531             case 313:
15532             case 314:
15533                 return visitNode(cbNode, node.tagName);
15534             case 326:
15535                 return visitNode(cbNode, node.expression);
15536         }
15537     }
15538     ts.forEachChild = forEachChild;
15539     function forEachChildRecursively(rootNode, cbNode, cbNodes) {
15540         var stack = [rootNode];
15541         while (stack.length) {
15542             var parent = stack.pop();
15543             var res = visitAllPossibleChildren(parent, gatherPossibleChildren(parent));
15544             if (res) {
15545                 return res;
15546             }
15547         }
15548         return;
15549         function gatherPossibleChildren(node) {
15550             var children = [];
15551             forEachChild(node, addWorkItem, addWorkItem);
15552             return children;
15553             function addWorkItem(n) {
15554                 children.unshift(n);
15555             }
15556         }
15557         function visitAllPossibleChildren(parent, children) {
15558             for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
15559                 var child = children_1[_i];
15560                 if (ts.isArray(child)) {
15561                     if (cbNodes) {
15562                         var res = cbNodes(child, parent);
15563                         if (res) {
15564                             if (res === "skip")
15565                                 continue;
15566                             return res;
15567                         }
15568                     }
15569                     for (var i = child.length - 1; i >= 0; i--) {
15570                         var realChild = child[i];
15571                         var res = cbNode(realChild, parent);
15572                         if (res) {
15573                             if (res === "skip")
15574                                 continue;
15575                             return res;
15576                         }
15577                         stack.push(realChild);
15578                     }
15579                 }
15580                 else {
15581                     stack.push(child);
15582                     var res = cbNode(child, parent);
15583                     if (res) {
15584                         if (res === "skip")
15585                             continue;
15586                         return res;
15587                     }
15588                 }
15589             }
15590         }
15591     }
15592     ts.forEachChildRecursively = forEachChildRecursively;
15593     function createSourceFile(fileName, sourceText, languageVersion, setParentNodes, scriptKind) {
15594         if (setParentNodes === void 0) { setParentNodes = false; }
15595         ts.performance.mark("beforeParse");
15596         var result;
15597         ts.perfLogger.logStartParseSourceFile(fileName);
15598         if (languageVersion === 100) {
15599             result = Parser.parseSourceFile(fileName, sourceText, languageVersion, undefined, setParentNodes, 6);
15600         }
15601         else {
15602             result = Parser.parseSourceFile(fileName, sourceText, languageVersion, undefined, setParentNodes, scriptKind);
15603         }
15604         ts.perfLogger.logStopParseSourceFile();
15605         ts.performance.mark("afterParse");
15606         ts.performance.measure("Parse", "beforeParse", "afterParse");
15607         return result;
15608     }
15609     ts.createSourceFile = createSourceFile;
15610     function parseIsolatedEntityName(text, languageVersion) {
15611         return Parser.parseIsolatedEntityName(text, languageVersion);
15612     }
15613     ts.parseIsolatedEntityName = parseIsolatedEntityName;
15614     function parseJsonText(fileName, sourceText) {
15615         return Parser.parseJsonText(fileName, sourceText);
15616     }
15617     ts.parseJsonText = parseJsonText;
15618     function isExternalModule(file) {
15619         return file.externalModuleIndicator !== undefined;
15620     }
15621     ts.isExternalModule = isExternalModule;
15622     function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) {
15623         if (aggressiveChecks === void 0) { aggressiveChecks = false; }
15624         var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks);
15625         newSourceFile.flags |= (sourceFile.flags & 3145728);
15626         return newSourceFile;
15627     }
15628     ts.updateSourceFile = updateSourceFile;
15629     function parseIsolatedJSDocComment(content, start, length) {
15630         var result = Parser.JSDocParser.parseIsolatedJSDocComment(content, start, length);
15631         if (result && result.jsDoc) {
15632             Parser.fixupParentReferences(result.jsDoc);
15633         }
15634         return result;
15635     }
15636     ts.parseIsolatedJSDocComment = parseIsolatedJSDocComment;
15637     function parseJSDocTypeExpressionForTests(content, start, length) {
15638         return Parser.JSDocParser.parseJSDocTypeExpressionForTests(content, start, length);
15639     }
15640     ts.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests;
15641     var Parser;
15642     (function (Parser) {
15643         var scanner = ts.createScanner(99, true);
15644         var disallowInAndDecoratorContext = 4096 | 16384;
15645         var NodeConstructor;
15646         var TokenConstructor;
15647         var IdentifierConstructor;
15648         var PrivateIdentifierConstructor;
15649         var SourceFileConstructor;
15650         var sourceFile;
15651         var parseDiagnostics;
15652         var syntaxCursor;
15653         var currentToken;
15654         var sourceText;
15655         var nodeCount;
15656         var identifiers;
15657         var privateIdentifiers;
15658         var identifierCount;
15659         var parsingContext;
15660         var notParenthesizedArrow;
15661         var contextFlags;
15662         var parseErrorBeforeNextFinishedNode = false;
15663         function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) {
15664             if (setParentNodes === void 0) { setParentNodes = false; }
15665             scriptKind = ts.ensureScriptKind(fileName, scriptKind);
15666             if (scriptKind === 6) {
15667                 var result_2 = parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes);
15668                 ts.convertToObjectWorker(result_2, result_2.parseDiagnostics, false, undefined, undefined);
15669                 result_2.referencedFiles = ts.emptyArray;
15670                 result_2.typeReferenceDirectives = ts.emptyArray;
15671                 result_2.libReferenceDirectives = ts.emptyArray;
15672                 result_2.amdDependencies = ts.emptyArray;
15673                 result_2.hasNoDefaultLib = false;
15674                 result_2.pragmas = ts.emptyMap;
15675                 return result_2;
15676             }
15677             initializeState(sourceText, languageVersion, syntaxCursor, scriptKind);
15678             var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind);
15679             clearState();
15680             return result;
15681         }
15682         Parser.parseSourceFile = parseSourceFile;
15683         function parseIsolatedEntityName(content, languageVersion) {
15684             initializeState(content, languageVersion, undefined, 1);
15685             nextToken();
15686             var entityName = parseEntityName(true);
15687             var isInvalid = token() === 1 && !parseDiagnostics.length;
15688             clearState();
15689             return isInvalid ? entityName : undefined;
15690         }
15691         Parser.parseIsolatedEntityName = parseIsolatedEntityName;
15692         function parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes) {
15693             if (languageVersion === void 0) { languageVersion = 2; }
15694             initializeState(sourceText, languageVersion, syntaxCursor, 6);
15695             sourceFile = createSourceFile(fileName, 2, 6, false);
15696             sourceFile.flags = contextFlags;
15697             nextToken();
15698             var pos = getNodePos();
15699             if (token() === 1) {
15700                 sourceFile.statements = createNodeArray([], pos, pos);
15701                 sourceFile.endOfFileToken = parseTokenNode();
15702             }
15703             else {
15704                 var statement = createNode(226);
15705                 switch (token()) {
15706                     case 22:
15707                         statement.expression = parseArrayLiteralExpression();
15708                         break;
15709                     case 106:
15710                     case 91:
15711                     case 100:
15712                         statement.expression = parseTokenNode();
15713                         break;
15714                     case 40:
15715                         if (lookAhead(function () { return nextToken() === 8 && nextToken() !== 58; })) {
15716                             statement.expression = parsePrefixUnaryExpression();
15717                         }
15718                         else {
15719                             statement.expression = parseObjectLiteralExpression();
15720                         }
15721                         break;
15722                     case 8:
15723                     case 10:
15724                         if (lookAhead(function () { return nextToken() !== 58; })) {
15725                             statement.expression = parseLiteralNode();
15726                             break;
15727                         }
15728                     default:
15729                         statement.expression = parseObjectLiteralExpression();
15730                         break;
15731                 }
15732                 finishNode(statement);
15733                 sourceFile.statements = createNodeArray([statement], pos);
15734                 sourceFile.endOfFileToken = parseExpectedToken(1, ts.Diagnostics.Unexpected_token);
15735             }
15736             if (setParentNodes) {
15737                 fixupParentReferences(sourceFile);
15738             }
15739             sourceFile.nodeCount = nodeCount;
15740             sourceFile.identifierCount = identifierCount;
15741             sourceFile.identifiers = identifiers;
15742             sourceFile.parseDiagnostics = parseDiagnostics;
15743             var result = sourceFile;
15744             clearState();
15745             return result;
15746         }
15747         Parser.parseJsonText = parseJsonText;
15748         function getLanguageVariant(scriptKind) {
15749             return scriptKind === 4 || scriptKind === 2 || scriptKind === 1 || scriptKind === 6 ? 1 : 0;
15750         }
15751         function initializeState(_sourceText, languageVersion, _syntaxCursor, scriptKind) {
15752             NodeConstructor = ts.objectAllocator.getNodeConstructor();
15753             TokenConstructor = ts.objectAllocator.getTokenConstructor();
15754             IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor();
15755             PrivateIdentifierConstructor = ts.objectAllocator.getPrivateIdentifierConstructor();
15756             SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor();
15757             sourceText = _sourceText;
15758             syntaxCursor = _syntaxCursor;
15759             parseDiagnostics = [];
15760             parsingContext = 0;
15761             identifiers = ts.createMap();
15762             privateIdentifiers = ts.createMap();
15763             identifierCount = 0;
15764             nodeCount = 0;
15765             switch (scriptKind) {
15766                 case 1:
15767                 case 2:
15768                     contextFlags = 131072;
15769                     break;
15770                 case 6:
15771                     contextFlags = 131072 | 33554432;
15772                     break;
15773                 default:
15774                     contextFlags = 0;
15775                     break;
15776             }
15777             parseErrorBeforeNextFinishedNode = false;
15778             scanner.setText(sourceText);
15779             scanner.setOnError(scanError);
15780             scanner.setScriptTarget(languageVersion);
15781             scanner.setLanguageVariant(getLanguageVariant(scriptKind));
15782         }
15783         function clearState() {
15784             scanner.clearCommentDirectives();
15785             scanner.setText("");
15786             scanner.setOnError(undefined);
15787             parseDiagnostics = undefined;
15788             sourceFile = undefined;
15789             identifiers = undefined;
15790             syntaxCursor = undefined;
15791             sourceText = undefined;
15792             notParenthesizedArrow = undefined;
15793         }
15794         function parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind) {
15795             var isDeclarationFile = isDeclarationFileName(fileName);
15796             if (isDeclarationFile) {
15797                 contextFlags |= 8388608;
15798             }
15799             sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile);
15800             sourceFile.flags = contextFlags;
15801             nextToken();
15802             processCommentPragmas(sourceFile, sourceText);
15803             processPragmasIntoFields(sourceFile, reportPragmaDiagnostic);
15804             sourceFile.statements = parseList(0, parseStatement);
15805             ts.Debug.assert(token() === 1);
15806             sourceFile.endOfFileToken = addJSDocComment(parseTokenNode());
15807             setExternalModuleIndicator(sourceFile);
15808             sourceFile.commentDirectives = scanner.getCommentDirectives();
15809             sourceFile.nodeCount = nodeCount;
15810             sourceFile.identifierCount = identifierCount;
15811             sourceFile.identifiers = identifiers;
15812             sourceFile.parseDiagnostics = parseDiagnostics;
15813             if (setParentNodes) {
15814                 fixupParentReferences(sourceFile);
15815             }
15816             return sourceFile;
15817             function reportPragmaDiagnostic(pos, end, diagnostic) {
15818                 parseDiagnostics.push(ts.createFileDiagnostic(sourceFile, pos, end, diagnostic));
15819             }
15820         }
15821         function addJSDocComment(node) {
15822             ts.Debug.assert(!node.jsDoc);
15823             var jsDoc = ts.mapDefined(ts.getJSDocCommentRanges(node, sourceFile.text), function (comment) { return JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); });
15824             if (jsDoc.length)
15825                 node.jsDoc = jsDoc;
15826             return node;
15827         }
15828         function fixupParentReferences(rootNode) {
15829             forEachChildRecursively(rootNode, bindParentToChild);
15830             function bindParentToChild(child, parent) {
15831                 child.parent = parent;
15832                 if (ts.hasJSDocNodes(child)) {
15833                     for (var _i = 0, _a = child.jsDoc; _i < _a.length; _i++) {
15834                         var doc = _a[_i];
15835                         bindParentToChild(doc, child);
15836                         forEachChildRecursively(doc, bindParentToChild);
15837                     }
15838                 }
15839             }
15840         }
15841         Parser.fixupParentReferences = fixupParentReferences;
15842         function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) {
15843             var sourceFile = new SourceFileConstructor(290, 0, sourceText.length);
15844             nodeCount++;
15845             sourceFile.text = sourceText;
15846             sourceFile.bindDiagnostics = [];
15847             sourceFile.bindSuggestionDiagnostics = undefined;
15848             sourceFile.languageVersion = languageVersion;
15849             sourceFile.fileName = ts.normalizePath(fileName);
15850             sourceFile.languageVariant = getLanguageVariant(scriptKind);
15851             sourceFile.isDeclarationFile = isDeclarationFile;
15852             sourceFile.scriptKind = scriptKind;
15853             return sourceFile;
15854         }
15855         function setContextFlag(val, flag) {
15856             if (val) {
15857                 contextFlags |= flag;
15858             }
15859             else {
15860                 contextFlags &= ~flag;
15861             }
15862         }
15863         function setDisallowInContext(val) {
15864             setContextFlag(val, 4096);
15865         }
15866         function setYieldContext(val) {
15867             setContextFlag(val, 8192);
15868         }
15869         function setDecoratorContext(val) {
15870             setContextFlag(val, 16384);
15871         }
15872         function setAwaitContext(val) {
15873             setContextFlag(val, 32768);
15874         }
15875         function doOutsideOfContext(context, func) {
15876             var contextFlagsToClear = context & contextFlags;
15877             if (contextFlagsToClear) {
15878                 setContextFlag(false, contextFlagsToClear);
15879                 var result = func();
15880                 setContextFlag(true, contextFlagsToClear);
15881                 return result;
15882             }
15883             return func();
15884         }
15885         function doInsideOfContext(context, func) {
15886             var contextFlagsToSet = context & ~contextFlags;
15887             if (contextFlagsToSet) {
15888                 setContextFlag(true, contextFlagsToSet);
15889                 var result = func();
15890                 setContextFlag(false, contextFlagsToSet);
15891                 return result;
15892             }
15893             return func();
15894         }
15895         function allowInAnd(func) {
15896             return doOutsideOfContext(4096, func);
15897         }
15898         function disallowInAnd(func) {
15899             return doInsideOfContext(4096, func);
15900         }
15901         function doInYieldContext(func) {
15902             return doInsideOfContext(8192, func);
15903         }
15904         function doInDecoratorContext(func) {
15905             return doInsideOfContext(16384, func);
15906         }
15907         function doInAwaitContext(func) {
15908             return doInsideOfContext(32768, func);
15909         }
15910         function doOutsideOfAwaitContext(func) {
15911             return doOutsideOfContext(32768, func);
15912         }
15913         function doInYieldAndAwaitContext(func) {
15914             return doInsideOfContext(8192 | 32768, func);
15915         }
15916         function doOutsideOfYieldAndAwaitContext(func) {
15917             return doOutsideOfContext(8192 | 32768, func);
15918         }
15919         function inContext(flags) {
15920             return (contextFlags & flags) !== 0;
15921         }
15922         function inYieldContext() {
15923             return inContext(8192);
15924         }
15925         function inDisallowInContext() {
15926             return inContext(4096);
15927         }
15928         function inDecoratorContext() {
15929             return inContext(16384);
15930         }
15931         function inAwaitContext() {
15932             return inContext(32768);
15933         }
15934         function parseErrorAtCurrentToken(message, arg0) {
15935             parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0);
15936         }
15937         function parseErrorAtPosition(start, length, message, arg0) {
15938             var lastError = ts.lastOrUndefined(parseDiagnostics);
15939             if (!lastError || start !== lastError.start) {
15940                 parseDiagnostics.push(ts.createFileDiagnostic(sourceFile, start, length, message, arg0));
15941             }
15942             parseErrorBeforeNextFinishedNode = true;
15943         }
15944         function parseErrorAt(start, end, message, arg0) {
15945             parseErrorAtPosition(start, end - start, message, arg0);
15946         }
15947         function parseErrorAtRange(range, message, arg0) {
15948             parseErrorAt(range.pos, range.end, message, arg0);
15949         }
15950         function scanError(message, length) {
15951             parseErrorAtPosition(scanner.getTextPos(), length, message);
15952         }
15953         function getNodePos() {
15954             return scanner.getStartPos();
15955         }
15956         function token() {
15957             return currentToken;
15958         }
15959         function nextTokenWithoutCheck() {
15960             return currentToken = scanner.scan();
15961         }
15962         function nextToken() {
15963             if (ts.isKeyword(currentToken) && (scanner.hasUnicodeEscape() || scanner.hasExtendedUnicodeEscape())) {
15964                 parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), ts.Diagnostics.Keywords_cannot_contain_escape_characters);
15965             }
15966             return nextTokenWithoutCheck();
15967         }
15968         function nextTokenJSDoc() {
15969             return currentToken = scanner.scanJsDocToken();
15970         }
15971         function reScanGreaterToken() {
15972             return currentToken = scanner.reScanGreaterToken();
15973         }
15974         function reScanSlashToken() {
15975             return currentToken = scanner.reScanSlashToken();
15976         }
15977         function reScanTemplateToken(isTaggedTemplate) {
15978             return currentToken = scanner.reScanTemplateToken(isTaggedTemplate);
15979         }
15980         function reScanTemplateHeadOrNoSubstitutionTemplate() {
15981             return currentToken = scanner.reScanTemplateHeadOrNoSubstitutionTemplate();
15982         }
15983         function reScanLessThanToken() {
15984             return currentToken = scanner.reScanLessThanToken();
15985         }
15986         function scanJsxIdentifier() {
15987             return currentToken = scanner.scanJsxIdentifier();
15988         }
15989         function scanJsxText() {
15990             return currentToken = scanner.scanJsxToken();
15991         }
15992         function scanJsxAttributeValue() {
15993             return currentToken = scanner.scanJsxAttributeValue();
15994         }
15995         function speculationHelper(callback, isLookAhead) {
15996             var saveToken = currentToken;
15997             var saveParseDiagnosticsLength = parseDiagnostics.length;
15998             var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode;
15999             var saveContextFlags = contextFlags;
16000             var result = isLookAhead
16001                 ? scanner.lookAhead(callback)
16002                 : scanner.tryScan(callback);
16003             ts.Debug.assert(saveContextFlags === contextFlags);
16004             if (!result || isLookAhead) {
16005                 currentToken = saveToken;
16006                 parseDiagnostics.length = saveParseDiagnosticsLength;
16007                 parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode;
16008             }
16009             return result;
16010         }
16011         function lookAhead(callback) {
16012             return speculationHelper(callback, true);
16013         }
16014         function tryParse(callback) {
16015             return speculationHelper(callback, false);
16016         }
16017         function isIdentifier() {
16018             if (token() === 75) {
16019                 return true;
16020             }
16021             if (token() === 121 && inYieldContext()) {
16022                 return false;
16023             }
16024             if (token() === 127 && inAwaitContext()) {
16025                 return false;
16026             }
16027             return token() > 112;
16028         }
16029         function parseExpected(kind, diagnosticMessage, shouldAdvance) {
16030             if (shouldAdvance === void 0) { shouldAdvance = true; }
16031             if (token() === kind) {
16032                 if (shouldAdvance) {
16033                     nextToken();
16034                 }
16035                 return true;
16036             }
16037             if (diagnosticMessage) {
16038                 parseErrorAtCurrentToken(diagnosticMessage);
16039             }
16040             else {
16041                 parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind));
16042             }
16043             return false;
16044         }
16045         function parseExpectedJSDoc(kind) {
16046             if (token() === kind) {
16047                 nextTokenJSDoc();
16048                 return true;
16049             }
16050             parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind));
16051             return false;
16052         }
16053         function parseOptional(t) {
16054             if (token() === t) {
16055                 nextToken();
16056                 return true;
16057             }
16058             return false;
16059         }
16060         function parseOptionalToken(t) {
16061             if (token() === t) {
16062                 return parseTokenNode();
16063             }
16064             return undefined;
16065         }
16066         function parseOptionalTokenJSDoc(t) {
16067             if (token() === t) {
16068                 return parseTokenNodeJSDoc();
16069             }
16070             return undefined;
16071         }
16072         function parseExpectedToken(t, diagnosticMessage, arg0) {
16073             return parseOptionalToken(t) ||
16074                 createMissingNode(t, false, diagnosticMessage || ts.Diagnostics._0_expected, arg0 || ts.tokenToString(t));
16075         }
16076         function parseExpectedTokenJSDoc(t) {
16077             return parseOptionalTokenJSDoc(t) ||
16078                 createMissingNode(t, false, ts.Diagnostics._0_expected, ts.tokenToString(t));
16079         }
16080         function parseTokenNode() {
16081             var node = createNode(token());
16082             nextToken();
16083             return finishNode(node);
16084         }
16085         function parseTokenNodeJSDoc() {
16086             var node = createNode(token());
16087             nextTokenJSDoc();
16088             return finishNode(node);
16089         }
16090         function canParseSemicolon() {
16091             if (token() === 26) {
16092                 return true;
16093             }
16094             return token() === 19 || token() === 1 || scanner.hasPrecedingLineBreak();
16095         }
16096         function parseSemicolon() {
16097             if (canParseSemicolon()) {
16098                 if (token() === 26) {
16099                     nextToken();
16100                 }
16101                 return true;
16102             }
16103             else {
16104                 return parseExpected(26);
16105             }
16106         }
16107         function createNode(kind, pos) {
16108             nodeCount++;
16109             var p = pos >= 0 ? pos : scanner.getStartPos();
16110             return ts.isNodeKind(kind) || kind === 0 ? new NodeConstructor(kind, p, p) :
16111                 kind === 75 ? new IdentifierConstructor(kind, p, p) :
16112                     kind === 76 ? new PrivateIdentifierConstructor(kind, p, p) :
16113                         new TokenConstructor(kind, p, p);
16114         }
16115         function createNodeWithJSDoc(kind, pos) {
16116             var node = createNode(kind, pos);
16117             if (scanner.getTokenFlags() & 2 && (kind !== 226 || token() !== 20)) {
16118                 addJSDocComment(node);
16119             }
16120             return node;
16121         }
16122         function createNodeArray(elements, pos, end) {
16123             var length = elements.length;
16124             var array = (length >= 1 && length <= 4 ? elements.slice() : elements);
16125             array.pos = pos;
16126             array.end = end === undefined ? scanner.getStartPos() : end;
16127             return array;
16128         }
16129         function finishNode(node, end) {
16130             node.end = end === undefined ? scanner.getStartPos() : end;
16131             if (contextFlags) {
16132                 node.flags |= contextFlags;
16133             }
16134             if (parseErrorBeforeNextFinishedNode) {
16135                 parseErrorBeforeNextFinishedNode = false;
16136                 node.flags |= 65536;
16137             }
16138             return node;
16139         }
16140         function createMissingNode(kind, reportAtCurrentPosition, diagnosticMessage, arg0) {
16141             if (reportAtCurrentPosition) {
16142                 parseErrorAtPosition(scanner.getStartPos(), 0, diagnosticMessage, arg0);
16143             }
16144             else if (diagnosticMessage) {
16145                 parseErrorAtCurrentToken(diagnosticMessage, arg0);
16146             }
16147             var result = createNode(kind);
16148             if (kind === 75) {
16149                 result.escapedText = "";
16150             }
16151             else if (ts.isLiteralKind(kind) || ts.isTemplateLiteralKind(kind)) {
16152                 result.text = "";
16153             }
16154             return finishNode(result);
16155         }
16156         function internIdentifier(text) {
16157             var identifier = identifiers.get(text);
16158             if (identifier === undefined) {
16159                 identifiers.set(text, identifier = text);
16160             }
16161             return identifier;
16162         }
16163         function createIdentifier(isIdentifier, diagnosticMessage, privateIdentifierDiagnosticMessage) {
16164             identifierCount++;
16165             if (isIdentifier) {
16166                 var node = createNode(75);
16167                 if (token() !== 75) {
16168                     node.originalKeywordKind = token();
16169                 }
16170                 node.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue()));
16171                 nextTokenWithoutCheck();
16172                 return finishNode(node);
16173             }
16174             if (token() === 76) {
16175                 parseErrorAtCurrentToken(privateIdentifierDiagnosticMessage || ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
16176                 return createIdentifier(true);
16177             }
16178             var reportAtCurrentPosition = token() === 1;
16179             var isReservedWord = scanner.isReservedWord();
16180             var msgArg = scanner.getTokenText();
16181             var defaultMessage = isReservedWord ?
16182                 ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here :
16183                 ts.Diagnostics.Identifier_expected;
16184             return createMissingNode(75, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg);
16185         }
16186         function parseIdentifier(diagnosticMessage, privateIdentifierDiagnosticMessage) {
16187             return createIdentifier(isIdentifier(), diagnosticMessage, privateIdentifierDiagnosticMessage);
16188         }
16189         function parseIdentifierName(diagnosticMessage) {
16190             return createIdentifier(ts.tokenIsIdentifierOrKeyword(token()), diagnosticMessage);
16191         }
16192         function isLiteralPropertyName() {
16193             return ts.tokenIsIdentifierOrKeyword(token()) ||
16194                 token() === 10 ||
16195                 token() === 8;
16196         }
16197         function parsePropertyNameWorker(allowComputedPropertyNames) {
16198             if (token() === 10 || token() === 8) {
16199                 var node = parseLiteralNode();
16200                 node.text = internIdentifier(node.text);
16201                 return node;
16202             }
16203             if (allowComputedPropertyNames && token() === 22) {
16204                 return parseComputedPropertyName();
16205             }
16206             if (token() === 76) {
16207                 return parsePrivateIdentifier();
16208             }
16209             return parseIdentifierName();
16210         }
16211         function parsePropertyName() {
16212             return parsePropertyNameWorker(true);
16213         }
16214         function parseComputedPropertyName() {
16215             var node = createNode(154);
16216             parseExpected(22);
16217             node.expression = allowInAnd(parseExpression);
16218             parseExpected(23);
16219             return finishNode(node);
16220         }
16221         function internPrivateIdentifier(text) {
16222             var privateIdentifier = privateIdentifiers.get(text);
16223             if (privateIdentifier === undefined) {
16224                 privateIdentifiers.set(text, privateIdentifier = text);
16225             }
16226             return privateIdentifier;
16227         }
16228         function parsePrivateIdentifier() {
16229             var node = createNode(76);
16230             node.escapedText = ts.escapeLeadingUnderscores(internPrivateIdentifier(scanner.getTokenText()));
16231             nextToken();
16232             return finishNode(node);
16233         }
16234         function parseContextualModifier(t) {
16235             return token() === t && tryParse(nextTokenCanFollowModifier);
16236         }
16237         function nextTokenIsOnSameLineAndCanFollowModifier() {
16238             nextToken();
16239             if (scanner.hasPrecedingLineBreak()) {
16240                 return false;
16241             }
16242             return canFollowModifier();
16243         }
16244         function nextTokenCanFollowModifier() {
16245             switch (token()) {
16246                 case 81:
16247                     return nextToken() === 88;
16248                 case 89:
16249                     nextToken();
16250                     if (token() === 84) {
16251                         return lookAhead(nextTokenCanFollowDefaultKeyword);
16252                     }
16253                     if (token() === 145) {
16254                         return lookAhead(nextTokenCanFollowExportModifier);
16255                     }
16256                     return canFollowExportModifier();
16257                 case 84:
16258                     return nextTokenCanFollowDefaultKeyword();
16259                 case 120:
16260                 case 131:
16261                 case 142:
16262                     nextToken();
16263                     return canFollowModifier();
16264                 default:
16265                     return nextTokenIsOnSameLineAndCanFollowModifier();
16266             }
16267         }
16268         function canFollowExportModifier() {
16269             return token() !== 41
16270                 && token() !== 123
16271                 && token() !== 18
16272                 && canFollowModifier();
16273         }
16274         function nextTokenCanFollowExportModifier() {
16275             nextToken();
16276             return canFollowExportModifier();
16277         }
16278         function parseAnyContextualModifier() {
16279             return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier);
16280         }
16281         function canFollowModifier() {
16282             return token() === 22
16283                 || token() === 18
16284                 || token() === 41
16285                 || token() === 25
16286                 || isLiteralPropertyName();
16287         }
16288         function nextTokenCanFollowDefaultKeyword() {
16289             nextToken();
16290             return token() === 80 || token() === 94 ||
16291                 token() === 114 ||
16292                 (token() === 122 && lookAhead(nextTokenIsClassKeywordOnSameLine)) ||
16293                 (token() === 126 && lookAhead(nextTokenIsFunctionKeywordOnSameLine));
16294         }
16295         function isListElement(parsingContext, inErrorRecovery) {
16296             var node = currentNode(parsingContext);
16297             if (node) {
16298                 return true;
16299             }
16300             switch (parsingContext) {
16301                 case 0:
16302                 case 1:
16303                 case 3:
16304                     return !(token() === 26 && inErrorRecovery) && isStartOfStatement();
16305                 case 2:
16306                     return token() === 78 || token() === 84;
16307                 case 4:
16308                     return lookAhead(isTypeMemberStart);
16309                 case 5:
16310                     return lookAhead(isClassMemberStart) || (token() === 26 && !inErrorRecovery);
16311                 case 6:
16312                     return token() === 22 || isLiteralPropertyName();
16313                 case 12:
16314                     switch (token()) {
16315                         case 22:
16316                         case 41:
16317                         case 25:
16318                         case 24:
16319                             return true;
16320                         default:
16321                             return isLiteralPropertyName();
16322                     }
16323                 case 18:
16324                     return isLiteralPropertyName();
16325                 case 9:
16326                     return token() === 22 || token() === 25 || isLiteralPropertyName();
16327                 case 7:
16328                     if (token() === 18) {
16329                         return lookAhead(isValidHeritageClauseObjectLiteral);
16330                     }
16331                     if (!inErrorRecovery) {
16332                         return isStartOfLeftHandSideExpression() && !isHeritageClauseExtendsOrImplementsKeyword();
16333                     }
16334                     else {
16335                         return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword();
16336                     }
16337                 case 8:
16338                     return isIdentifierOrPrivateIdentifierOrPattern();
16339                 case 10:
16340                     return token() === 27 || token() === 25 || isIdentifierOrPrivateIdentifierOrPattern();
16341                 case 19:
16342                     return isIdentifier();
16343                 case 15:
16344                     switch (token()) {
16345                         case 27:
16346                         case 24:
16347                             return true;
16348                     }
16349                 case 11:
16350                     return token() === 25 || isStartOfExpression();
16351                 case 16:
16352                     return isStartOfParameter(false);
16353                 case 17:
16354                     return isStartOfParameter(true);
16355                 case 20:
16356                 case 21:
16357                     return token() === 27 || isStartOfType();
16358                 case 22:
16359                     return isHeritageClause();
16360                 case 23:
16361                     return ts.tokenIsIdentifierOrKeyword(token());
16362                 case 13:
16363                     return ts.tokenIsIdentifierOrKeyword(token()) || token() === 18;
16364                 case 14:
16365                     return true;
16366             }
16367             return ts.Debug.fail("Non-exhaustive case in 'isListElement'.");
16368         }
16369         function isValidHeritageClauseObjectLiteral() {
16370             ts.Debug.assert(token() === 18);
16371             if (nextToken() === 19) {
16372                 var next = nextToken();
16373                 return next === 27 || next === 18 || next === 90 || next === 113;
16374             }
16375             return true;
16376         }
16377         function nextTokenIsIdentifier() {
16378             nextToken();
16379             return isIdentifier();
16380         }
16381         function nextTokenIsIdentifierOrKeyword() {
16382             nextToken();
16383             return ts.tokenIsIdentifierOrKeyword(token());
16384         }
16385         function nextTokenIsIdentifierOrKeywordOrGreaterThan() {
16386             nextToken();
16387             return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token());
16388         }
16389         function isHeritageClauseExtendsOrImplementsKeyword() {
16390             if (token() === 113 ||
16391                 token() === 90) {
16392                 return lookAhead(nextTokenIsStartOfExpression);
16393             }
16394             return false;
16395         }
16396         function nextTokenIsStartOfExpression() {
16397             nextToken();
16398             return isStartOfExpression();
16399         }
16400         function nextTokenIsStartOfType() {
16401             nextToken();
16402             return isStartOfType();
16403         }
16404         function isListTerminator(kind) {
16405             if (token() === 1) {
16406                 return true;
16407             }
16408             switch (kind) {
16409                 case 1:
16410                 case 2:
16411                 case 4:
16412                 case 5:
16413                 case 6:
16414                 case 12:
16415                 case 9:
16416                 case 23:
16417                     return token() === 19;
16418                 case 3:
16419                     return token() === 19 || token() === 78 || token() === 84;
16420                 case 7:
16421                     return token() === 18 || token() === 90 || token() === 113;
16422                 case 8:
16423                     return isVariableDeclaratorListTerminator();
16424                 case 19:
16425                     return token() === 31 || token() === 20 || token() === 18 || token() === 90 || token() === 113;
16426                 case 11:
16427                     return token() === 21 || token() === 26;
16428                 case 15:
16429                 case 21:
16430                 case 10:
16431                     return token() === 23;
16432                 case 17:
16433                 case 16:
16434                 case 18:
16435                     return token() === 21 || token() === 23;
16436                 case 20:
16437                     return token() !== 27;
16438                 case 22:
16439                     return token() === 18 || token() === 19;
16440                 case 13:
16441                     return token() === 31 || token() === 43;
16442                 case 14:
16443                     return token() === 29 && lookAhead(nextTokenIsSlash);
16444                 default:
16445                     return false;
16446             }
16447         }
16448         function isVariableDeclaratorListTerminator() {
16449             if (canParseSemicolon()) {
16450                 return true;
16451             }
16452             if (isInOrOfKeyword(token())) {
16453                 return true;
16454             }
16455             if (token() === 38) {
16456                 return true;
16457             }
16458             return false;
16459         }
16460         function isInSomeParsingContext() {
16461             for (var kind = 0; kind < 24; kind++) {
16462                 if (parsingContext & (1 << kind)) {
16463                     if (isListElement(kind, true) || isListTerminator(kind)) {
16464                         return true;
16465                     }
16466                 }
16467             }
16468             return false;
16469         }
16470         function parseList(kind, parseElement) {
16471             var saveParsingContext = parsingContext;
16472             parsingContext |= 1 << kind;
16473             var list = [];
16474             var listPos = getNodePos();
16475             while (!isListTerminator(kind)) {
16476                 if (isListElement(kind, false)) {
16477                     var element = parseListElement(kind, parseElement);
16478                     list.push(element);
16479                     continue;
16480                 }
16481                 if (abortParsingListOrMoveToNextToken(kind)) {
16482                     break;
16483                 }
16484             }
16485             parsingContext = saveParsingContext;
16486             return createNodeArray(list, listPos);
16487         }
16488         function parseListElement(parsingContext, parseElement) {
16489             var node = currentNode(parsingContext);
16490             if (node) {
16491                 return consumeNode(node);
16492             }
16493             return parseElement();
16494         }
16495         function currentNode(parsingContext) {
16496             if (!syntaxCursor || !isReusableParsingContext(parsingContext) || parseErrorBeforeNextFinishedNode) {
16497                 return undefined;
16498             }
16499             var node = syntaxCursor.currentNode(scanner.getStartPos());
16500             if (ts.nodeIsMissing(node) || node.intersectsChange || ts.containsParseError(node)) {
16501                 return undefined;
16502             }
16503             var nodeContextFlags = node.flags & 25358336;
16504             if (nodeContextFlags !== contextFlags) {
16505                 return undefined;
16506             }
16507             if (!canReuseNode(node, parsingContext)) {
16508                 return undefined;
16509             }
16510             if (node.jsDocCache) {
16511                 node.jsDocCache = undefined;
16512             }
16513             return node;
16514         }
16515         function consumeNode(node) {
16516             scanner.setTextPos(node.end);
16517             nextToken();
16518             return node;
16519         }
16520         function isReusableParsingContext(parsingContext) {
16521             switch (parsingContext) {
16522                 case 5:
16523                 case 2:
16524                 case 0:
16525                 case 1:
16526                 case 3:
16527                 case 6:
16528                 case 4:
16529                 case 8:
16530                 case 17:
16531                 case 16:
16532                     return true;
16533             }
16534             return false;
16535         }
16536         function canReuseNode(node, parsingContext) {
16537             switch (parsingContext) {
16538                 case 5:
16539                     return isReusableClassMember(node);
16540                 case 2:
16541                     return isReusableSwitchClause(node);
16542                 case 0:
16543                 case 1:
16544                 case 3:
16545                     return isReusableStatement(node);
16546                 case 6:
16547                     return isReusableEnumMember(node);
16548                 case 4:
16549                     return isReusableTypeMember(node);
16550                 case 8:
16551                     return isReusableVariableDeclaration(node);
16552                 case 17:
16553                 case 16:
16554                     return isReusableParameter(node);
16555             }
16556             return false;
16557         }
16558         function isReusableClassMember(node) {
16559             if (node) {
16560                 switch (node.kind) {
16561                     case 162:
16562                     case 167:
16563                     case 163:
16564                     case 164:
16565                     case 159:
16566                     case 222:
16567                         return true;
16568                     case 161:
16569                         var methodDeclaration = node;
16570                         var nameIsConstructor = methodDeclaration.name.kind === 75 &&
16571                             methodDeclaration.name.originalKeywordKind === 129;
16572                         return !nameIsConstructor;
16573                 }
16574             }
16575             return false;
16576         }
16577         function isReusableSwitchClause(node) {
16578             if (node) {
16579                 switch (node.kind) {
16580                     case 277:
16581                     case 278:
16582                         return true;
16583                 }
16584             }
16585             return false;
16586         }
16587         function isReusableStatement(node) {
16588             if (node) {
16589                 switch (node.kind) {
16590                     case 244:
16591                     case 225:
16592                     case 223:
16593                     case 227:
16594                     case 226:
16595                     case 239:
16596                     case 235:
16597                     case 237:
16598                     case 234:
16599                     case 233:
16600                     case 231:
16601                     case 232:
16602                     case 230:
16603                     case 229:
16604                     case 236:
16605                     case 224:
16606                     case 240:
16607                     case 238:
16608                     case 228:
16609                     case 241:
16610                     case 254:
16611                     case 253:
16612                     case 260:
16613                     case 259:
16614                     case 249:
16615                     case 245:
16616                     case 246:
16617                     case 248:
16618                     case 247:
16619                         return true;
16620                 }
16621             }
16622             return false;
16623         }
16624         function isReusableEnumMember(node) {
16625             return node.kind === 284;
16626         }
16627         function isReusableTypeMember(node) {
16628             if (node) {
16629                 switch (node.kind) {
16630                     case 166:
16631                     case 160:
16632                     case 167:
16633                     case 158:
16634                     case 165:
16635                         return true;
16636                 }
16637             }
16638             return false;
16639         }
16640         function isReusableVariableDeclaration(node) {
16641             if (node.kind !== 242) {
16642                 return false;
16643             }
16644             var variableDeclarator = node;
16645             return variableDeclarator.initializer === undefined;
16646         }
16647         function isReusableParameter(node) {
16648             if (node.kind !== 156) {
16649                 return false;
16650             }
16651             var parameter = node;
16652             return parameter.initializer === undefined;
16653         }
16654         function abortParsingListOrMoveToNextToken(kind) {
16655             parseErrorAtCurrentToken(parsingContextErrors(kind));
16656             if (isInSomeParsingContext()) {
16657                 return true;
16658             }
16659             nextToken();
16660             return false;
16661         }
16662         function parsingContextErrors(context) {
16663             switch (context) {
16664                 case 0: return ts.Diagnostics.Declaration_or_statement_expected;
16665                 case 1: return ts.Diagnostics.Declaration_or_statement_expected;
16666                 case 2: return ts.Diagnostics.case_or_default_expected;
16667                 case 3: return ts.Diagnostics.Statement_expected;
16668                 case 18:
16669                 case 4: return ts.Diagnostics.Property_or_signature_expected;
16670                 case 5: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected;
16671                 case 6: return ts.Diagnostics.Enum_member_expected;
16672                 case 7: return ts.Diagnostics.Expression_expected;
16673                 case 8: return ts.Diagnostics.Variable_declaration_expected;
16674                 case 9: return ts.Diagnostics.Property_destructuring_pattern_expected;
16675                 case 10: return ts.Diagnostics.Array_element_destructuring_pattern_expected;
16676                 case 11: return ts.Diagnostics.Argument_expression_expected;
16677                 case 12: return ts.Diagnostics.Property_assignment_expected;
16678                 case 15: return ts.Diagnostics.Expression_or_comma_expected;
16679                 case 17: return ts.Diagnostics.Parameter_declaration_expected;
16680                 case 16: return ts.Diagnostics.Parameter_declaration_expected;
16681                 case 19: return ts.Diagnostics.Type_parameter_declaration_expected;
16682                 case 20: return ts.Diagnostics.Type_argument_expected;
16683                 case 21: return ts.Diagnostics.Type_expected;
16684                 case 22: return ts.Diagnostics.Unexpected_token_expected;
16685                 case 23: return ts.Diagnostics.Identifier_expected;
16686                 case 13: return ts.Diagnostics.Identifier_expected;
16687                 case 14: return ts.Diagnostics.Identifier_expected;
16688                 default: return undefined;
16689             }
16690         }
16691         function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) {
16692             var saveParsingContext = parsingContext;
16693             parsingContext |= 1 << kind;
16694             var list = [];
16695             var listPos = getNodePos();
16696             var commaStart = -1;
16697             while (true) {
16698                 if (isListElement(kind, false)) {
16699                     var startPos = scanner.getStartPos();
16700                     list.push(parseListElement(kind, parseElement));
16701                     commaStart = scanner.getTokenPos();
16702                     if (parseOptional(27)) {
16703                         continue;
16704                     }
16705                     commaStart = -1;
16706                     if (isListTerminator(kind)) {
16707                         break;
16708                     }
16709                     parseExpected(27, getExpectedCommaDiagnostic(kind));
16710                     if (considerSemicolonAsDelimiter && token() === 26 && !scanner.hasPrecedingLineBreak()) {
16711                         nextToken();
16712                     }
16713                     if (startPos === scanner.getStartPos()) {
16714                         nextToken();
16715                     }
16716                     continue;
16717                 }
16718                 if (isListTerminator(kind)) {
16719                     break;
16720                 }
16721                 if (abortParsingListOrMoveToNextToken(kind)) {
16722                     break;
16723                 }
16724             }
16725             parsingContext = saveParsingContext;
16726             var result = createNodeArray(list, listPos);
16727             if (commaStart >= 0) {
16728                 result.hasTrailingComma = true;
16729             }
16730             return result;
16731         }
16732         function getExpectedCommaDiagnostic(kind) {
16733             return kind === 6 ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined;
16734         }
16735         function createMissingList() {
16736             var list = createNodeArray([], getNodePos());
16737             list.isMissingList = true;
16738             return list;
16739         }
16740         function isMissingList(arr) {
16741             return !!arr.isMissingList;
16742         }
16743         function parseBracketedList(kind, parseElement, open, close) {
16744             if (parseExpected(open)) {
16745                 var result = parseDelimitedList(kind, parseElement);
16746                 parseExpected(close);
16747                 return result;
16748             }
16749             return createMissingList();
16750         }
16751         function parseEntityName(allowReservedWords, diagnosticMessage) {
16752             var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage);
16753             var dotPos = scanner.getStartPos();
16754             while (parseOptional(24)) {
16755                 if (token() === 29) {
16756                     entity.jsdocDotPos = dotPos;
16757                     break;
16758                 }
16759                 dotPos = scanner.getStartPos();
16760                 entity = createQualifiedName(entity, parseRightSideOfDot(allowReservedWords, false));
16761             }
16762             return entity;
16763         }
16764         function createQualifiedName(entity, name) {
16765             var node = createNode(153, entity.pos);
16766             node.left = entity;
16767             node.right = name;
16768             return finishNode(node);
16769         }
16770         function parseRightSideOfDot(allowIdentifierNames, allowPrivateIdentifiers) {
16771             if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token())) {
16772                 var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine);
16773                 if (matchesPattern) {
16774                     return createMissingNode(75, true, ts.Diagnostics.Identifier_expected);
16775                 }
16776             }
16777             if (token() === 76) {
16778                 var node = parsePrivateIdentifier();
16779                 return allowPrivateIdentifiers ? node : createMissingNode(75, true, ts.Diagnostics.Identifier_expected);
16780             }
16781             return allowIdentifierNames ? parseIdentifierName() : parseIdentifier();
16782         }
16783         function parseTemplateExpression(isTaggedTemplate) {
16784             var template = createNode(211);
16785             template.head = parseTemplateHead(isTaggedTemplate);
16786             ts.Debug.assert(template.head.kind === 15, "Template head has wrong token kind");
16787             var list = [];
16788             var listPos = getNodePos();
16789             do {
16790                 list.push(parseTemplateSpan(isTaggedTemplate));
16791             } while (ts.last(list).literal.kind === 16);
16792             template.templateSpans = createNodeArray(list, listPos);
16793             return finishNode(template);
16794         }
16795         function parseTemplateSpan(isTaggedTemplate) {
16796             var span = createNode(221);
16797             span.expression = allowInAnd(parseExpression);
16798             var literal;
16799             if (token() === 19) {
16800                 reScanTemplateToken(isTaggedTemplate);
16801                 literal = parseTemplateMiddleOrTemplateTail();
16802             }
16803             else {
16804                 literal = parseExpectedToken(17, ts.Diagnostics._0_expected, ts.tokenToString(19));
16805             }
16806             span.literal = literal;
16807             return finishNode(span);
16808         }
16809         function parseLiteralNode() {
16810             return parseLiteralLikeNode(token());
16811         }
16812         function parseTemplateHead(isTaggedTemplate) {
16813             if (isTaggedTemplate) {
16814                 reScanTemplateHeadOrNoSubstitutionTemplate();
16815             }
16816             var fragment = parseLiteralLikeNode(token());
16817             ts.Debug.assert(fragment.kind === 15, "Template head has wrong token kind");
16818             return fragment;
16819         }
16820         function parseTemplateMiddleOrTemplateTail() {
16821             var fragment = parseLiteralLikeNode(token());
16822             ts.Debug.assert(fragment.kind === 16 || fragment.kind === 17, "Template fragment has wrong token kind");
16823             return fragment;
16824         }
16825         function parseLiteralLikeNode(kind) {
16826             var node = createNode(kind);
16827             node.text = scanner.getTokenValue();
16828             switch (kind) {
16829                 case 14:
16830                 case 15:
16831                 case 16:
16832                 case 17:
16833                     var isLast = kind === 14 || kind === 17;
16834                     var tokenText = scanner.getTokenText();
16835                     node.rawText = tokenText.substring(1, tokenText.length - (scanner.isUnterminated() ? 0 : isLast ? 1 : 2));
16836                     break;
16837             }
16838             if (scanner.hasExtendedUnicodeEscape()) {
16839                 node.hasExtendedUnicodeEscape = true;
16840             }
16841             if (scanner.isUnterminated()) {
16842                 node.isUnterminated = true;
16843             }
16844             if (node.kind === 8) {
16845                 node.numericLiteralFlags = scanner.getTokenFlags() & 1008;
16846             }
16847             if (ts.isTemplateLiteralKind(node.kind)) {
16848                 node.templateFlags = scanner.getTokenFlags() & 2048;
16849             }
16850             nextToken();
16851             finishNode(node);
16852             return node;
16853         }
16854         function parseTypeReference() {
16855             var node = createNode(169);
16856             node.typeName = parseEntityName(true, ts.Diagnostics.Type_expected);
16857             if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29) {
16858                 node.typeArguments = parseBracketedList(20, parseType, 29, 31);
16859             }
16860             return finishNode(node);
16861         }
16862         function typeHasArrowFunctionBlockingParseError(node) {
16863             switch (node.kind) {
16864                 case 169:
16865                     return ts.nodeIsMissing(node.typeName);
16866                 case 170:
16867                 case 171: {
16868                     var _a = node, parameters = _a.parameters, type = _a.type;
16869                     return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type);
16870                 }
16871                 case 182:
16872                     return typeHasArrowFunctionBlockingParseError(node.type);
16873                 default:
16874                     return false;
16875             }
16876         }
16877         function parseThisTypePredicate(lhs) {
16878             nextToken();
16879             var node = createNode(168, lhs.pos);
16880             node.parameterName = lhs;
16881             node.type = parseType();
16882             return finishNode(node);
16883         }
16884         function parseThisTypeNode() {
16885             var node = createNode(183);
16886             nextToken();
16887             return finishNode(node);
16888         }
16889         function parseJSDocAllType(postFixEquals) {
16890             var result = createNode(295);
16891             if (postFixEquals) {
16892                 return createPostfixType(299, result);
16893             }
16894             else {
16895                 nextToken();
16896             }
16897             return finishNode(result);
16898         }
16899         function parseJSDocNonNullableType() {
16900             var result = createNode(298);
16901             nextToken();
16902             result.type = parseNonArrayType();
16903             return finishNode(result);
16904         }
16905         function parseJSDocUnknownOrNullableType() {
16906             var pos = scanner.getStartPos();
16907             nextToken();
16908             if (token() === 27 ||
16909                 token() === 19 ||
16910                 token() === 21 ||
16911                 token() === 31 ||
16912                 token() === 62 ||
16913                 token() === 51) {
16914                 var result = createNode(296, pos);
16915                 return finishNode(result);
16916             }
16917             else {
16918                 var result = createNode(297, pos);
16919                 result.type = parseType();
16920                 return finishNode(result);
16921             }
16922         }
16923         function parseJSDocFunctionType() {
16924             if (lookAhead(nextTokenIsOpenParen)) {
16925                 var result = createNodeWithJSDoc(300);
16926                 nextToken();
16927                 fillSignature(58, 4 | 32, result);
16928                 return finishNode(result);
16929             }
16930             var node = createNode(169);
16931             node.typeName = parseIdentifierName();
16932             return finishNode(node);
16933         }
16934         function parseJSDocParameter() {
16935             var parameter = createNode(156);
16936             if (token() === 104 || token() === 99) {
16937                 parameter.name = parseIdentifierName();
16938                 parseExpected(58);
16939             }
16940             parameter.type = parseJSDocType();
16941             return finishNode(parameter);
16942         }
16943         function parseJSDocType() {
16944             scanner.setInJSDocType(true);
16945             var moduleSpecifier = parseOptionalToken(135);
16946             if (moduleSpecifier) {
16947                 var moduleTag = createNode(302, moduleSpecifier.pos);
16948                 terminate: while (true) {
16949                     switch (token()) {
16950                         case 19:
16951                         case 1:
16952                         case 27:
16953                         case 5:
16954                             break terminate;
16955                         default:
16956                             nextTokenJSDoc();
16957                     }
16958                 }
16959                 scanner.setInJSDocType(false);
16960                 return finishNode(moduleTag);
16961             }
16962             var dotdotdot = parseOptionalToken(25);
16963             var type = parseTypeOrTypePredicate();
16964             scanner.setInJSDocType(false);
16965             if (dotdotdot) {
16966                 var variadic = createNode(301, dotdotdot.pos);
16967                 variadic.type = type;
16968                 type = finishNode(variadic);
16969             }
16970             if (token() === 62) {
16971                 return createPostfixType(299, type);
16972             }
16973             return type;
16974         }
16975         function parseTypeQuery() {
16976             var node = createNode(172);
16977             parseExpected(108);
16978             node.exprName = parseEntityName(true);
16979             return finishNode(node);
16980         }
16981         function parseTypeParameter() {
16982             var node = createNode(155);
16983             node.name = parseIdentifier();
16984             if (parseOptional(90)) {
16985                 if (isStartOfType() || !isStartOfExpression()) {
16986                     node.constraint = parseType();
16987                 }
16988                 else {
16989                     node.expression = parseUnaryExpressionOrHigher();
16990                 }
16991             }
16992             if (parseOptional(62)) {
16993                 node.default = parseType();
16994             }
16995             return finishNode(node);
16996         }
16997         function parseTypeParameters() {
16998             if (token() === 29) {
16999                 return parseBracketedList(19, parseTypeParameter, 29, 31);
17000             }
17001         }
17002         function parseParameterType() {
17003             if (parseOptional(58)) {
17004                 return parseType();
17005             }
17006             return undefined;
17007         }
17008         function isStartOfParameter(isJSDocParameter) {
17009             return token() === 25 ||
17010                 isIdentifierOrPrivateIdentifierOrPattern() ||
17011                 ts.isModifierKind(token()) ||
17012                 token() === 59 ||
17013                 isStartOfType(!isJSDocParameter);
17014         }
17015         function parseParameter() {
17016             var node = createNodeWithJSDoc(156);
17017             if (token() === 104) {
17018                 node.name = createIdentifier(true);
17019                 node.type = parseParameterType();
17020                 return finishNode(node);
17021             }
17022             node.decorators = parseDecorators();
17023             node.modifiers = parseModifiers();
17024             node.dotDotDotToken = parseOptionalToken(25);
17025             node.name = parseIdentifierOrPattern(ts.Diagnostics.Private_identifiers_cannot_be_used_as_parameters);
17026             if (ts.getFullWidth(node.name) === 0 && !node.modifiers && ts.isModifierKind(token())) {
17027                 nextToken();
17028             }
17029             node.questionToken = parseOptionalToken(57);
17030             node.type = parseParameterType();
17031             node.initializer = parseInitializer();
17032             return finishNode(node);
17033         }
17034         function fillSignature(returnToken, flags, signature) {
17035             if (!(flags & 32)) {
17036                 signature.typeParameters = parseTypeParameters();
17037             }
17038             var parametersParsedSuccessfully = parseParameterList(signature, flags);
17039             if (shouldParseReturnType(returnToken, !!(flags & 4))) {
17040                 signature.type = parseTypeOrTypePredicate();
17041                 if (typeHasArrowFunctionBlockingParseError(signature.type))
17042                     return false;
17043             }
17044             return parametersParsedSuccessfully;
17045         }
17046         function shouldParseReturnType(returnToken, isType) {
17047             if (returnToken === 38) {
17048                 parseExpected(returnToken);
17049                 return true;
17050             }
17051             else if (parseOptional(58)) {
17052                 return true;
17053             }
17054             else if (isType && token() === 38) {
17055                 parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58));
17056                 nextToken();
17057                 return true;
17058             }
17059             return false;
17060         }
17061         function parseParameterList(signature, flags) {
17062             if (!parseExpected(20)) {
17063                 signature.parameters = createMissingList();
17064                 return false;
17065             }
17066             var savedYieldContext = inYieldContext();
17067             var savedAwaitContext = inAwaitContext();
17068             setYieldContext(!!(flags & 1));
17069             setAwaitContext(!!(flags & 2));
17070             signature.parameters = flags & 32 ?
17071                 parseDelimitedList(17, parseJSDocParameter) :
17072                 parseDelimitedList(16, parseParameter);
17073             setYieldContext(savedYieldContext);
17074             setAwaitContext(savedAwaitContext);
17075             return parseExpected(21);
17076         }
17077         function parseTypeMemberSemicolon() {
17078             if (parseOptional(27)) {
17079                 return;
17080             }
17081             parseSemicolon();
17082         }
17083         function parseSignatureMember(kind) {
17084             var node = createNodeWithJSDoc(kind);
17085             if (kind === 166) {
17086                 parseExpected(99);
17087             }
17088             fillSignature(58, 4, node);
17089             parseTypeMemberSemicolon();
17090             return finishNode(node);
17091         }
17092         function isIndexSignature() {
17093             return token() === 22 && lookAhead(isUnambiguouslyIndexSignature);
17094         }
17095         function isUnambiguouslyIndexSignature() {
17096             nextToken();
17097             if (token() === 25 || token() === 23) {
17098                 return true;
17099             }
17100             if (ts.isModifierKind(token())) {
17101                 nextToken();
17102                 if (isIdentifier()) {
17103                     return true;
17104                 }
17105             }
17106             else if (!isIdentifier()) {
17107                 return false;
17108             }
17109             else {
17110                 nextToken();
17111             }
17112             if (token() === 58 || token() === 27) {
17113                 return true;
17114             }
17115             if (token() !== 57) {
17116                 return false;
17117             }
17118             nextToken();
17119             return token() === 58 || token() === 27 || token() === 23;
17120         }
17121         function parseIndexSignatureDeclaration(node) {
17122             node.kind = 167;
17123             node.parameters = parseBracketedList(16, parseParameter, 22, 23);
17124             node.type = parseTypeAnnotation();
17125             parseTypeMemberSemicolon();
17126             return finishNode(node);
17127         }
17128         function parsePropertyOrMethodSignature(node) {
17129             node.name = parsePropertyName();
17130             node.questionToken = parseOptionalToken(57);
17131             if (token() === 20 || token() === 29) {
17132                 node.kind = 160;
17133                 fillSignature(58, 4, node);
17134             }
17135             else {
17136                 node.kind = 158;
17137                 node.type = parseTypeAnnotation();
17138                 if (token() === 62) {
17139                     node.initializer = parseInitializer();
17140                 }
17141             }
17142             parseTypeMemberSemicolon();
17143             return finishNode(node);
17144         }
17145         function isTypeMemberStart() {
17146             if (token() === 20 || token() === 29) {
17147                 return true;
17148             }
17149             var idToken = false;
17150             while (ts.isModifierKind(token())) {
17151                 idToken = true;
17152                 nextToken();
17153             }
17154             if (token() === 22) {
17155                 return true;
17156             }
17157             if (isLiteralPropertyName()) {
17158                 idToken = true;
17159                 nextToken();
17160             }
17161             if (idToken) {
17162                 return token() === 20 ||
17163                     token() === 29 ||
17164                     token() === 57 ||
17165                     token() === 58 ||
17166                     token() === 27 ||
17167                     canParseSemicolon();
17168             }
17169             return false;
17170         }
17171         function parseTypeMember() {
17172             if (token() === 20 || token() === 29) {
17173                 return parseSignatureMember(165);
17174             }
17175             if (token() === 99 && lookAhead(nextTokenIsOpenParenOrLessThan)) {
17176                 return parseSignatureMember(166);
17177             }
17178             var node = createNodeWithJSDoc(0);
17179             node.modifiers = parseModifiers();
17180             if (isIndexSignature()) {
17181                 return parseIndexSignatureDeclaration(node);
17182             }
17183             return parsePropertyOrMethodSignature(node);
17184         }
17185         function nextTokenIsOpenParenOrLessThan() {
17186             nextToken();
17187             return token() === 20 || token() === 29;
17188         }
17189         function nextTokenIsDot() {
17190             return nextToken() === 24;
17191         }
17192         function nextTokenIsOpenParenOrLessThanOrDot() {
17193             switch (nextToken()) {
17194                 case 20:
17195                 case 29:
17196                 case 24:
17197                     return true;
17198             }
17199             return false;
17200         }
17201         function parseTypeLiteral() {
17202             var node = createNode(173);
17203             node.members = parseObjectTypeMembers();
17204             return finishNode(node);
17205         }
17206         function parseObjectTypeMembers() {
17207             var members;
17208             if (parseExpected(18)) {
17209                 members = parseList(4, parseTypeMember);
17210                 parseExpected(19);
17211             }
17212             else {
17213                 members = createMissingList();
17214             }
17215             return members;
17216         }
17217         function isStartOfMappedType() {
17218             nextToken();
17219             if (token() === 39 || token() === 40) {
17220                 return nextToken() === 138;
17221             }
17222             if (token() === 138) {
17223                 nextToken();
17224             }
17225             return token() === 22 && nextTokenIsIdentifier() && nextToken() === 97;
17226         }
17227         function parseMappedTypeParameter() {
17228             var node = createNode(155);
17229             node.name = parseIdentifier();
17230             parseExpected(97);
17231             node.constraint = parseType();
17232             return finishNode(node);
17233         }
17234         function parseMappedType() {
17235             var node = createNode(186);
17236             parseExpected(18);
17237             if (token() === 138 || token() === 39 || token() === 40) {
17238                 node.readonlyToken = parseTokenNode();
17239                 if (node.readonlyToken.kind !== 138) {
17240                     parseExpectedToken(138);
17241                 }
17242             }
17243             parseExpected(22);
17244             node.typeParameter = parseMappedTypeParameter();
17245             parseExpected(23);
17246             if (token() === 57 || token() === 39 || token() === 40) {
17247                 node.questionToken = parseTokenNode();
17248                 if (node.questionToken.kind !== 57) {
17249                     parseExpectedToken(57);
17250                 }
17251             }
17252             node.type = parseTypeAnnotation();
17253             parseSemicolon();
17254             parseExpected(19);
17255             return finishNode(node);
17256         }
17257         function parseTupleElementType() {
17258             var pos = getNodePos();
17259             if (parseOptional(25)) {
17260                 var node = createNode(177, pos);
17261                 node.type = parseType();
17262                 return finishNode(node);
17263             }
17264             var type = parseType();
17265             if (!(contextFlags & 4194304) && type.kind === 297 && type.pos === type.type.pos) {
17266                 type.kind = 176;
17267             }
17268             return type;
17269         }
17270         function parseTupleType() {
17271             var node = createNode(175);
17272             node.elementTypes = parseBracketedList(21, parseTupleElementType, 22, 23);
17273             return finishNode(node);
17274         }
17275         function parseParenthesizedType() {
17276             var node = createNode(182);
17277             parseExpected(20);
17278             node.type = parseType();
17279             parseExpected(21);
17280             return finishNode(node);
17281         }
17282         function parseFunctionOrConstructorType() {
17283             var pos = getNodePos();
17284             var kind = parseOptional(99) ? 171 : 170;
17285             var node = createNodeWithJSDoc(kind, pos);
17286             fillSignature(38, 4, node);
17287             return finishNode(node);
17288         }
17289         function parseKeywordAndNoDot() {
17290             var node = parseTokenNode();
17291             return token() === 24 ? undefined : node;
17292         }
17293         function parseLiteralTypeNode(negative) {
17294             var node = createNode(187);
17295             var unaryMinusExpression;
17296             if (negative) {
17297                 unaryMinusExpression = createNode(207);
17298                 unaryMinusExpression.operator = 40;
17299                 nextToken();
17300             }
17301             var expression = token() === 106 || token() === 91
17302                 ? parseTokenNode()
17303                 : parseLiteralLikeNode(token());
17304             if (negative) {
17305                 unaryMinusExpression.operand = expression;
17306                 finishNode(unaryMinusExpression);
17307                 expression = unaryMinusExpression;
17308             }
17309             node.literal = expression;
17310             return finishNode(node);
17311         }
17312         function isStartOfTypeOfImportType() {
17313             nextToken();
17314             return token() === 96;
17315         }
17316         function parseImportType() {
17317             sourceFile.flags |= 1048576;
17318             var node = createNode(188);
17319             if (parseOptional(108)) {
17320                 node.isTypeOf = true;
17321             }
17322             parseExpected(96);
17323             parseExpected(20);
17324             node.argument = parseType();
17325             parseExpected(21);
17326             if (parseOptional(24)) {
17327                 node.qualifier = parseEntityName(true, ts.Diagnostics.Type_expected);
17328             }
17329             if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29) {
17330                 node.typeArguments = parseBracketedList(20, parseType, 29, 31);
17331             }
17332             return finishNode(node);
17333         }
17334         function nextTokenIsNumericOrBigIntLiteral() {
17335             nextToken();
17336             return token() === 8 || token() === 9;
17337         }
17338         function parseNonArrayType() {
17339             switch (token()) {
17340                 case 125:
17341                 case 148:
17342                 case 143:
17343                 case 140:
17344                 case 151:
17345                 case 144:
17346                 case 128:
17347                 case 146:
17348                 case 137:
17349                 case 141:
17350                     return tryParse(parseKeywordAndNoDot) || parseTypeReference();
17351                 case 41:
17352                     return parseJSDocAllType(false);
17353                 case 65:
17354                     return parseJSDocAllType(true);
17355                 case 60:
17356                     scanner.reScanQuestionToken();
17357                 case 57:
17358                     return parseJSDocUnknownOrNullableType();
17359                 case 94:
17360                     return parseJSDocFunctionType();
17361                 case 53:
17362                     return parseJSDocNonNullableType();
17363                 case 14:
17364                 case 10:
17365                 case 8:
17366                 case 9:
17367                 case 106:
17368                 case 91:
17369                     return parseLiteralTypeNode();
17370                 case 40:
17371                     return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(true) : parseTypeReference();
17372                 case 110:
17373                 case 100:
17374                     return parseTokenNode();
17375                 case 104: {
17376                     var thisKeyword = parseThisTypeNode();
17377                     if (token() === 133 && !scanner.hasPrecedingLineBreak()) {
17378                         return parseThisTypePredicate(thisKeyword);
17379                     }
17380                     else {
17381                         return thisKeyword;
17382                     }
17383                 }
17384                 case 108:
17385                     return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery();
17386                 case 18:
17387                     return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral();
17388                 case 22:
17389                     return parseTupleType();
17390                 case 20:
17391                     return parseParenthesizedType();
17392                 case 96:
17393                     return parseImportType();
17394                 case 124:
17395                     return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference();
17396                 default:
17397                     return parseTypeReference();
17398             }
17399         }
17400         function isStartOfType(inStartOfParameter) {
17401             switch (token()) {
17402                 case 125:
17403                 case 148:
17404                 case 143:
17405                 case 140:
17406                 case 151:
17407                 case 128:
17408                 case 138:
17409                 case 144:
17410                 case 147:
17411                 case 110:
17412                 case 146:
17413                 case 100:
17414                 case 104:
17415                 case 108:
17416                 case 137:
17417                 case 18:
17418                 case 22:
17419                 case 29:
17420                 case 51:
17421                 case 50:
17422                 case 99:
17423                 case 10:
17424                 case 8:
17425                 case 9:
17426                 case 106:
17427                 case 91:
17428                 case 141:
17429                 case 41:
17430                 case 57:
17431                 case 53:
17432                 case 25:
17433                 case 132:
17434                 case 96:
17435                 case 124:
17436                     return true;
17437                 case 94:
17438                     return !inStartOfParameter;
17439                 case 40:
17440                     return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral);
17441                 case 20:
17442                     return !inStartOfParameter && lookAhead(isStartOfParenthesizedOrFunctionType);
17443                 default:
17444                     return isIdentifier();
17445             }
17446         }
17447         function isStartOfParenthesizedOrFunctionType() {
17448             nextToken();
17449             return token() === 21 || isStartOfParameter(false) || isStartOfType();
17450         }
17451         function parsePostfixTypeOrHigher() {
17452             var type = parseNonArrayType();
17453             while (!scanner.hasPrecedingLineBreak()) {
17454                 switch (token()) {
17455                     case 53:
17456                         type = createPostfixType(298, type);
17457                         break;
17458                     case 57:
17459                         if (!(contextFlags & 4194304) && lookAhead(nextTokenIsStartOfType)) {
17460                             return type;
17461                         }
17462                         type = createPostfixType(297, type);
17463                         break;
17464                     case 22:
17465                         parseExpected(22);
17466                         if (isStartOfType()) {
17467                             var node = createNode(185, type.pos);
17468                             node.objectType = type;
17469                             node.indexType = parseType();
17470                             parseExpected(23);
17471                             type = finishNode(node);
17472                         }
17473                         else {
17474                             var node = createNode(174, type.pos);
17475                             node.elementType = type;
17476                             parseExpected(23);
17477                             type = finishNode(node);
17478                         }
17479                         break;
17480                     default:
17481                         return type;
17482                 }
17483             }
17484             return type;
17485         }
17486         function createPostfixType(kind, type) {
17487             nextToken();
17488             var postfix = createNode(kind, type.pos);
17489             postfix.type = type;
17490             return finishNode(postfix);
17491         }
17492         function parseTypeOperator(operator) {
17493             var node = createNode(184);
17494             parseExpected(operator);
17495             node.operator = operator;
17496             node.type = parseTypeOperatorOrHigher();
17497             return finishNode(node);
17498         }
17499         function parseInferType() {
17500             var node = createNode(181);
17501             parseExpected(132);
17502             var typeParameter = createNode(155);
17503             typeParameter.name = parseIdentifier();
17504             node.typeParameter = finishNode(typeParameter);
17505             return finishNode(node);
17506         }
17507         function parseTypeOperatorOrHigher() {
17508             var operator = token();
17509             switch (operator) {
17510                 case 134:
17511                 case 147:
17512                 case 138:
17513                     return parseTypeOperator(operator);
17514                 case 132:
17515                     return parseInferType();
17516             }
17517             return parsePostfixTypeOrHigher();
17518         }
17519         function parseUnionOrIntersectionType(kind, parseConstituentType, operator) {
17520             var start = scanner.getStartPos();
17521             var hasLeadingOperator = parseOptional(operator);
17522             var type = parseConstituentType();
17523             if (token() === operator || hasLeadingOperator) {
17524                 var types = [type];
17525                 while (parseOptional(operator)) {
17526                     types.push(parseConstituentType());
17527                 }
17528                 var node = createNode(kind, start);
17529                 node.types = createNodeArray(types, start);
17530                 type = finishNode(node);
17531             }
17532             return type;
17533         }
17534         function parseIntersectionTypeOrHigher() {
17535             return parseUnionOrIntersectionType(179, parseTypeOperatorOrHigher, 50);
17536         }
17537         function parseUnionTypeOrHigher() {
17538             return parseUnionOrIntersectionType(178, parseIntersectionTypeOrHigher, 51);
17539         }
17540         function isStartOfFunctionType() {
17541             if (token() === 29) {
17542                 return true;
17543             }
17544             return token() === 20 && lookAhead(isUnambiguouslyStartOfFunctionType);
17545         }
17546         function skipParameterStart() {
17547             if (ts.isModifierKind(token())) {
17548                 parseModifiers();
17549             }
17550             if (isIdentifier() || token() === 104) {
17551                 nextToken();
17552                 return true;
17553             }
17554             if (token() === 22 || token() === 18) {
17555                 var previousErrorCount = parseDiagnostics.length;
17556                 parseIdentifierOrPattern();
17557                 return previousErrorCount === parseDiagnostics.length;
17558             }
17559             return false;
17560         }
17561         function isUnambiguouslyStartOfFunctionType() {
17562             nextToken();
17563             if (token() === 21 || token() === 25) {
17564                 return true;
17565             }
17566             if (skipParameterStart()) {
17567                 if (token() === 58 || token() === 27 ||
17568                     token() === 57 || token() === 62) {
17569                     return true;
17570                 }
17571                 if (token() === 21) {
17572                     nextToken();
17573                     if (token() === 38) {
17574                         return true;
17575                     }
17576                 }
17577             }
17578             return false;
17579         }
17580         function parseTypeOrTypePredicate() {
17581             var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix);
17582             var type = parseType();
17583             if (typePredicateVariable) {
17584                 var node = createNode(168, typePredicateVariable.pos);
17585                 node.assertsModifier = undefined;
17586                 node.parameterName = typePredicateVariable;
17587                 node.type = type;
17588                 return finishNode(node);
17589             }
17590             else {
17591                 return type;
17592             }
17593         }
17594         function parseTypePredicatePrefix() {
17595             var id = parseIdentifier();
17596             if (token() === 133 && !scanner.hasPrecedingLineBreak()) {
17597                 nextToken();
17598                 return id;
17599             }
17600         }
17601         function parseAssertsTypePredicate() {
17602             var node = createNode(168);
17603             node.assertsModifier = parseExpectedToken(124);
17604             node.parameterName = token() === 104 ? parseThisTypeNode() : parseIdentifier();
17605             node.type = parseOptional(133) ? parseType() : undefined;
17606             return finishNode(node);
17607         }
17608         function parseType() {
17609             return doOutsideOfContext(40960, parseTypeWorker);
17610         }
17611         function parseTypeWorker(noConditionalTypes) {
17612             if (isStartOfFunctionType() || token() === 99) {
17613                 return parseFunctionOrConstructorType();
17614             }
17615             var type = parseUnionTypeOrHigher();
17616             if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(90)) {
17617                 var node = createNode(180, type.pos);
17618                 node.checkType = type;
17619                 node.extendsType = parseTypeWorker(true);
17620                 parseExpected(57);
17621                 node.trueType = parseTypeWorker();
17622                 parseExpected(58);
17623                 node.falseType = parseTypeWorker();
17624                 return finishNode(node);
17625             }
17626             return type;
17627         }
17628         function parseTypeAnnotation() {
17629             return parseOptional(58) ? parseType() : undefined;
17630         }
17631         function isStartOfLeftHandSideExpression() {
17632             switch (token()) {
17633                 case 104:
17634                 case 102:
17635                 case 100:
17636                 case 106:
17637                 case 91:
17638                 case 8:
17639                 case 9:
17640                 case 10:
17641                 case 14:
17642                 case 15:
17643                 case 20:
17644                 case 22:
17645                 case 18:
17646                 case 94:
17647                 case 80:
17648                 case 99:
17649                 case 43:
17650                 case 67:
17651                 case 75:
17652                     return true;
17653                 case 96:
17654                     return lookAhead(nextTokenIsOpenParenOrLessThanOrDot);
17655                 default:
17656                     return isIdentifier();
17657             }
17658         }
17659         function isStartOfExpression() {
17660             if (isStartOfLeftHandSideExpression()) {
17661                 return true;
17662             }
17663             switch (token()) {
17664                 case 39:
17665                 case 40:
17666                 case 54:
17667                 case 53:
17668                 case 85:
17669                 case 108:
17670                 case 110:
17671                 case 45:
17672                 case 46:
17673                 case 29:
17674                 case 127:
17675                 case 121:
17676                 case 76:
17677                     return true;
17678                 default:
17679                     if (isBinaryOperator()) {
17680                         return true;
17681                     }
17682                     return isIdentifier();
17683             }
17684         }
17685         function isStartOfExpressionStatement() {
17686             return token() !== 18 &&
17687                 token() !== 94 &&
17688                 token() !== 80 &&
17689                 token() !== 59 &&
17690                 isStartOfExpression();
17691         }
17692         function parseExpression() {
17693             var saveDecoratorContext = inDecoratorContext();
17694             if (saveDecoratorContext) {
17695                 setDecoratorContext(false);
17696             }
17697             var expr = parseAssignmentExpressionOrHigher();
17698             var operatorToken;
17699             while ((operatorToken = parseOptionalToken(27))) {
17700                 expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher());
17701             }
17702             if (saveDecoratorContext) {
17703                 setDecoratorContext(true);
17704             }
17705             return expr;
17706         }
17707         function parseInitializer() {
17708             return parseOptional(62) ? parseAssignmentExpressionOrHigher() : undefined;
17709         }
17710         function parseAssignmentExpressionOrHigher() {
17711             if (isYieldExpression()) {
17712                 return parseYieldExpression();
17713             }
17714             var arrowExpression = tryParseParenthesizedArrowFunctionExpression() || tryParseAsyncSimpleArrowFunctionExpression();
17715             if (arrowExpression) {
17716                 return arrowExpression;
17717             }
17718             var expr = parseBinaryExpressionOrHigher(0);
17719             if (expr.kind === 75 && token() === 38) {
17720                 return parseSimpleArrowFunctionExpression(expr);
17721             }
17722             if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) {
17723                 return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher());
17724             }
17725             return parseConditionalExpressionRest(expr);
17726         }
17727         function isYieldExpression() {
17728             if (token() === 121) {
17729                 if (inYieldContext()) {
17730                     return true;
17731                 }
17732                 return lookAhead(nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine);
17733             }
17734             return false;
17735         }
17736         function nextTokenIsIdentifierOnSameLine() {
17737             nextToken();
17738             return !scanner.hasPrecedingLineBreak() && isIdentifier();
17739         }
17740         function parseYieldExpression() {
17741             var node = createNode(212);
17742             nextToken();
17743             if (!scanner.hasPrecedingLineBreak() &&
17744                 (token() === 41 || isStartOfExpression())) {
17745                 node.asteriskToken = parseOptionalToken(41);
17746                 node.expression = parseAssignmentExpressionOrHigher();
17747                 return finishNode(node);
17748             }
17749             else {
17750                 return finishNode(node);
17751             }
17752         }
17753         function parseSimpleArrowFunctionExpression(identifier, asyncModifier) {
17754             ts.Debug.assert(token() === 38, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
17755             var node;
17756             if (asyncModifier) {
17757                 node = createNode(202, asyncModifier.pos);
17758                 node.modifiers = asyncModifier;
17759             }
17760             else {
17761                 node = createNode(202, identifier.pos);
17762             }
17763             var parameter = createNode(156, identifier.pos);
17764             parameter.name = identifier;
17765             finishNode(parameter);
17766             node.parameters = createNodeArray([parameter], parameter.pos, parameter.end);
17767             node.equalsGreaterThanToken = parseExpectedToken(38);
17768             node.body = parseArrowFunctionExpressionBody(!!asyncModifier);
17769             return addJSDocComment(finishNode(node));
17770         }
17771         function tryParseParenthesizedArrowFunctionExpression() {
17772             var triState = isParenthesizedArrowFunctionExpression();
17773             if (triState === 0) {
17774                 return undefined;
17775             }
17776             var arrowFunction = triState === 1
17777                 ? parseParenthesizedArrowFunctionExpressionHead(true)
17778                 : tryParse(parsePossibleParenthesizedArrowFunctionExpressionHead);
17779             if (!arrowFunction) {
17780                 return undefined;
17781             }
17782             var isAsync = hasModifierOfKind(arrowFunction, 126);
17783             var lastToken = token();
17784             arrowFunction.equalsGreaterThanToken = parseExpectedToken(38);
17785             arrowFunction.body = (lastToken === 38 || lastToken === 18)
17786                 ? parseArrowFunctionExpressionBody(isAsync)
17787                 : parseIdentifier();
17788             return finishNode(arrowFunction);
17789         }
17790         function isParenthesizedArrowFunctionExpression() {
17791             if (token() === 20 || token() === 29 || token() === 126) {
17792                 return lookAhead(isParenthesizedArrowFunctionExpressionWorker);
17793             }
17794             if (token() === 38) {
17795                 return 1;
17796             }
17797             return 0;
17798         }
17799         function isParenthesizedArrowFunctionExpressionWorker() {
17800             if (token() === 126) {
17801                 nextToken();
17802                 if (scanner.hasPrecedingLineBreak()) {
17803                     return 0;
17804                 }
17805                 if (token() !== 20 && token() !== 29) {
17806                     return 0;
17807                 }
17808             }
17809             var first = token();
17810             var second = nextToken();
17811             if (first === 20) {
17812                 if (second === 21) {
17813                     var third = nextToken();
17814                     switch (third) {
17815                         case 38:
17816                         case 58:
17817                         case 18:
17818                             return 1;
17819                         default:
17820                             return 0;
17821                     }
17822                 }
17823                 if (second === 22 || second === 18) {
17824                     return 2;
17825                 }
17826                 if (second === 25) {
17827                     return 1;
17828                 }
17829                 if (ts.isModifierKind(second) && second !== 126 && lookAhead(nextTokenIsIdentifier)) {
17830                     return 1;
17831                 }
17832                 if (!isIdentifier() && second !== 104) {
17833                     return 0;
17834                 }
17835                 switch (nextToken()) {
17836                     case 58:
17837                         return 1;
17838                     case 57:
17839                         nextToken();
17840                         if (token() === 58 || token() === 27 || token() === 62 || token() === 21) {
17841                             return 1;
17842                         }
17843                         return 0;
17844                     case 27:
17845                     case 62:
17846                     case 21:
17847                         return 2;
17848                 }
17849                 return 0;
17850             }
17851             else {
17852                 ts.Debug.assert(first === 29);
17853                 if (!isIdentifier()) {
17854                     return 0;
17855                 }
17856                 if (sourceFile.languageVariant === 1) {
17857                     var isArrowFunctionInJsx = lookAhead(function () {
17858                         var third = nextToken();
17859                         if (third === 90) {
17860                             var fourth = nextToken();
17861                             switch (fourth) {
17862                                 case 62:
17863                                 case 31:
17864                                     return false;
17865                                 default:
17866                                     return true;
17867                             }
17868                         }
17869                         else if (third === 27) {
17870                             return true;
17871                         }
17872                         return false;
17873                     });
17874                     if (isArrowFunctionInJsx) {
17875                         return 1;
17876                     }
17877                     return 0;
17878                 }
17879                 return 2;
17880             }
17881         }
17882         function parsePossibleParenthesizedArrowFunctionExpressionHead() {
17883             var tokenPos = scanner.getTokenPos();
17884             if (notParenthesizedArrow && notParenthesizedArrow.has(tokenPos.toString())) {
17885                 return undefined;
17886             }
17887             var result = parseParenthesizedArrowFunctionExpressionHead(false);
17888             if (!result) {
17889                 (notParenthesizedArrow || (notParenthesizedArrow = ts.createMap())).set(tokenPos.toString(), true);
17890             }
17891             return result;
17892         }
17893         function tryParseAsyncSimpleArrowFunctionExpression() {
17894             if (token() === 126) {
17895                 if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1) {
17896                     var asyncModifier = parseModifiersForArrowFunction();
17897                     var expr = parseBinaryExpressionOrHigher(0);
17898                     return parseSimpleArrowFunctionExpression(expr, asyncModifier);
17899                 }
17900             }
17901             return undefined;
17902         }
17903         function isUnParenthesizedAsyncArrowFunctionWorker() {
17904             if (token() === 126) {
17905                 nextToken();
17906                 if (scanner.hasPrecedingLineBreak() || token() === 38) {
17907                     return 0;
17908                 }
17909                 var expr = parseBinaryExpressionOrHigher(0);
17910                 if (!scanner.hasPrecedingLineBreak() && expr.kind === 75 && token() === 38) {
17911                     return 1;
17912                 }
17913             }
17914             return 0;
17915         }
17916         function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) {
17917             var node = createNodeWithJSDoc(202);
17918             node.modifiers = parseModifiersForArrowFunction();
17919             var isAsync = hasModifierOfKind(node, 126) ? 2 : 0;
17920             if (!fillSignature(58, isAsync, node) && !allowAmbiguity) {
17921                 return undefined;
17922             }
17923             var hasJSDocFunctionType = node.type && ts.isJSDocFunctionType(node.type);
17924             if (!allowAmbiguity && token() !== 38 && (hasJSDocFunctionType || token() !== 18)) {
17925                 return undefined;
17926             }
17927             return node;
17928         }
17929         function parseArrowFunctionExpressionBody(isAsync) {
17930             if (token() === 18) {
17931                 return parseFunctionBlock(isAsync ? 2 : 0);
17932             }
17933             if (token() !== 26 &&
17934                 token() !== 94 &&
17935                 token() !== 80 &&
17936                 isStartOfStatement() &&
17937                 !isStartOfExpressionStatement()) {
17938                 return parseFunctionBlock(16 | (isAsync ? 2 : 0));
17939             }
17940             return isAsync
17941                 ? doInAwaitContext(parseAssignmentExpressionOrHigher)
17942                 : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher);
17943         }
17944         function parseConditionalExpressionRest(leftOperand) {
17945             var questionToken = parseOptionalToken(57);
17946             if (!questionToken) {
17947                 return leftOperand;
17948             }
17949             var node = createNode(210, leftOperand.pos);
17950             node.condition = leftOperand;
17951             node.questionToken = questionToken;
17952             node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher);
17953             node.colonToken = parseExpectedToken(58);
17954             node.whenFalse = ts.nodeIsPresent(node.colonToken)
17955                 ? parseAssignmentExpressionOrHigher()
17956                 : createMissingNode(75, false, ts.Diagnostics._0_expected, ts.tokenToString(58));
17957             return finishNode(node);
17958         }
17959         function parseBinaryExpressionOrHigher(precedence) {
17960             var leftOperand = parseUnaryExpressionOrHigher();
17961             return parseBinaryExpressionRest(precedence, leftOperand);
17962         }
17963         function isInOrOfKeyword(t) {
17964             return t === 97 || t === 152;
17965         }
17966         function parseBinaryExpressionRest(precedence, leftOperand) {
17967             while (true) {
17968                 reScanGreaterToken();
17969                 var newPrecedence = ts.getBinaryOperatorPrecedence(token());
17970                 var consumeCurrentOperator = token() === 42 ?
17971                     newPrecedence >= precedence :
17972                     newPrecedence > precedence;
17973                 if (!consumeCurrentOperator) {
17974                     break;
17975                 }
17976                 if (token() === 97 && inDisallowInContext()) {
17977                     break;
17978                 }
17979                 if (token() === 123) {
17980                     if (scanner.hasPrecedingLineBreak()) {
17981                         break;
17982                     }
17983                     else {
17984                         nextToken();
17985                         leftOperand = makeAsExpression(leftOperand, parseType());
17986                     }
17987                 }
17988                 else {
17989                     leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence));
17990                 }
17991             }
17992             return leftOperand;
17993         }
17994         function isBinaryOperator() {
17995             if (inDisallowInContext() && token() === 97) {
17996                 return false;
17997             }
17998             return ts.getBinaryOperatorPrecedence(token()) > 0;
17999         }
18000         function makeBinaryExpression(left, operatorToken, right) {
18001             var node = createNode(209, left.pos);
18002             node.left = left;
18003             node.operatorToken = operatorToken;
18004             node.right = right;
18005             return finishNode(node);
18006         }
18007         function makeAsExpression(left, right) {
18008             var node = createNode(217, left.pos);
18009             node.expression = left;
18010             node.type = right;
18011             return finishNode(node);
18012         }
18013         function parsePrefixUnaryExpression() {
18014             var node = createNode(207);
18015             node.operator = token();
18016             nextToken();
18017             node.operand = parseSimpleUnaryExpression();
18018             return finishNode(node);
18019         }
18020         function parseDeleteExpression() {
18021             var node = createNode(203);
18022             nextToken();
18023             node.expression = parseSimpleUnaryExpression();
18024             return finishNode(node);
18025         }
18026         function parseTypeOfExpression() {
18027             var node = createNode(204);
18028             nextToken();
18029             node.expression = parseSimpleUnaryExpression();
18030             return finishNode(node);
18031         }
18032         function parseVoidExpression() {
18033             var node = createNode(205);
18034             nextToken();
18035             node.expression = parseSimpleUnaryExpression();
18036             return finishNode(node);
18037         }
18038         function isAwaitExpression() {
18039             if (token() === 127) {
18040                 if (inAwaitContext()) {
18041                     return true;
18042                 }
18043                 return lookAhead(nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine);
18044             }
18045             return false;
18046         }
18047         function parseAwaitExpression() {
18048             var node = createNode(206);
18049             nextToken();
18050             node.expression = parseSimpleUnaryExpression();
18051             return finishNode(node);
18052         }
18053         function parseUnaryExpressionOrHigher() {
18054             if (isUpdateExpression()) {
18055                 var updateExpression = parseUpdateExpression();
18056                 return token() === 42 ?
18057                     parseBinaryExpressionRest(ts.getBinaryOperatorPrecedence(token()), updateExpression) :
18058                     updateExpression;
18059             }
18060             var unaryOperator = token();
18061             var simpleUnaryExpression = parseSimpleUnaryExpression();
18062             if (token() === 42) {
18063                 var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos);
18064                 var end = simpleUnaryExpression.end;
18065                 if (simpleUnaryExpression.kind === 199) {
18066                     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);
18067                 }
18068                 else {
18069                     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));
18070                 }
18071             }
18072             return simpleUnaryExpression;
18073         }
18074         function parseSimpleUnaryExpression() {
18075             switch (token()) {
18076                 case 39:
18077                 case 40:
18078                 case 54:
18079                 case 53:
18080                     return parsePrefixUnaryExpression();
18081                 case 85:
18082                     return parseDeleteExpression();
18083                 case 108:
18084                     return parseTypeOfExpression();
18085                 case 110:
18086                     return parseVoidExpression();
18087                 case 29:
18088                     return parseTypeAssertion();
18089                 case 127:
18090                     if (isAwaitExpression()) {
18091                         return parseAwaitExpression();
18092                     }
18093                 default:
18094                     return parseUpdateExpression();
18095             }
18096         }
18097         function isUpdateExpression() {
18098             switch (token()) {
18099                 case 39:
18100                 case 40:
18101                 case 54:
18102                 case 53:
18103                 case 85:
18104                 case 108:
18105                 case 110:
18106                 case 127:
18107                     return false;
18108                 case 29:
18109                     if (sourceFile.languageVariant !== 1) {
18110                         return false;
18111                     }
18112                 default:
18113                     return true;
18114             }
18115         }
18116         function parseUpdateExpression() {
18117             if (token() === 45 || token() === 46) {
18118                 var node = createNode(207);
18119                 node.operator = token();
18120                 nextToken();
18121                 node.operand = parseLeftHandSideExpressionOrHigher();
18122                 return finishNode(node);
18123             }
18124             else if (sourceFile.languageVariant === 1 && token() === 29 && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) {
18125                 return parseJsxElementOrSelfClosingElementOrFragment(true);
18126             }
18127             var expression = parseLeftHandSideExpressionOrHigher();
18128             ts.Debug.assert(ts.isLeftHandSideExpression(expression));
18129             if ((token() === 45 || token() === 46) && !scanner.hasPrecedingLineBreak()) {
18130                 var node = createNode(208, expression.pos);
18131                 node.operand = expression;
18132                 node.operator = token();
18133                 nextToken();
18134                 return finishNode(node);
18135             }
18136             return expression;
18137         }
18138         function parseLeftHandSideExpressionOrHigher() {
18139             var expression;
18140             if (token() === 96) {
18141                 if (lookAhead(nextTokenIsOpenParenOrLessThan)) {
18142                     sourceFile.flags |= 1048576;
18143                     expression = parseTokenNode();
18144                 }
18145                 else if (lookAhead(nextTokenIsDot)) {
18146                     var fullStart = scanner.getStartPos();
18147                     nextToken();
18148                     nextToken();
18149                     var node = createNode(219, fullStart);
18150                     node.keywordToken = 96;
18151                     node.name = parseIdentifierName();
18152                     expression = finishNode(node);
18153                     sourceFile.flags |= 2097152;
18154                 }
18155                 else {
18156                     expression = parseMemberExpressionOrHigher();
18157                 }
18158             }
18159             else {
18160                 expression = token() === 102 ? parseSuperExpression() : parseMemberExpressionOrHigher();
18161             }
18162             return parseCallExpressionRest(expression);
18163         }
18164         function parseMemberExpressionOrHigher() {
18165             var expression = parsePrimaryExpression();
18166             return parseMemberExpressionRest(expression, true);
18167         }
18168         function parseSuperExpression() {
18169             var expression = parseTokenNode();
18170             if (token() === 29) {
18171                 var startPos = getNodePos();
18172                 var typeArguments = tryParse(parseTypeArgumentsInExpression);
18173                 if (typeArguments !== undefined) {
18174                     parseErrorAt(startPos, getNodePos(), ts.Diagnostics.super_may_not_use_type_arguments);
18175                 }
18176             }
18177             if (token() === 20 || token() === 24 || token() === 22) {
18178                 return expression;
18179             }
18180             var node = createNode(194, expression.pos);
18181             node.expression = expression;
18182             parseExpectedToken(24, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access);
18183             node.name = parseRightSideOfDot(true, true);
18184             return finishNode(node);
18185         }
18186         function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) {
18187             var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext);
18188             var result;
18189             if (opening.kind === 268) {
18190                 var node = createNode(266, opening.pos);
18191                 node.openingElement = opening;
18192                 node.children = parseJsxChildren(node.openingElement);
18193                 node.closingElement = parseJsxClosingElement(inExpressionContext);
18194                 if (!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) {
18195                     parseErrorAtRange(node.closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNodeFromSourceText(sourceText, node.openingElement.tagName));
18196                 }
18197                 result = finishNode(node);
18198             }
18199             else if (opening.kind === 271) {
18200                 var node = createNode(270, opening.pos);
18201                 node.openingFragment = opening;
18202                 node.children = parseJsxChildren(node.openingFragment);
18203                 node.closingFragment = parseJsxClosingFragment(inExpressionContext);
18204                 result = finishNode(node);
18205             }
18206             else {
18207                 ts.Debug.assert(opening.kind === 267);
18208                 result = opening;
18209             }
18210             if (inExpressionContext && token() === 29) {
18211                 var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(true); });
18212                 if (invalidElement) {
18213                     parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element);
18214                     var badNode = createNode(209, result.pos);
18215                     badNode.end = invalidElement.end;
18216                     badNode.left = result;
18217                     badNode.right = invalidElement;
18218                     badNode.operatorToken = createMissingNode(27, false);
18219                     badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos;
18220                     return badNode;
18221                 }
18222             }
18223             return result;
18224         }
18225         function parseJsxText() {
18226             var node = createNode(11);
18227             node.text = scanner.getTokenValue();
18228             node.containsOnlyTriviaWhiteSpaces = currentToken === 12;
18229             currentToken = scanner.scanJsxToken();
18230             return finishNode(node);
18231         }
18232         function parseJsxChild(openingTag, token) {
18233             switch (token) {
18234                 case 1:
18235                     if (ts.isJsxOpeningFragment(openingTag)) {
18236                         parseErrorAtRange(openingTag, ts.Diagnostics.JSX_fragment_has_no_corresponding_closing_tag);
18237                     }
18238                     else {
18239                         var tag = openingTag.tagName;
18240                         var start = ts.skipTrivia(sourceText, tag.pos);
18241                         parseErrorAt(start, tag.end, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName));
18242                     }
18243                     return undefined;
18244                 case 30:
18245                 case 7:
18246                     return undefined;
18247                 case 11:
18248                 case 12:
18249                     return parseJsxText();
18250                 case 18:
18251                     return parseJsxExpression(false);
18252                 case 29:
18253                     return parseJsxElementOrSelfClosingElementOrFragment(false);
18254                 default:
18255                     return ts.Debug.assertNever(token);
18256             }
18257         }
18258         function parseJsxChildren(openingTag) {
18259             var list = [];
18260             var listPos = getNodePos();
18261             var saveParsingContext = parsingContext;
18262             parsingContext |= 1 << 14;
18263             while (true) {
18264                 var child = parseJsxChild(openingTag, currentToken = scanner.reScanJsxToken());
18265                 if (!child)
18266                     break;
18267                 list.push(child);
18268             }
18269             parsingContext = saveParsingContext;
18270             return createNodeArray(list, listPos);
18271         }
18272         function parseJsxAttributes() {
18273             var jsxAttributes = createNode(274);
18274             jsxAttributes.properties = parseList(13, parseJsxAttribute);
18275             return finishNode(jsxAttributes);
18276         }
18277         function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) {
18278             var fullStart = scanner.getStartPos();
18279             parseExpected(29);
18280             if (token() === 31) {
18281                 var node_1 = createNode(271, fullStart);
18282                 scanJsxText();
18283                 return finishNode(node_1);
18284             }
18285             var tagName = parseJsxElementName();
18286             var typeArguments = tryParseTypeArguments();
18287             var attributes = parseJsxAttributes();
18288             var node;
18289             if (token() === 31) {
18290                 node = createNode(268, fullStart);
18291                 scanJsxText();
18292             }
18293             else {
18294                 parseExpected(43);
18295                 if (inExpressionContext) {
18296                     parseExpected(31);
18297                 }
18298                 else {
18299                     parseExpected(31, undefined, false);
18300                     scanJsxText();
18301                 }
18302                 node = createNode(267, fullStart);
18303             }
18304             node.tagName = tagName;
18305             node.typeArguments = typeArguments;
18306             node.attributes = attributes;
18307             return finishNode(node);
18308         }
18309         function parseJsxElementName() {
18310             scanJsxIdentifier();
18311             var expression = token() === 104 ?
18312                 parseTokenNode() : parseIdentifierName();
18313             while (parseOptional(24)) {
18314                 var propertyAccess = createNode(194, expression.pos);
18315                 propertyAccess.expression = expression;
18316                 propertyAccess.name = parseRightSideOfDot(true, false);
18317                 expression = finishNode(propertyAccess);
18318             }
18319             return expression;
18320         }
18321         function parseJsxExpression(inExpressionContext) {
18322             var node = createNode(276);
18323             if (!parseExpected(18)) {
18324                 return undefined;
18325             }
18326             if (token() !== 19) {
18327                 node.dotDotDotToken = parseOptionalToken(25);
18328                 node.expression = parseExpression();
18329             }
18330             if (inExpressionContext) {
18331                 parseExpected(19);
18332             }
18333             else {
18334                 if (parseExpected(19, undefined, false)) {
18335                     scanJsxText();
18336                 }
18337             }
18338             return finishNode(node);
18339         }
18340         function parseJsxAttribute() {
18341             if (token() === 18) {
18342                 return parseJsxSpreadAttribute();
18343             }
18344             scanJsxIdentifier();
18345             var node = createNode(273);
18346             node.name = parseIdentifierName();
18347             if (token() === 62) {
18348                 switch (scanJsxAttributeValue()) {
18349                     case 10:
18350                         node.initializer = parseLiteralNode();
18351                         break;
18352                     default:
18353                         node.initializer = parseJsxExpression(true);
18354                         break;
18355                 }
18356             }
18357             return finishNode(node);
18358         }
18359         function parseJsxSpreadAttribute() {
18360             var node = createNode(275);
18361             parseExpected(18);
18362             parseExpected(25);
18363             node.expression = parseExpression();
18364             parseExpected(19);
18365             return finishNode(node);
18366         }
18367         function parseJsxClosingElement(inExpressionContext) {
18368             var node = createNode(269);
18369             parseExpected(30);
18370             node.tagName = parseJsxElementName();
18371             if (inExpressionContext) {
18372                 parseExpected(31);
18373             }
18374             else {
18375                 parseExpected(31, undefined, false);
18376                 scanJsxText();
18377             }
18378             return finishNode(node);
18379         }
18380         function parseJsxClosingFragment(inExpressionContext) {
18381             var node = createNode(272);
18382             parseExpected(30);
18383             if (ts.tokenIsIdentifierOrKeyword(token())) {
18384                 parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment);
18385             }
18386             if (inExpressionContext) {
18387                 parseExpected(31);
18388             }
18389             else {
18390                 parseExpected(31, undefined, false);
18391                 scanJsxText();
18392             }
18393             return finishNode(node);
18394         }
18395         function parseTypeAssertion() {
18396             var node = createNode(199);
18397             parseExpected(29);
18398             node.type = parseType();
18399             parseExpected(31);
18400             node.expression = parseSimpleUnaryExpression();
18401             return finishNode(node);
18402         }
18403         function nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate() {
18404             nextToken();
18405             return ts.tokenIsIdentifierOrKeyword(token())
18406                 || token() === 22
18407                 || isTemplateStartOfTaggedTemplate();
18408         }
18409         function isStartOfOptionalPropertyOrElementAccessChain() {
18410             return token() === 28
18411                 && lookAhead(nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate);
18412         }
18413         function tryReparseOptionalChain(node) {
18414             if (node.flags & 32) {
18415                 return true;
18416             }
18417             if (ts.isNonNullExpression(node)) {
18418                 var expr = node.expression;
18419                 while (ts.isNonNullExpression(expr) && !(expr.flags & 32)) {
18420                     expr = expr.expression;
18421                 }
18422                 if (expr.flags & 32) {
18423                     while (ts.isNonNullExpression(node)) {
18424                         node.flags |= 32;
18425                         node = node.expression;
18426                     }
18427                     return true;
18428                 }
18429             }
18430             return false;
18431         }
18432         function parsePropertyAccessExpressionRest(expression, questionDotToken) {
18433             var propertyAccess = createNode(194, expression.pos);
18434             propertyAccess.expression = expression;
18435             propertyAccess.questionDotToken = questionDotToken;
18436             propertyAccess.name = parseRightSideOfDot(true, true);
18437             if (questionDotToken || tryReparseOptionalChain(expression)) {
18438                 propertyAccess.flags |= 32;
18439                 if (ts.isPrivateIdentifier(propertyAccess.name)) {
18440                     parseErrorAtRange(propertyAccess.name, ts.Diagnostics.An_optional_chain_cannot_contain_private_identifiers);
18441                 }
18442             }
18443             return finishNode(propertyAccess);
18444         }
18445         function parseElementAccessExpressionRest(expression, questionDotToken) {
18446             var indexedAccess = createNode(195, expression.pos);
18447             indexedAccess.expression = expression;
18448             indexedAccess.questionDotToken = questionDotToken;
18449             if (token() === 23) {
18450                 indexedAccess.argumentExpression = createMissingNode(75, true, ts.Diagnostics.An_element_access_expression_should_take_an_argument);
18451             }
18452             else {
18453                 var argument = allowInAnd(parseExpression);
18454                 if (ts.isStringOrNumericLiteralLike(argument)) {
18455                     argument.text = internIdentifier(argument.text);
18456                 }
18457                 indexedAccess.argumentExpression = argument;
18458             }
18459             parseExpected(23);
18460             if (questionDotToken || tryReparseOptionalChain(expression)) {
18461                 indexedAccess.flags |= 32;
18462             }
18463             return finishNode(indexedAccess);
18464         }
18465         function parseMemberExpressionRest(expression, allowOptionalChain) {
18466             while (true) {
18467                 var questionDotToken = void 0;
18468                 var isPropertyAccess = false;
18469                 if (allowOptionalChain && isStartOfOptionalPropertyOrElementAccessChain()) {
18470                     questionDotToken = parseExpectedToken(28);
18471                     isPropertyAccess = ts.tokenIsIdentifierOrKeyword(token());
18472                 }
18473                 else {
18474                     isPropertyAccess = parseOptional(24);
18475                 }
18476                 if (isPropertyAccess) {
18477                     expression = parsePropertyAccessExpressionRest(expression, questionDotToken);
18478                     continue;
18479                 }
18480                 if (!questionDotToken && token() === 53 && !scanner.hasPrecedingLineBreak()) {
18481                     nextToken();
18482                     var nonNullExpression = createNode(218, expression.pos);
18483                     nonNullExpression.expression = expression;
18484                     expression = finishNode(nonNullExpression);
18485                     continue;
18486                 }
18487                 if ((questionDotToken || !inDecoratorContext()) && parseOptional(22)) {
18488                     expression = parseElementAccessExpressionRest(expression, questionDotToken);
18489                     continue;
18490                 }
18491                 if (isTemplateStartOfTaggedTemplate()) {
18492                     expression = parseTaggedTemplateRest(expression, questionDotToken, undefined);
18493                     continue;
18494                 }
18495                 return expression;
18496             }
18497         }
18498         function isTemplateStartOfTaggedTemplate() {
18499             return token() === 14 || token() === 15;
18500         }
18501         function parseTaggedTemplateRest(tag, questionDotToken, typeArguments) {
18502             var tagExpression = createNode(198, tag.pos);
18503             tagExpression.tag = tag;
18504             tagExpression.questionDotToken = questionDotToken;
18505             tagExpression.typeArguments = typeArguments;
18506             tagExpression.template = token() === 14
18507                 ? (reScanTemplateHeadOrNoSubstitutionTemplate(), parseLiteralNode())
18508                 : parseTemplateExpression(true);
18509             if (questionDotToken || tag.flags & 32) {
18510                 tagExpression.flags |= 32;
18511             }
18512             return finishNode(tagExpression);
18513         }
18514         function parseCallExpressionRest(expression) {
18515             while (true) {
18516                 expression = parseMemberExpressionRest(expression, true);
18517                 var questionDotToken = parseOptionalToken(28);
18518                 if (token() === 29 || token() === 47) {
18519                     var typeArguments = tryParse(parseTypeArgumentsInExpression);
18520                     if (typeArguments) {
18521                         if (isTemplateStartOfTaggedTemplate()) {
18522                             expression = parseTaggedTemplateRest(expression, questionDotToken, typeArguments);
18523                             continue;
18524                         }
18525                         var callExpr = createNode(196, expression.pos);
18526                         callExpr.expression = expression;
18527                         callExpr.questionDotToken = questionDotToken;
18528                         callExpr.typeArguments = typeArguments;
18529                         callExpr.arguments = parseArgumentList();
18530                         if (questionDotToken || tryReparseOptionalChain(expression)) {
18531                             callExpr.flags |= 32;
18532                         }
18533                         expression = finishNode(callExpr);
18534                         continue;
18535                     }
18536                 }
18537                 else if (token() === 20) {
18538                     var callExpr = createNode(196, expression.pos);
18539                     callExpr.expression = expression;
18540                     callExpr.questionDotToken = questionDotToken;
18541                     callExpr.arguments = parseArgumentList();
18542                     if (questionDotToken || tryReparseOptionalChain(expression)) {
18543                         callExpr.flags |= 32;
18544                     }
18545                     expression = finishNode(callExpr);
18546                     continue;
18547                 }
18548                 if (questionDotToken) {
18549                     var propertyAccess = createNode(194, expression.pos);
18550                     propertyAccess.expression = expression;
18551                     propertyAccess.questionDotToken = questionDotToken;
18552                     propertyAccess.name = createMissingNode(75, false, ts.Diagnostics.Identifier_expected);
18553                     propertyAccess.flags |= 32;
18554                     expression = finishNode(propertyAccess);
18555                 }
18556                 break;
18557             }
18558             return expression;
18559         }
18560         function parseArgumentList() {
18561             parseExpected(20);
18562             var result = parseDelimitedList(11, parseArgumentExpression);
18563             parseExpected(21);
18564             return result;
18565         }
18566         function parseTypeArgumentsInExpression() {
18567             if (reScanLessThanToken() !== 29) {
18568                 return undefined;
18569             }
18570             nextToken();
18571             var typeArguments = parseDelimitedList(20, parseType);
18572             if (!parseExpected(31)) {
18573                 return undefined;
18574             }
18575             return typeArguments && canFollowTypeArgumentsInExpression()
18576                 ? typeArguments
18577                 : undefined;
18578         }
18579         function canFollowTypeArgumentsInExpression() {
18580             switch (token()) {
18581                 case 20:
18582                 case 14:
18583                 case 15:
18584                 case 24:
18585                 case 21:
18586                 case 23:
18587                 case 58:
18588                 case 26:
18589                 case 57:
18590                 case 34:
18591                 case 36:
18592                 case 35:
18593                 case 37:
18594                 case 55:
18595                 case 56:
18596                 case 60:
18597                 case 52:
18598                 case 50:
18599                 case 51:
18600                 case 19:
18601                 case 1:
18602                     return true;
18603                 case 27:
18604                 case 18:
18605                 default:
18606                     return false;
18607             }
18608         }
18609         function parsePrimaryExpression() {
18610             switch (token()) {
18611                 case 8:
18612                 case 9:
18613                 case 10:
18614                 case 14:
18615                     return parseLiteralNode();
18616                 case 104:
18617                 case 102:
18618                 case 100:
18619                 case 106:
18620                 case 91:
18621                     return parseTokenNode();
18622                 case 20:
18623                     return parseParenthesizedExpression();
18624                 case 22:
18625                     return parseArrayLiteralExpression();
18626                 case 18:
18627                     return parseObjectLiteralExpression();
18628                 case 126:
18629                     if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) {
18630                         break;
18631                     }
18632                     return parseFunctionExpression();
18633                 case 80:
18634                     return parseClassExpression();
18635                 case 94:
18636                     return parseFunctionExpression();
18637                 case 99:
18638                     return parseNewExpressionOrNewDotTarget();
18639                 case 43:
18640                 case 67:
18641                     if (reScanSlashToken() === 13) {
18642                         return parseLiteralNode();
18643                     }
18644                     break;
18645                 case 15:
18646                     return parseTemplateExpression(false);
18647             }
18648             return parseIdentifier(ts.Diagnostics.Expression_expected);
18649         }
18650         function parseParenthesizedExpression() {
18651             var node = createNodeWithJSDoc(200);
18652             parseExpected(20);
18653             node.expression = allowInAnd(parseExpression);
18654             parseExpected(21);
18655             return finishNode(node);
18656         }
18657         function parseSpreadElement() {
18658             var node = createNode(213);
18659             parseExpected(25);
18660             node.expression = parseAssignmentExpressionOrHigher();
18661             return finishNode(node);
18662         }
18663         function parseArgumentOrArrayLiteralElement() {
18664             return token() === 25 ? parseSpreadElement() :
18665                 token() === 27 ? createNode(215) :
18666                     parseAssignmentExpressionOrHigher();
18667         }
18668         function parseArgumentExpression() {
18669             return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement);
18670         }
18671         function parseArrayLiteralExpression() {
18672             var node = createNode(192);
18673             parseExpected(22);
18674             if (scanner.hasPrecedingLineBreak()) {
18675                 node.multiLine = true;
18676             }
18677             node.elements = parseDelimitedList(15, parseArgumentOrArrayLiteralElement);
18678             parseExpected(23);
18679             return finishNode(node);
18680         }
18681         function parseObjectLiteralElement() {
18682             var node = createNodeWithJSDoc(0);
18683             if (parseOptionalToken(25)) {
18684                 node.kind = 283;
18685                 node.expression = parseAssignmentExpressionOrHigher();
18686                 return finishNode(node);
18687             }
18688             node.decorators = parseDecorators();
18689             node.modifiers = parseModifiers();
18690             if (parseContextualModifier(131)) {
18691                 return parseAccessorDeclaration(node, 163);
18692             }
18693             if (parseContextualModifier(142)) {
18694                 return parseAccessorDeclaration(node, 164);
18695             }
18696             var asteriskToken = parseOptionalToken(41);
18697             var tokenIsIdentifier = isIdentifier();
18698             node.name = parsePropertyName();
18699             node.questionToken = parseOptionalToken(57);
18700             node.exclamationToken = parseOptionalToken(53);
18701             if (asteriskToken || token() === 20 || token() === 29) {
18702                 return parseMethodDeclaration(node, asteriskToken);
18703             }
18704             var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58);
18705             if (isShorthandPropertyAssignment) {
18706                 node.kind = 282;
18707                 var equalsToken = parseOptionalToken(62);
18708                 if (equalsToken) {
18709                     node.equalsToken = equalsToken;
18710                     node.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher);
18711                 }
18712             }
18713             else {
18714                 node.kind = 281;
18715                 parseExpected(58);
18716                 node.initializer = allowInAnd(parseAssignmentExpressionOrHigher);
18717             }
18718             return finishNode(node);
18719         }
18720         function parseObjectLiteralExpression() {
18721             var node = createNode(193);
18722             var openBracePosition = scanner.getTokenPos();
18723             parseExpected(18);
18724             if (scanner.hasPrecedingLineBreak()) {
18725                 node.multiLine = true;
18726             }
18727             node.properties = parseDelimitedList(12, parseObjectLiteralElement, true);
18728             if (!parseExpected(19)) {
18729                 var lastError = ts.lastOrUndefined(parseDiagnostics);
18730                 if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
18731                     ts.addRelatedInfo(lastError, ts.createFileDiagnostic(sourceFile, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
18732                 }
18733             }
18734             return finishNode(node);
18735         }
18736         function parseFunctionExpression() {
18737             var saveDecoratorContext = inDecoratorContext();
18738             if (saveDecoratorContext) {
18739                 setDecoratorContext(false);
18740             }
18741             var node = createNodeWithJSDoc(201);
18742             node.modifiers = parseModifiers();
18743             parseExpected(94);
18744             node.asteriskToken = parseOptionalToken(41);
18745             var isGenerator = node.asteriskToken ? 1 : 0;
18746             var isAsync = hasModifierOfKind(node, 126) ? 2 : 0;
18747             node.name =
18748                 isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) :
18749                     isGenerator ? doInYieldContext(parseOptionalIdentifier) :
18750                         isAsync ? doInAwaitContext(parseOptionalIdentifier) :
18751                             parseOptionalIdentifier();
18752             fillSignature(58, isGenerator | isAsync, node);
18753             node.body = parseFunctionBlock(isGenerator | isAsync);
18754             if (saveDecoratorContext) {
18755                 setDecoratorContext(true);
18756             }
18757             return finishNode(node);
18758         }
18759         function parseOptionalIdentifier() {
18760             return isIdentifier() ? parseIdentifier() : undefined;
18761         }
18762         function parseNewExpressionOrNewDotTarget() {
18763             var fullStart = scanner.getStartPos();
18764             parseExpected(99);
18765             if (parseOptional(24)) {
18766                 var node_2 = createNode(219, fullStart);
18767                 node_2.keywordToken = 99;
18768                 node_2.name = parseIdentifierName();
18769                 return finishNode(node_2);
18770             }
18771             var expression = parsePrimaryExpression();
18772             var typeArguments;
18773             while (true) {
18774                 expression = parseMemberExpressionRest(expression, false);
18775                 typeArguments = tryParse(parseTypeArgumentsInExpression);
18776                 if (isTemplateStartOfTaggedTemplate()) {
18777                     ts.Debug.assert(!!typeArguments, "Expected a type argument list; all plain tagged template starts should be consumed in 'parseMemberExpressionRest'");
18778                     expression = parseTaggedTemplateRest(expression, undefined, typeArguments);
18779                     typeArguments = undefined;
18780                 }
18781                 break;
18782             }
18783             var node = createNode(197, fullStart);
18784             node.expression = expression;
18785             node.typeArguments = typeArguments;
18786             if (token() === 20) {
18787                 node.arguments = parseArgumentList();
18788             }
18789             else if (node.typeArguments) {
18790                 parseErrorAt(fullStart, scanner.getStartPos(), ts.Diagnostics.A_new_expression_with_type_arguments_must_always_be_followed_by_a_parenthesized_argument_list);
18791             }
18792             return finishNode(node);
18793         }
18794         function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) {
18795             var node = createNode(223);
18796             var openBracePosition = scanner.getTokenPos();
18797             if (parseExpected(18, diagnosticMessage) || ignoreMissingOpenBrace) {
18798                 if (scanner.hasPrecedingLineBreak()) {
18799                     node.multiLine = true;
18800                 }
18801                 node.statements = parseList(1, parseStatement);
18802                 if (!parseExpected(19)) {
18803                     var lastError = ts.lastOrUndefined(parseDiagnostics);
18804                     if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
18805                         ts.addRelatedInfo(lastError, ts.createFileDiagnostic(sourceFile, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
18806                     }
18807                 }
18808             }
18809             else {
18810                 node.statements = createMissingList();
18811             }
18812             return finishNode(node);
18813         }
18814         function parseFunctionBlock(flags, diagnosticMessage) {
18815             var savedYieldContext = inYieldContext();
18816             setYieldContext(!!(flags & 1));
18817             var savedAwaitContext = inAwaitContext();
18818             setAwaitContext(!!(flags & 2));
18819             var saveDecoratorContext = inDecoratorContext();
18820             if (saveDecoratorContext) {
18821                 setDecoratorContext(false);
18822             }
18823             var block = parseBlock(!!(flags & 16), diagnosticMessage);
18824             if (saveDecoratorContext) {
18825                 setDecoratorContext(true);
18826             }
18827             setYieldContext(savedYieldContext);
18828             setAwaitContext(savedAwaitContext);
18829             return block;
18830         }
18831         function parseEmptyStatement() {
18832             var node = createNode(224);
18833             parseExpected(26);
18834             return finishNode(node);
18835         }
18836         function parseIfStatement() {
18837             var node = createNode(227);
18838             parseExpected(95);
18839             parseExpected(20);
18840             node.expression = allowInAnd(parseExpression);
18841             parseExpected(21);
18842             node.thenStatement = parseStatement();
18843             node.elseStatement = parseOptional(87) ? parseStatement() : undefined;
18844             return finishNode(node);
18845         }
18846         function parseDoStatement() {
18847             var node = createNode(228);
18848             parseExpected(86);
18849             node.statement = parseStatement();
18850             parseExpected(111);
18851             parseExpected(20);
18852             node.expression = allowInAnd(parseExpression);
18853             parseExpected(21);
18854             parseOptional(26);
18855             return finishNode(node);
18856         }
18857         function parseWhileStatement() {
18858             var node = createNode(229);
18859             parseExpected(111);
18860             parseExpected(20);
18861             node.expression = allowInAnd(parseExpression);
18862             parseExpected(21);
18863             node.statement = parseStatement();
18864             return finishNode(node);
18865         }
18866         function parseForOrForInOrForOfStatement() {
18867             var pos = getNodePos();
18868             parseExpected(93);
18869             var awaitToken = parseOptionalToken(127);
18870             parseExpected(20);
18871             var initializer;
18872             if (token() !== 26) {
18873                 if (token() === 109 || token() === 115 || token() === 81) {
18874                     initializer = parseVariableDeclarationList(true);
18875                 }
18876                 else {
18877                     initializer = disallowInAnd(parseExpression);
18878                 }
18879             }
18880             var forOrForInOrForOfStatement;
18881             if (awaitToken ? parseExpected(152) : parseOptional(152)) {
18882                 var forOfStatement = createNode(232, pos);
18883                 forOfStatement.awaitModifier = awaitToken;
18884                 forOfStatement.initializer = initializer;
18885                 forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher);
18886                 parseExpected(21);
18887                 forOrForInOrForOfStatement = forOfStatement;
18888             }
18889             else if (parseOptional(97)) {
18890                 var forInStatement = createNode(231, pos);
18891                 forInStatement.initializer = initializer;
18892                 forInStatement.expression = allowInAnd(parseExpression);
18893                 parseExpected(21);
18894                 forOrForInOrForOfStatement = forInStatement;
18895             }
18896             else {
18897                 var forStatement = createNode(230, pos);
18898                 forStatement.initializer = initializer;
18899                 parseExpected(26);
18900                 if (token() !== 26 && token() !== 21) {
18901                     forStatement.condition = allowInAnd(parseExpression);
18902                 }
18903                 parseExpected(26);
18904                 if (token() !== 21) {
18905                     forStatement.incrementor = allowInAnd(parseExpression);
18906                 }
18907                 parseExpected(21);
18908                 forOrForInOrForOfStatement = forStatement;
18909             }
18910             forOrForInOrForOfStatement.statement = parseStatement();
18911             return finishNode(forOrForInOrForOfStatement);
18912         }
18913         function parseBreakOrContinueStatement(kind) {
18914             var node = createNode(kind);
18915             parseExpected(kind === 234 ? 77 : 82);
18916             if (!canParseSemicolon()) {
18917                 node.label = parseIdentifier();
18918             }
18919             parseSemicolon();
18920             return finishNode(node);
18921         }
18922         function parseReturnStatement() {
18923             var node = createNode(235);
18924             parseExpected(101);
18925             if (!canParseSemicolon()) {
18926                 node.expression = allowInAnd(parseExpression);
18927             }
18928             parseSemicolon();
18929             return finishNode(node);
18930         }
18931         function parseWithStatement() {
18932             var node = createNode(236);
18933             parseExpected(112);
18934             parseExpected(20);
18935             node.expression = allowInAnd(parseExpression);
18936             parseExpected(21);
18937             node.statement = doInsideOfContext(16777216, parseStatement);
18938             return finishNode(node);
18939         }
18940         function parseCaseClause() {
18941             var node = createNode(277);
18942             parseExpected(78);
18943             node.expression = allowInAnd(parseExpression);
18944             parseExpected(58);
18945             node.statements = parseList(3, parseStatement);
18946             return finishNode(node);
18947         }
18948         function parseDefaultClause() {
18949             var node = createNode(278);
18950             parseExpected(84);
18951             parseExpected(58);
18952             node.statements = parseList(3, parseStatement);
18953             return finishNode(node);
18954         }
18955         function parseCaseOrDefaultClause() {
18956             return token() === 78 ? parseCaseClause() : parseDefaultClause();
18957         }
18958         function parseSwitchStatement() {
18959             var node = createNode(237);
18960             parseExpected(103);
18961             parseExpected(20);
18962             node.expression = allowInAnd(parseExpression);
18963             parseExpected(21);
18964             var caseBlock = createNode(251);
18965             parseExpected(18);
18966             caseBlock.clauses = parseList(2, parseCaseOrDefaultClause);
18967             parseExpected(19);
18968             node.caseBlock = finishNode(caseBlock);
18969             return finishNode(node);
18970         }
18971         function parseThrowStatement() {
18972             var node = createNode(239);
18973             parseExpected(105);
18974             node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression);
18975             parseSemicolon();
18976             return finishNode(node);
18977         }
18978         function parseTryStatement() {
18979             var node = createNode(240);
18980             parseExpected(107);
18981             node.tryBlock = parseBlock(false);
18982             node.catchClause = token() === 79 ? parseCatchClause() : undefined;
18983             if (!node.catchClause || token() === 92) {
18984                 parseExpected(92);
18985                 node.finallyBlock = parseBlock(false);
18986             }
18987             return finishNode(node);
18988         }
18989         function parseCatchClause() {
18990             var result = createNode(280);
18991             parseExpected(79);
18992             if (parseOptional(20)) {
18993                 result.variableDeclaration = parseVariableDeclaration();
18994                 parseExpected(21);
18995             }
18996             else {
18997                 result.variableDeclaration = undefined;
18998             }
18999             result.block = parseBlock(false);
19000             return finishNode(result);
19001         }
19002         function parseDebuggerStatement() {
19003             var node = createNode(241);
19004             parseExpected(83);
19005             parseSemicolon();
19006             return finishNode(node);
19007         }
19008         function parseExpressionOrLabeledStatement() {
19009             var node = createNodeWithJSDoc(token() === 75 ? 0 : 226);
19010             var expression = allowInAnd(parseExpression);
19011             if (expression.kind === 75 && parseOptional(58)) {
19012                 node.kind = 238;
19013                 node.label = expression;
19014                 node.statement = parseStatement();
19015             }
19016             else {
19017                 node.kind = 226;
19018                 node.expression = expression;
19019                 parseSemicolon();
19020             }
19021             return finishNode(node);
19022         }
19023         function nextTokenIsIdentifierOrKeywordOnSameLine() {
19024             nextToken();
19025             return ts.tokenIsIdentifierOrKeyword(token()) && !scanner.hasPrecedingLineBreak();
19026         }
19027         function nextTokenIsClassKeywordOnSameLine() {
19028             nextToken();
19029             return token() === 80 && !scanner.hasPrecedingLineBreak();
19030         }
19031         function nextTokenIsFunctionKeywordOnSameLine() {
19032             nextToken();
19033             return token() === 94 && !scanner.hasPrecedingLineBreak();
19034         }
19035         function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() {
19036             nextToken();
19037             return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 || token() === 9 || token() === 10) && !scanner.hasPrecedingLineBreak();
19038         }
19039         function isDeclaration() {
19040             while (true) {
19041                 switch (token()) {
19042                     case 109:
19043                     case 115:
19044                     case 81:
19045                     case 94:
19046                     case 80:
19047                     case 88:
19048                         return true;
19049                     case 114:
19050                     case 145:
19051                         return nextTokenIsIdentifierOnSameLine();
19052                     case 135:
19053                     case 136:
19054                         return nextTokenIsIdentifierOrStringLiteralOnSameLine();
19055                     case 122:
19056                     case 126:
19057                     case 130:
19058                     case 117:
19059                     case 118:
19060                     case 119:
19061                     case 138:
19062                         nextToken();
19063                         if (scanner.hasPrecedingLineBreak()) {
19064                             return false;
19065                         }
19066                         continue;
19067                     case 150:
19068                         nextToken();
19069                         return token() === 18 || token() === 75 || token() === 89;
19070                     case 96:
19071                         nextToken();
19072                         return token() === 10 || token() === 41 ||
19073                             token() === 18 || ts.tokenIsIdentifierOrKeyword(token());
19074                     case 89:
19075                         var currentToken_1 = nextToken();
19076                         if (currentToken_1 === 145) {
19077                             currentToken_1 = lookAhead(nextToken);
19078                         }
19079                         if (currentToken_1 === 62 || currentToken_1 === 41 ||
19080                             currentToken_1 === 18 || currentToken_1 === 84 ||
19081                             currentToken_1 === 123) {
19082                             return true;
19083                         }
19084                         continue;
19085                     case 120:
19086                         nextToken();
19087                         continue;
19088                     default:
19089                         return false;
19090                 }
19091             }
19092         }
19093         function isStartOfDeclaration() {
19094             return lookAhead(isDeclaration);
19095         }
19096         function isStartOfStatement() {
19097             switch (token()) {
19098                 case 59:
19099                 case 26:
19100                 case 18:
19101                 case 109:
19102                 case 115:
19103                 case 94:
19104                 case 80:
19105                 case 88:
19106                 case 95:
19107                 case 86:
19108                 case 111:
19109                 case 93:
19110                 case 82:
19111                 case 77:
19112                 case 101:
19113                 case 112:
19114                 case 103:
19115                 case 105:
19116                 case 107:
19117                 case 83:
19118                 case 79:
19119                 case 92:
19120                     return true;
19121                 case 96:
19122                     return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot);
19123                 case 81:
19124                 case 89:
19125                     return isStartOfDeclaration();
19126                 case 126:
19127                 case 130:
19128                 case 114:
19129                 case 135:
19130                 case 136:
19131                 case 145:
19132                 case 150:
19133                     return true;
19134                 case 119:
19135                 case 117:
19136                 case 118:
19137                 case 120:
19138                 case 138:
19139                     return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine);
19140                 default:
19141                     return isStartOfExpression();
19142             }
19143         }
19144         function nextTokenIsIdentifierOrStartOfDestructuring() {
19145             nextToken();
19146             return isIdentifier() || token() === 18 || token() === 22;
19147         }
19148         function isLetDeclaration() {
19149             return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring);
19150         }
19151         function parseStatement() {
19152             switch (token()) {
19153                 case 26:
19154                     return parseEmptyStatement();
19155                 case 18:
19156                     return parseBlock(false);
19157                 case 109:
19158                     return parseVariableStatement(createNodeWithJSDoc(242));
19159                 case 115:
19160                     if (isLetDeclaration()) {
19161                         return parseVariableStatement(createNodeWithJSDoc(242));
19162                     }
19163                     break;
19164                 case 94:
19165                     return parseFunctionDeclaration(createNodeWithJSDoc(244));
19166                 case 80:
19167                     return parseClassDeclaration(createNodeWithJSDoc(245));
19168                 case 95:
19169                     return parseIfStatement();
19170                 case 86:
19171                     return parseDoStatement();
19172                 case 111:
19173                     return parseWhileStatement();
19174                 case 93:
19175                     return parseForOrForInOrForOfStatement();
19176                 case 82:
19177                     return parseBreakOrContinueStatement(233);
19178                 case 77:
19179                     return parseBreakOrContinueStatement(234);
19180                 case 101:
19181                     return parseReturnStatement();
19182                 case 112:
19183                     return parseWithStatement();
19184                 case 103:
19185                     return parseSwitchStatement();
19186                 case 105:
19187                     return parseThrowStatement();
19188                 case 107:
19189                 case 79:
19190                 case 92:
19191                     return parseTryStatement();
19192                 case 83:
19193                     return parseDebuggerStatement();
19194                 case 59:
19195                     return parseDeclaration();
19196                 case 126:
19197                 case 114:
19198                 case 145:
19199                 case 135:
19200                 case 136:
19201                 case 130:
19202                 case 81:
19203                 case 88:
19204                 case 89:
19205                 case 96:
19206                 case 117:
19207                 case 118:
19208                 case 119:
19209                 case 122:
19210                 case 120:
19211                 case 138:
19212                 case 150:
19213                     if (isStartOfDeclaration()) {
19214                         return parseDeclaration();
19215                     }
19216                     break;
19217             }
19218             return parseExpressionOrLabeledStatement();
19219         }
19220         function isDeclareModifier(modifier) {
19221             return modifier.kind === 130;
19222         }
19223         function parseDeclaration() {
19224             var modifiers = lookAhead(function () { return (parseDecorators(), parseModifiers()); });
19225             var isAmbient = ts.some(modifiers, isDeclareModifier);
19226             if (isAmbient) {
19227                 var node_3 = tryReuseAmbientDeclaration();
19228                 if (node_3) {
19229                     return node_3;
19230                 }
19231             }
19232             var node = createNodeWithJSDoc(0);
19233             node.decorators = parseDecorators();
19234             node.modifiers = parseModifiers();
19235             if (isAmbient) {
19236                 for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) {
19237                     var m = _a[_i];
19238                     m.flags |= 8388608;
19239                 }
19240                 return doInsideOfContext(8388608, function () { return parseDeclarationWorker(node); });
19241             }
19242             else {
19243                 return parseDeclarationWorker(node);
19244             }
19245         }
19246         function tryReuseAmbientDeclaration() {
19247             return doInsideOfContext(8388608, function () {
19248                 var node = currentNode(parsingContext);
19249                 if (node) {
19250                     return consumeNode(node);
19251                 }
19252             });
19253         }
19254         function parseDeclarationWorker(node) {
19255             switch (token()) {
19256                 case 109:
19257                 case 115:
19258                 case 81:
19259                     return parseVariableStatement(node);
19260                 case 94:
19261                     return parseFunctionDeclaration(node);
19262                 case 80:
19263                     return parseClassDeclaration(node);
19264                 case 114:
19265                     return parseInterfaceDeclaration(node);
19266                 case 145:
19267                     return parseTypeAliasDeclaration(node);
19268                 case 88:
19269                     return parseEnumDeclaration(node);
19270                 case 150:
19271                 case 135:
19272                 case 136:
19273                     return parseModuleDeclaration(node);
19274                 case 96:
19275                     return parseImportDeclarationOrImportEqualsDeclaration(node);
19276                 case 89:
19277                     nextToken();
19278                     switch (token()) {
19279                         case 84:
19280                         case 62:
19281                             return parseExportAssignment(node);
19282                         case 123:
19283                             return parseNamespaceExportDeclaration(node);
19284                         default:
19285                             return parseExportDeclaration(node);
19286                     }
19287                 default:
19288                     if (node.decorators || node.modifiers) {
19289                         var missing = createMissingNode(264, true, ts.Diagnostics.Declaration_expected);
19290                         missing.pos = node.pos;
19291                         missing.decorators = node.decorators;
19292                         missing.modifiers = node.modifiers;
19293                         return finishNode(missing);
19294                     }
19295                     return undefined;
19296             }
19297         }
19298         function nextTokenIsIdentifierOrStringLiteralOnSameLine() {
19299             nextToken();
19300             return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10);
19301         }
19302         function parseFunctionBlockOrSemicolon(flags, diagnosticMessage) {
19303             if (token() !== 18 && canParseSemicolon()) {
19304                 parseSemicolon();
19305                 return;
19306             }
19307             return parseFunctionBlock(flags, diagnosticMessage);
19308         }
19309         function parseArrayBindingElement() {
19310             if (token() === 27) {
19311                 return createNode(215);
19312             }
19313             var node = createNode(191);
19314             node.dotDotDotToken = parseOptionalToken(25);
19315             node.name = parseIdentifierOrPattern();
19316             node.initializer = parseInitializer();
19317             return finishNode(node);
19318         }
19319         function parseObjectBindingElement() {
19320             var node = createNode(191);
19321             node.dotDotDotToken = parseOptionalToken(25);
19322             var tokenIsIdentifier = isIdentifier();
19323             var propertyName = parsePropertyName();
19324             if (tokenIsIdentifier && token() !== 58) {
19325                 node.name = propertyName;
19326             }
19327             else {
19328                 parseExpected(58);
19329                 node.propertyName = propertyName;
19330                 node.name = parseIdentifierOrPattern();
19331             }
19332             node.initializer = parseInitializer();
19333             return finishNode(node);
19334         }
19335         function parseObjectBindingPattern() {
19336             var node = createNode(189);
19337             parseExpected(18);
19338             node.elements = parseDelimitedList(9, parseObjectBindingElement);
19339             parseExpected(19);
19340             return finishNode(node);
19341         }
19342         function parseArrayBindingPattern() {
19343             var node = createNode(190);
19344             parseExpected(22);
19345             node.elements = parseDelimitedList(10, parseArrayBindingElement);
19346             parseExpected(23);
19347             return finishNode(node);
19348         }
19349         function isIdentifierOrPrivateIdentifierOrPattern() {
19350             return token() === 18
19351                 || token() === 22
19352                 || token() === 76
19353                 || isIdentifier();
19354         }
19355         function parseIdentifierOrPattern(privateIdentifierDiagnosticMessage) {
19356             if (token() === 22) {
19357                 return parseArrayBindingPattern();
19358             }
19359             if (token() === 18) {
19360                 return parseObjectBindingPattern();
19361             }
19362             return parseIdentifier(undefined, privateIdentifierDiagnosticMessage);
19363         }
19364         function parseVariableDeclarationAllowExclamation() {
19365             return parseVariableDeclaration(true);
19366         }
19367         function parseVariableDeclaration(allowExclamation) {
19368             var node = createNode(242);
19369             node.name = parseIdentifierOrPattern(ts.Diagnostics.Private_identifiers_are_not_allowed_in_variable_declarations);
19370             if (allowExclamation && node.name.kind === 75 &&
19371                 token() === 53 && !scanner.hasPrecedingLineBreak()) {
19372                 node.exclamationToken = parseTokenNode();
19373             }
19374             node.type = parseTypeAnnotation();
19375             if (!isInOrOfKeyword(token())) {
19376                 node.initializer = parseInitializer();
19377             }
19378             return finishNode(node);
19379         }
19380         function parseVariableDeclarationList(inForStatementInitializer) {
19381             var node = createNode(243);
19382             switch (token()) {
19383                 case 109:
19384                     break;
19385                 case 115:
19386                     node.flags |= 1;
19387                     break;
19388                 case 81:
19389                     node.flags |= 2;
19390                     break;
19391                 default:
19392                     ts.Debug.fail();
19393             }
19394             nextToken();
19395             if (token() === 152 && lookAhead(canFollowContextualOfKeyword)) {
19396                 node.declarations = createMissingList();
19397             }
19398             else {
19399                 var savedDisallowIn = inDisallowInContext();
19400                 setDisallowInContext(inForStatementInitializer);
19401                 node.declarations = parseDelimitedList(8, inForStatementInitializer ? parseVariableDeclaration : parseVariableDeclarationAllowExclamation);
19402                 setDisallowInContext(savedDisallowIn);
19403             }
19404             return finishNode(node);
19405         }
19406         function canFollowContextualOfKeyword() {
19407             return nextTokenIsIdentifier() && nextToken() === 21;
19408         }
19409         function parseVariableStatement(node) {
19410             node.kind = 225;
19411             node.declarationList = parseVariableDeclarationList(false);
19412             parseSemicolon();
19413             return finishNode(node);
19414         }
19415         function parseFunctionDeclaration(node) {
19416             node.kind = 244;
19417             parseExpected(94);
19418             node.asteriskToken = parseOptionalToken(41);
19419             node.name = hasModifierOfKind(node, 84) ? parseOptionalIdentifier() : parseIdentifier();
19420             var isGenerator = node.asteriskToken ? 1 : 0;
19421             var isAsync = hasModifierOfKind(node, 126) ? 2 : 0;
19422             fillSignature(58, isGenerator | isAsync, node);
19423             node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected);
19424             return finishNode(node);
19425         }
19426         function parseConstructorName() {
19427             if (token() === 129) {
19428                 return parseExpected(129);
19429             }
19430             if (token() === 10 && lookAhead(nextToken) === 20) {
19431                 return tryParse(function () {
19432                     var literalNode = parseLiteralNode();
19433                     return literalNode.text === "constructor" ? literalNode : undefined;
19434                 });
19435             }
19436         }
19437         function tryParseConstructorDeclaration(node) {
19438             return tryParse(function () {
19439                 if (parseConstructorName()) {
19440                     node.kind = 162;
19441                     fillSignature(58, 0, node);
19442                     node.body = parseFunctionBlockOrSemicolon(0, ts.Diagnostics.or_expected);
19443                     return finishNode(node);
19444                 }
19445             });
19446         }
19447         function parseMethodDeclaration(node, asteriskToken, diagnosticMessage) {
19448             node.kind = 161;
19449             node.asteriskToken = asteriskToken;
19450             var isGenerator = asteriskToken ? 1 : 0;
19451             var isAsync = hasModifierOfKind(node, 126) ? 2 : 0;
19452             fillSignature(58, isGenerator | isAsync, node);
19453             node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage);
19454             return finishNode(node);
19455         }
19456         function parsePropertyDeclaration(node) {
19457             node.kind = 159;
19458             if (!node.questionToken && token() === 53 && !scanner.hasPrecedingLineBreak()) {
19459                 node.exclamationToken = parseTokenNode();
19460             }
19461             node.type = parseTypeAnnotation();
19462             node.initializer = doOutsideOfContext(8192 | 32768 | 4096, parseInitializer);
19463             parseSemicolon();
19464             return finishNode(node);
19465         }
19466         function parsePropertyOrMethodDeclaration(node) {
19467             var asteriskToken = parseOptionalToken(41);
19468             node.name = parsePropertyName();
19469             node.questionToken = parseOptionalToken(57);
19470             if (asteriskToken || token() === 20 || token() === 29) {
19471                 return parseMethodDeclaration(node, asteriskToken, ts.Diagnostics.or_expected);
19472             }
19473             return parsePropertyDeclaration(node);
19474         }
19475         function parseAccessorDeclaration(node, kind) {
19476             node.kind = kind;
19477             node.name = parsePropertyName();
19478             fillSignature(58, 0, node);
19479             node.body = parseFunctionBlockOrSemicolon(0);
19480             return finishNode(node);
19481         }
19482         function isClassMemberStart() {
19483             var idToken;
19484             if (token() === 59) {
19485                 return true;
19486             }
19487             while (ts.isModifierKind(token())) {
19488                 idToken = token();
19489                 if (ts.isClassMemberModifier(idToken)) {
19490                     return true;
19491                 }
19492                 nextToken();
19493             }
19494             if (token() === 41) {
19495                 return true;
19496             }
19497             if (isLiteralPropertyName()) {
19498                 idToken = token();
19499                 nextToken();
19500             }
19501             if (token() === 22) {
19502                 return true;
19503             }
19504             if (idToken !== undefined) {
19505                 if (!ts.isKeyword(idToken) || idToken === 142 || idToken === 131) {
19506                     return true;
19507                 }
19508                 switch (token()) {
19509                     case 20:
19510                     case 29:
19511                     case 53:
19512                     case 58:
19513                     case 62:
19514                     case 57:
19515                         return true;
19516                     default:
19517                         return canParseSemicolon();
19518                 }
19519             }
19520             return false;
19521         }
19522         function parseDecorators() {
19523             var list;
19524             var listPos = getNodePos();
19525             while (true) {
19526                 var decoratorStart = getNodePos();
19527                 if (!parseOptional(59)) {
19528                     break;
19529                 }
19530                 var decorator = createNode(157, decoratorStart);
19531                 decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher);
19532                 finishNode(decorator);
19533                 (list || (list = [])).push(decorator);
19534             }
19535             return list && createNodeArray(list, listPos);
19536         }
19537         function parseModifiers(permitInvalidConstAsModifier) {
19538             var list;
19539             var listPos = getNodePos();
19540             while (true) {
19541                 var modifierStart = scanner.getStartPos();
19542                 var modifierKind = token();
19543                 if (token() === 81 && permitInvalidConstAsModifier) {
19544                     if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) {
19545                         break;
19546                     }
19547                 }
19548                 else {
19549                     if (!parseAnyContextualModifier()) {
19550                         break;
19551                     }
19552                 }
19553                 var modifier = finishNode(createNode(modifierKind, modifierStart));
19554                 (list || (list = [])).push(modifier);
19555             }
19556             return list && createNodeArray(list, listPos);
19557         }
19558         function parseModifiersForArrowFunction() {
19559             var modifiers;
19560             if (token() === 126) {
19561                 var modifierStart = scanner.getStartPos();
19562                 var modifierKind = token();
19563                 nextToken();
19564                 var modifier = finishNode(createNode(modifierKind, modifierStart));
19565                 modifiers = createNodeArray([modifier], modifierStart);
19566             }
19567             return modifiers;
19568         }
19569         function parseClassElement() {
19570             if (token() === 26) {
19571                 var result = createNode(222);
19572                 nextToken();
19573                 return finishNode(result);
19574             }
19575             var node = createNodeWithJSDoc(0);
19576             node.decorators = parseDecorators();
19577             node.modifiers = parseModifiers(true);
19578             if (parseContextualModifier(131)) {
19579                 return parseAccessorDeclaration(node, 163);
19580             }
19581             if (parseContextualModifier(142)) {
19582                 return parseAccessorDeclaration(node, 164);
19583             }
19584             if (token() === 129 || token() === 10) {
19585                 var constructorDeclaration = tryParseConstructorDeclaration(node);
19586                 if (constructorDeclaration) {
19587                     return constructorDeclaration;
19588                 }
19589             }
19590             if (isIndexSignature()) {
19591                 return parseIndexSignatureDeclaration(node);
19592             }
19593             if (ts.tokenIsIdentifierOrKeyword(token()) ||
19594                 token() === 10 ||
19595                 token() === 8 ||
19596                 token() === 41 ||
19597                 token() === 22) {
19598                 var isAmbient = node.modifiers && ts.some(node.modifiers, isDeclareModifier);
19599                 if (isAmbient) {
19600                     for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) {
19601                         var m = _a[_i];
19602                         m.flags |= 8388608;
19603                     }
19604                     return doInsideOfContext(8388608, function () { return parsePropertyOrMethodDeclaration(node); });
19605                 }
19606                 else {
19607                     return parsePropertyOrMethodDeclaration(node);
19608                 }
19609             }
19610             if (node.decorators || node.modifiers) {
19611                 node.name = createMissingNode(75, true, ts.Diagnostics.Declaration_expected);
19612                 return parsePropertyDeclaration(node);
19613             }
19614             return ts.Debug.fail("Should not have attempted to parse class member declaration.");
19615         }
19616         function parseClassExpression() {
19617             return parseClassDeclarationOrExpression(createNodeWithJSDoc(0), 214);
19618         }
19619         function parseClassDeclaration(node) {
19620             return parseClassDeclarationOrExpression(node, 245);
19621         }
19622         function parseClassDeclarationOrExpression(node, kind) {
19623             node.kind = kind;
19624             parseExpected(80);
19625             node.name = parseNameOfClassDeclarationOrExpression();
19626             node.typeParameters = parseTypeParameters();
19627             node.heritageClauses = parseHeritageClauses();
19628             if (parseExpected(18)) {
19629                 node.members = parseClassMembers();
19630                 parseExpected(19);
19631             }
19632             else {
19633                 node.members = createMissingList();
19634             }
19635             return finishNode(node);
19636         }
19637         function parseNameOfClassDeclarationOrExpression() {
19638             return isIdentifier() && !isImplementsClause()
19639                 ? parseIdentifier()
19640                 : undefined;
19641         }
19642         function isImplementsClause() {
19643             return token() === 113 && lookAhead(nextTokenIsIdentifierOrKeyword);
19644         }
19645         function parseHeritageClauses() {
19646             if (isHeritageClause()) {
19647                 return parseList(22, parseHeritageClause);
19648             }
19649             return undefined;
19650         }
19651         function parseHeritageClause() {
19652             var tok = token();
19653             ts.Debug.assert(tok === 90 || tok === 113);
19654             var node = createNode(279);
19655             node.token = tok;
19656             nextToken();
19657             node.types = parseDelimitedList(7, parseExpressionWithTypeArguments);
19658             return finishNode(node);
19659         }
19660         function parseExpressionWithTypeArguments() {
19661             var node = createNode(216);
19662             node.expression = parseLeftHandSideExpressionOrHigher();
19663             node.typeArguments = tryParseTypeArguments();
19664             return finishNode(node);
19665         }
19666         function tryParseTypeArguments() {
19667             return token() === 29 ?
19668                 parseBracketedList(20, parseType, 29, 31) : undefined;
19669         }
19670         function isHeritageClause() {
19671             return token() === 90 || token() === 113;
19672         }
19673         function parseClassMembers() {
19674             return parseList(5, parseClassElement);
19675         }
19676         function parseInterfaceDeclaration(node) {
19677             node.kind = 246;
19678             parseExpected(114);
19679             node.name = parseIdentifier();
19680             node.typeParameters = parseTypeParameters();
19681             node.heritageClauses = parseHeritageClauses();
19682             node.members = parseObjectTypeMembers();
19683             return finishNode(node);
19684         }
19685         function parseTypeAliasDeclaration(node) {
19686             node.kind = 247;
19687             parseExpected(145);
19688             node.name = parseIdentifier();
19689             node.typeParameters = parseTypeParameters();
19690             parseExpected(62);
19691             node.type = parseType();
19692             parseSemicolon();
19693             return finishNode(node);
19694         }
19695         function parseEnumMember() {
19696             var node = createNodeWithJSDoc(284);
19697             node.name = parsePropertyName();
19698             node.initializer = allowInAnd(parseInitializer);
19699             return finishNode(node);
19700         }
19701         function parseEnumDeclaration(node) {
19702             node.kind = 248;
19703             parseExpected(88);
19704             node.name = parseIdentifier();
19705             if (parseExpected(18)) {
19706                 node.members = doOutsideOfYieldAndAwaitContext(function () { return parseDelimitedList(6, parseEnumMember); });
19707                 parseExpected(19);
19708             }
19709             else {
19710                 node.members = createMissingList();
19711             }
19712             return finishNode(node);
19713         }
19714         function parseModuleBlock() {
19715             var node = createNode(250);
19716             if (parseExpected(18)) {
19717                 node.statements = parseList(1, parseStatement);
19718                 parseExpected(19);
19719             }
19720             else {
19721                 node.statements = createMissingList();
19722             }
19723             return finishNode(node);
19724         }
19725         function parseModuleOrNamespaceDeclaration(node, flags) {
19726             node.kind = 249;
19727             var namespaceFlag = flags & 16;
19728             node.flags |= flags;
19729             node.name = parseIdentifier();
19730             node.body = parseOptional(24)
19731                 ? parseModuleOrNamespaceDeclaration(createNode(0), 4 | namespaceFlag)
19732                 : parseModuleBlock();
19733             return finishNode(node);
19734         }
19735         function parseAmbientExternalModuleDeclaration(node) {
19736             node.kind = 249;
19737             if (token() === 150) {
19738                 node.name = parseIdentifier();
19739                 node.flags |= 1024;
19740             }
19741             else {
19742                 node.name = parseLiteralNode();
19743                 node.name.text = internIdentifier(node.name.text);
19744             }
19745             if (token() === 18) {
19746                 node.body = parseModuleBlock();
19747             }
19748             else {
19749                 parseSemicolon();
19750             }
19751             return finishNode(node);
19752         }
19753         function parseModuleDeclaration(node) {
19754             var flags = 0;
19755             if (token() === 150) {
19756                 return parseAmbientExternalModuleDeclaration(node);
19757             }
19758             else if (parseOptional(136)) {
19759                 flags |= 16;
19760             }
19761             else {
19762                 parseExpected(135);
19763                 if (token() === 10) {
19764                     return parseAmbientExternalModuleDeclaration(node);
19765                 }
19766             }
19767             return parseModuleOrNamespaceDeclaration(node, flags);
19768         }
19769         function isExternalModuleReference() {
19770             return token() === 139 &&
19771                 lookAhead(nextTokenIsOpenParen);
19772         }
19773         function nextTokenIsOpenParen() {
19774             return nextToken() === 20;
19775         }
19776         function nextTokenIsSlash() {
19777             return nextToken() === 43;
19778         }
19779         function parseNamespaceExportDeclaration(node) {
19780             node.kind = 252;
19781             parseExpected(123);
19782             parseExpected(136);
19783             node.name = parseIdentifier();
19784             parseSemicolon();
19785             return finishNode(node);
19786         }
19787         function parseImportDeclarationOrImportEqualsDeclaration(node) {
19788             parseExpected(96);
19789             var afterImportPos = scanner.getStartPos();
19790             var identifier;
19791             if (isIdentifier()) {
19792                 identifier = parseIdentifier();
19793             }
19794             var isTypeOnly = false;
19795             if (token() !== 149 &&
19796                 (identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) === "type" &&
19797                 (isIdentifier() || tokenAfterImportDefinitelyProducesImportDeclaration())) {
19798                 isTypeOnly = true;
19799                 identifier = isIdentifier() ? parseIdentifier() : undefined;
19800             }
19801             if (identifier && !tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration()) {
19802                 return parseImportEqualsDeclaration(node, identifier, isTypeOnly);
19803             }
19804             node.kind = 254;
19805             if (identifier ||
19806                 token() === 41 ||
19807                 token() === 18) {
19808                 node.importClause = parseImportClause(identifier, afterImportPos, isTypeOnly);
19809                 parseExpected(149);
19810             }
19811             node.moduleSpecifier = parseModuleSpecifier();
19812             parseSemicolon();
19813             return finishNode(node);
19814         }
19815         function tokenAfterImportDefinitelyProducesImportDeclaration() {
19816             return token() === 41 || token() === 18;
19817         }
19818         function tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration() {
19819             return token() === 27 || token() === 149;
19820         }
19821         function parseImportEqualsDeclaration(node, identifier, isTypeOnly) {
19822             node.kind = 253;
19823             node.name = identifier;
19824             parseExpected(62);
19825             node.moduleReference = parseModuleReference();
19826             parseSemicolon();
19827             var finished = finishNode(node);
19828             if (isTypeOnly) {
19829                 parseErrorAtRange(finished, ts.Diagnostics.Only_ECMAScript_imports_may_use_import_type);
19830             }
19831             return finished;
19832         }
19833         function parseImportClause(identifier, fullStart, isTypeOnly) {
19834             var importClause = createNode(255, fullStart);
19835             importClause.isTypeOnly = isTypeOnly;
19836             if (identifier) {
19837                 importClause.name = identifier;
19838             }
19839             if (!importClause.name ||
19840                 parseOptional(27)) {
19841                 importClause.namedBindings = token() === 41 ? parseNamespaceImport() : parseNamedImportsOrExports(257);
19842             }
19843             return finishNode(importClause);
19844         }
19845         function parseModuleReference() {
19846             return isExternalModuleReference()
19847                 ? parseExternalModuleReference()
19848                 : parseEntityName(false);
19849         }
19850         function parseExternalModuleReference() {
19851             var node = createNode(265);
19852             parseExpected(139);
19853             parseExpected(20);
19854             node.expression = parseModuleSpecifier();
19855             parseExpected(21);
19856             return finishNode(node);
19857         }
19858         function parseModuleSpecifier() {
19859             if (token() === 10) {
19860                 var result = parseLiteralNode();
19861                 result.text = internIdentifier(result.text);
19862                 return result;
19863             }
19864             else {
19865                 return parseExpression();
19866             }
19867         }
19868         function parseNamespaceImport() {
19869             var namespaceImport = createNode(256);
19870             parseExpected(41);
19871             parseExpected(123);
19872             namespaceImport.name = parseIdentifier();
19873             return finishNode(namespaceImport);
19874         }
19875         function parseNamedImportsOrExports(kind) {
19876             var node = createNode(kind);
19877             node.elements = parseBracketedList(23, kind === 257 ? parseImportSpecifier : parseExportSpecifier, 18, 19);
19878             return finishNode(node);
19879         }
19880         function parseExportSpecifier() {
19881             return parseImportOrExportSpecifier(263);
19882         }
19883         function parseImportSpecifier() {
19884             return parseImportOrExportSpecifier(258);
19885         }
19886         function parseImportOrExportSpecifier(kind) {
19887             var node = createNode(kind);
19888             var checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier();
19889             var checkIdentifierStart = scanner.getTokenPos();
19890             var checkIdentifierEnd = scanner.getTextPos();
19891             var identifierName = parseIdentifierName();
19892             if (token() === 123) {
19893                 node.propertyName = identifierName;
19894                 parseExpected(123);
19895                 checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier();
19896                 checkIdentifierStart = scanner.getTokenPos();
19897                 checkIdentifierEnd = scanner.getTextPos();
19898                 node.name = parseIdentifierName();
19899             }
19900             else {
19901                 node.name = identifierName;
19902             }
19903             if (kind === 258 && checkIdentifierIsKeyword) {
19904                 parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected);
19905             }
19906             return finishNode(node);
19907         }
19908         function parseNamespaceExport(pos) {
19909             var node = createNode(262, pos);
19910             node.name = parseIdentifier();
19911             return finishNode(node);
19912         }
19913         function parseExportDeclaration(node) {
19914             node.kind = 260;
19915             node.isTypeOnly = parseOptional(145);
19916             var namespaceExportPos = scanner.getStartPos();
19917             if (parseOptional(41)) {
19918                 if (parseOptional(123)) {
19919                     node.exportClause = parseNamespaceExport(namespaceExportPos);
19920                 }
19921                 parseExpected(149);
19922                 node.moduleSpecifier = parseModuleSpecifier();
19923             }
19924             else {
19925                 node.exportClause = parseNamedImportsOrExports(261);
19926                 if (token() === 149 || (token() === 10 && !scanner.hasPrecedingLineBreak())) {
19927                     parseExpected(149);
19928                     node.moduleSpecifier = parseModuleSpecifier();
19929                 }
19930             }
19931             parseSemicolon();
19932             return finishNode(node);
19933         }
19934         function parseExportAssignment(node) {
19935             node.kind = 259;
19936             if (parseOptional(62)) {
19937                 node.isExportEquals = true;
19938             }
19939             else {
19940                 parseExpected(84);
19941             }
19942             node.expression = parseAssignmentExpressionOrHigher();
19943             parseSemicolon();
19944             return finishNode(node);
19945         }
19946         function setExternalModuleIndicator(sourceFile) {
19947             sourceFile.externalModuleIndicator =
19948                 ts.forEach(sourceFile.statements, isAnExternalModuleIndicatorNode) ||
19949                     getImportMetaIfNecessary(sourceFile);
19950         }
19951         function isAnExternalModuleIndicatorNode(node) {
19952             return hasModifierOfKind(node, 89)
19953                 || node.kind === 253 && node.moduleReference.kind === 265
19954                 || node.kind === 254
19955                 || node.kind === 259
19956                 || node.kind === 260 ? node : undefined;
19957         }
19958         function getImportMetaIfNecessary(sourceFile) {
19959             return sourceFile.flags & 2097152 ?
19960                 walkTreeForExternalModuleIndicators(sourceFile) :
19961                 undefined;
19962         }
19963         function walkTreeForExternalModuleIndicators(node) {
19964             return isImportMeta(node) ? node : forEachChild(node, walkTreeForExternalModuleIndicators);
19965         }
19966         function hasModifierOfKind(node, kind) {
19967             return ts.some(node.modifiers, function (m) { return m.kind === kind; });
19968         }
19969         function isImportMeta(node) {
19970             return ts.isMetaProperty(node) && node.keywordToken === 96 && node.name.escapedText === "meta";
19971         }
19972         var JSDocParser;
19973         (function (JSDocParser) {
19974             function parseJSDocTypeExpressionForTests(content, start, length) {
19975                 initializeState(content, 99, undefined, 1);
19976                 sourceFile = createSourceFile("file.js", 99, 1, false);
19977                 scanner.setText(content, start, length);
19978                 currentToken = scanner.scan();
19979                 var jsDocTypeExpression = parseJSDocTypeExpression();
19980                 var diagnostics = parseDiagnostics;
19981                 clearState();
19982                 return jsDocTypeExpression ? { jsDocTypeExpression: jsDocTypeExpression, diagnostics: diagnostics } : undefined;
19983             }
19984             JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests;
19985             function parseJSDocTypeExpression(mayOmitBraces) {
19986                 var result = createNode(294);
19987                 var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18);
19988                 result.type = doInsideOfContext(4194304, parseJSDocType);
19989                 if (!mayOmitBraces || hasBrace) {
19990                     parseExpectedJSDoc(19);
19991                 }
19992                 fixupParentReferences(result);
19993                 return finishNode(result);
19994             }
19995             JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression;
19996             function parseIsolatedJSDocComment(content, start, length) {
19997                 initializeState(content, 99, undefined, 1);
19998                 sourceFile = { languageVariant: 0, text: content };
19999                 var jsDoc = doInsideOfContext(4194304, function () { return parseJSDocCommentWorker(start, length); });
20000                 var diagnostics = parseDiagnostics;
20001                 clearState();
20002                 return jsDoc ? { jsDoc: jsDoc, diagnostics: diagnostics } : undefined;
20003             }
20004             JSDocParser.parseIsolatedJSDocComment = parseIsolatedJSDocComment;
20005             function parseJSDocComment(parent, start, length) {
20006                 var _a;
20007                 var saveToken = currentToken;
20008                 var saveParseDiagnosticsLength = parseDiagnostics.length;
20009                 var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode;
20010                 var comment = doInsideOfContext(4194304, function () { return parseJSDocCommentWorker(start, length); });
20011                 if (comment) {
20012                     comment.parent = parent;
20013                 }
20014                 if (contextFlags & 131072) {
20015                     if (!sourceFile.jsDocDiagnostics) {
20016                         sourceFile.jsDocDiagnostics = [];
20017                     }
20018                     (_a = sourceFile.jsDocDiagnostics).push.apply(_a, parseDiagnostics);
20019                 }
20020                 currentToken = saveToken;
20021                 parseDiagnostics.length = saveParseDiagnosticsLength;
20022                 parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode;
20023                 return comment;
20024             }
20025             JSDocParser.parseJSDocComment = parseJSDocComment;
20026             function parseJSDocCommentWorker(start, length) {
20027                 if (start === void 0) { start = 0; }
20028                 var content = sourceText;
20029                 var end = length === undefined ? content.length : start + length;
20030                 length = end - start;
20031                 ts.Debug.assert(start >= 0);
20032                 ts.Debug.assert(start <= end);
20033                 ts.Debug.assert(end <= content.length);
20034                 if (!isJSDocLikeText(content, start)) {
20035                     return undefined;
20036                 }
20037                 var tags;
20038                 var tagsPos;
20039                 var tagsEnd;
20040                 var comments = [];
20041                 return scanner.scanRange(start + 3, length - 5, function () {
20042                     var state = 1;
20043                     var margin;
20044                     var indent = start - Math.max(content.lastIndexOf("\n", start), 0) + 4;
20045                     function pushComment(text) {
20046                         if (!margin) {
20047                             margin = indent;
20048                         }
20049                         comments.push(text);
20050                         indent += text.length;
20051                     }
20052                     nextTokenJSDoc();
20053                     while (parseOptionalJsdoc(5))
20054                         ;
20055                     if (parseOptionalJsdoc(4)) {
20056                         state = 0;
20057                         indent = 0;
20058                     }
20059                     loop: while (true) {
20060                         switch (token()) {
20061                             case 59:
20062                                 if (state === 0 || state === 1) {
20063                                     removeTrailingWhitespace(comments);
20064                                     addTag(parseTag(indent));
20065                                     state = 0;
20066                                     margin = undefined;
20067                                 }
20068                                 else {
20069                                     pushComment(scanner.getTokenText());
20070                                 }
20071                                 break;
20072                             case 4:
20073                                 comments.push(scanner.getTokenText());
20074                                 state = 0;
20075                                 indent = 0;
20076                                 break;
20077                             case 41:
20078                                 var asterisk = scanner.getTokenText();
20079                                 if (state === 1 || state === 2) {
20080                                     state = 2;
20081                                     pushComment(asterisk);
20082                                 }
20083                                 else {
20084                                     state = 1;
20085                                     indent += asterisk.length;
20086                                 }
20087                                 break;
20088                             case 5:
20089                                 var whitespace = scanner.getTokenText();
20090                                 if (state === 2) {
20091                                     comments.push(whitespace);
20092                                 }
20093                                 else if (margin !== undefined && indent + whitespace.length > margin) {
20094                                     comments.push(whitespace.slice(margin - indent - 1));
20095                                 }
20096                                 indent += whitespace.length;
20097                                 break;
20098                             case 1:
20099                                 break loop;
20100                             default:
20101                                 state = 2;
20102                                 pushComment(scanner.getTokenText());
20103                                 break;
20104                         }
20105                         nextTokenJSDoc();
20106                     }
20107                     removeLeadingNewlines(comments);
20108                     removeTrailingWhitespace(comments);
20109                     return createJSDocComment();
20110                 });
20111                 function removeLeadingNewlines(comments) {
20112                     while (comments.length && (comments[0] === "\n" || comments[0] === "\r")) {
20113                         comments.shift();
20114                     }
20115                 }
20116                 function removeTrailingWhitespace(comments) {
20117                     while (comments.length && comments[comments.length - 1].trim() === "") {
20118                         comments.pop();
20119                     }
20120                 }
20121                 function createJSDocComment() {
20122                     var result = createNode(303, start);
20123                     result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd);
20124                     result.comment = comments.length ? comments.join("") : undefined;
20125                     return finishNode(result, end);
20126                 }
20127                 function isNextNonwhitespaceTokenEndOfFile() {
20128                     while (true) {
20129                         nextTokenJSDoc();
20130                         if (token() === 1) {
20131                             return true;
20132                         }
20133                         if (!(token() === 5 || token() === 4)) {
20134                             return false;
20135                         }
20136                     }
20137                 }
20138                 function skipWhitespace() {
20139                     if (token() === 5 || token() === 4) {
20140                         if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) {
20141                             return;
20142                         }
20143                     }
20144                     while (token() === 5 || token() === 4) {
20145                         nextTokenJSDoc();
20146                     }
20147                 }
20148                 function skipWhitespaceOrAsterisk() {
20149                     if (token() === 5 || token() === 4) {
20150                         if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) {
20151                             return "";
20152                         }
20153                     }
20154                     var precedingLineBreak = scanner.hasPrecedingLineBreak();
20155                     var seenLineBreak = false;
20156                     var indentText = "";
20157                     while ((precedingLineBreak && token() === 41) || token() === 5 || token() === 4) {
20158                         indentText += scanner.getTokenText();
20159                         if (token() === 4) {
20160                             precedingLineBreak = true;
20161                             seenLineBreak = true;
20162                             indentText = "";
20163                         }
20164                         else if (token() === 41) {
20165                             precedingLineBreak = false;
20166                         }
20167                         nextTokenJSDoc();
20168                     }
20169                     return seenLineBreak ? indentText : "";
20170                 }
20171                 function parseTag(margin) {
20172                     ts.Debug.assert(token() === 59);
20173                     var start = scanner.getTokenPos();
20174                     nextTokenJSDoc();
20175                     var tagName = parseJSDocIdentifierName(undefined);
20176                     var indentText = skipWhitespaceOrAsterisk();
20177                     var tag;
20178                     switch (tagName.escapedText) {
20179                         case "author":
20180                             tag = parseAuthorTag(start, tagName, margin);
20181                             break;
20182                         case "implements":
20183                             tag = parseImplementsTag(start, tagName);
20184                             break;
20185                         case "augments":
20186                         case "extends":
20187                             tag = parseAugmentsTag(start, tagName);
20188                             break;
20189                         case "class":
20190                         case "constructor":
20191                             tag = parseSimpleTag(start, 310, tagName);
20192                             break;
20193                         case "public":
20194                             tag = parseSimpleTag(start, 311, tagName);
20195                             break;
20196                         case "private":
20197                             tag = parseSimpleTag(start, 312, tagName);
20198                             break;
20199                         case "protected":
20200                             tag = parseSimpleTag(start, 313, tagName);
20201                             break;
20202                         case "readonly":
20203                             tag = parseSimpleTag(start, 314, tagName);
20204                             break;
20205                         case "this":
20206                             tag = parseThisTag(start, tagName);
20207                             break;
20208                         case "enum":
20209                             tag = parseEnumTag(start, tagName);
20210                             break;
20211                         case "arg":
20212                         case "argument":
20213                         case "param":
20214                             return parseParameterOrPropertyTag(start, tagName, 2, margin);
20215                         case "return":
20216                         case "returns":
20217                             tag = parseReturnTag(start, tagName);
20218                             break;
20219                         case "template":
20220                             tag = parseTemplateTag(start, tagName);
20221                             break;
20222                         case "type":
20223                             tag = parseTypeTag(start, tagName);
20224                             break;
20225                         case "typedef":
20226                             tag = parseTypedefTag(start, tagName, margin);
20227                             break;
20228                         case "callback":
20229                             tag = parseCallbackTag(start, tagName, margin);
20230                             break;
20231                         default:
20232                             tag = parseUnknownTag(start, tagName);
20233                             break;
20234                     }
20235                     if (!tag.comment) {
20236                         if (!indentText) {
20237                             margin += tag.end - tag.pos;
20238                         }
20239                         tag.comment = parseTagComments(margin, indentText.slice(margin));
20240                     }
20241                     return tag;
20242                 }
20243                 function parseTagComments(indent, initialMargin) {
20244                     var comments = [];
20245                     var state = 0;
20246                     var margin;
20247                     function pushComment(text) {
20248                         if (!margin) {
20249                             margin = indent;
20250                         }
20251                         comments.push(text);
20252                         indent += text.length;
20253                     }
20254                     if (initialMargin !== undefined) {
20255                         if (initialMargin !== "") {
20256                             pushComment(initialMargin);
20257                         }
20258                         state = 1;
20259                     }
20260                     var tok = token();
20261                     loop: while (true) {
20262                         switch (tok) {
20263                             case 4:
20264                                 if (state >= 1) {
20265                                     state = 0;
20266                                     comments.push(scanner.getTokenText());
20267                                 }
20268                                 indent = 0;
20269                                 break;
20270                             case 59:
20271                                 if (state === 3) {
20272                                     comments.push(scanner.getTokenText());
20273                                     break;
20274                                 }
20275                                 scanner.setTextPos(scanner.getTextPos() - 1);
20276                             case 1:
20277                                 break loop;
20278                             case 5:
20279                                 if (state === 2 || state === 3) {
20280                                     pushComment(scanner.getTokenText());
20281                                 }
20282                                 else {
20283                                     var whitespace = scanner.getTokenText();
20284                                     if (margin !== undefined && indent + whitespace.length > margin) {
20285                                         comments.push(whitespace.slice(margin - indent));
20286                                     }
20287                                     indent += whitespace.length;
20288                                 }
20289                                 break;
20290                             case 18:
20291                                 state = 2;
20292                                 if (lookAhead(function () { return nextTokenJSDoc() === 59 && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) {
20293                                     pushComment(scanner.getTokenText());
20294                                     nextTokenJSDoc();
20295                                     pushComment(scanner.getTokenText());
20296                                     nextTokenJSDoc();
20297                                 }
20298                                 pushComment(scanner.getTokenText());
20299                                 break;
20300                             case 61:
20301                                 if (state === 3) {
20302                                     state = 2;
20303                                 }
20304                                 else {
20305                                     state = 3;
20306                                 }
20307                                 pushComment(scanner.getTokenText());
20308                                 break;
20309                             case 41:
20310                                 if (state === 0) {
20311                                     state = 1;
20312                                     indent += 1;
20313                                     break;
20314                                 }
20315                             default:
20316                                 if (state !== 3) {
20317                                     state = 2;
20318                                 }
20319                                 pushComment(scanner.getTokenText());
20320                                 break;
20321                         }
20322                         tok = nextTokenJSDoc();
20323                     }
20324                     removeLeadingNewlines(comments);
20325                     removeTrailingWhitespace(comments);
20326                     return comments.length === 0 ? undefined : comments.join("");
20327                 }
20328                 function parseUnknownTag(start, tagName) {
20329                     var result = createNode(306, start);
20330                     result.tagName = tagName;
20331                     return finishNode(result);
20332                 }
20333                 function addTag(tag) {
20334                     if (!tag) {
20335                         return;
20336                     }
20337                     if (!tags) {
20338                         tags = [tag];
20339                         tagsPos = tag.pos;
20340                     }
20341                     else {
20342                         tags.push(tag);
20343                     }
20344                     tagsEnd = tag.end;
20345                 }
20346                 function tryParseTypeExpression() {
20347                     skipWhitespaceOrAsterisk();
20348                     return token() === 18 ? parseJSDocTypeExpression() : undefined;
20349                 }
20350                 function parseBracketNameInPropertyAndParamTag() {
20351                     var isBracketed = parseOptionalJsdoc(22);
20352                     if (isBracketed) {
20353                         skipWhitespace();
20354                     }
20355                     var isBackquoted = parseOptionalJsdoc(61);
20356                     var name = parseJSDocEntityName();
20357                     if (isBackquoted) {
20358                         parseExpectedTokenJSDoc(61);
20359                     }
20360                     if (isBracketed) {
20361                         skipWhitespace();
20362                         if (parseOptionalToken(62)) {
20363                             parseExpression();
20364                         }
20365                         parseExpected(23);
20366                     }
20367                     return { name: name, isBracketed: isBracketed };
20368                 }
20369                 function isObjectOrObjectArrayTypeReference(node) {
20370                     switch (node.kind) {
20371                         case 141:
20372                             return true;
20373                         case 174:
20374                             return isObjectOrObjectArrayTypeReference(node.elementType);
20375                         default:
20376                             return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && !node.typeArguments;
20377                     }
20378                 }
20379                 function parseParameterOrPropertyTag(start, tagName, target, indent) {
20380                     var typeExpression = tryParseTypeExpression();
20381                     var isNameFirst = !typeExpression;
20382                     skipWhitespaceOrAsterisk();
20383                     var _a = parseBracketNameInPropertyAndParamTag(), name = _a.name, isBracketed = _a.isBracketed;
20384                     skipWhitespace();
20385                     if (isNameFirst) {
20386                         typeExpression = tryParseTypeExpression();
20387                     }
20388                     var result = target === 1 ?
20389                         createNode(323, start) :
20390                         createNode(317, start);
20391                     var comment = parseTagComments(indent + scanner.getStartPos() - start);
20392                     var nestedTypeLiteral = target !== 4 && parseNestedTypeLiteral(typeExpression, name, target, indent);
20393                     if (nestedTypeLiteral) {
20394                         typeExpression = nestedTypeLiteral;
20395                         isNameFirst = true;
20396                     }
20397                     result.tagName = tagName;
20398                     result.typeExpression = typeExpression;
20399                     result.name = name;
20400                     result.isNameFirst = isNameFirst;
20401                     result.isBracketed = isBracketed;
20402                     result.comment = comment;
20403                     return finishNode(result);
20404                 }
20405                 function parseNestedTypeLiteral(typeExpression, name, target, indent) {
20406                     if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) {
20407                         var typeLiteralExpression = createNode(294, scanner.getTokenPos());
20408                         var child = void 0;
20409                         var jsdocTypeLiteral = void 0;
20410                         var start_3 = scanner.getStartPos();
20411                         var children = void 0;
20412                         while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) {
20413                             if (child.kind === 317 || child.kind === 323) {
20414                                 children = ts.append(children, child);
20415                             }
20416                         }
20417                         if (children) {
20418                             jsdocTypeLiteral = createNode(304, start_3);
20419                             jsdocTypeLiteral.jsDocPropertyTags = children;
20420                             if (typeExpression.type.kind === 174) {
20421                                 jsdocTypeLiteral.isArrayType = true;
20422                             }
20423                             typeLiteralExpression.type = finishNode(jsdocTypeLiteral);
20424                             return finishNode(typeLiteralExpression);
20425                         }
20426                     }
20427                 }
20428                 function parseReturnTag(start, tagName) {
20429                     if (ts.some(tags, ts.isJSDocReturnTag)) {
20430                         parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText);
20431                     }
20432                     var result = createNode(318, start);
20433                     result.tagName = tagName;
20434                     result.typeExpression = tryParseTypeExpression();
20435                     return finishNode(result);
20436                 }
20437                 function parseTypeTag(start, tagName) {
20438                     if (ts.some(tags, ts.isJSDocTypeTag)) {
20439                         parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText);
20440                     }
20441                     var result = createNode(320, start);
20442                     result.tagName = tagName;
20443                     result.typeExpression = parseJSDocTypeExpression(true);
20444                     return finishNode(result);
20445                 }
20446                 function parseAuthorTag(start, tagName, indent) {
20447                     var result = createNode(309, start);
20448                     result.tagName = tagName;
20449                     var authorInfoWithEmail = tryParse(function () { return tryParseAuthorNameAndEmail(); });
20450                     if (!authorInfoWithEmail) {
20451                         return finishNode(result);
20452                     }
20453                     result.comment = authorInfoWithEmail;
20454                     if (lookAhead(function () { return nextToken() !== 4; })) {
20455                         var comment = parseTagComments(indent);
20456                         if (comment) {
20457                             result.comment += comment;
20458                         }
20459                     }
20460                     return finishNode(result);
20461                 }
20462                 function tryParseAuthorNameAndEmail() {
20463                     var comments = [];
20464                     var seenLessThan = false;
20465                     var seenGreaterThan = false;
20466                     var token = scanner.getToken();
20467                     loop: while (true) {
20468                         switch (token) {
20469                             case 75:
20470                             case 5:
20471                             case 24:
20472                             case 59:
20473                                 comments.push(scanner.getTokenText());
20474                                 break;
20475                             case 29:
20476                                 if (seenLessThan || seenGreaterThan) {
20477                                     return;
20478                                 }
20479                                 seenLessThan = true;
20480                                 comments.push(scanner.getTokenText());
20481                                 break;
20482                             case 31:
20483                                 if (!seenLessThan || seenGreaterThan) {
20484                                     return;
20485                                 }
20486                                 seenGreaterThan = true;
20487                                 comments.push(scanner.getTokenText());
20488                                 scanner.setTextPos(scanner.getTokenPos() + 1);
20489                                 break loop;
20490                             case 4:
20491                             case 1:
20492                                 break loop;
20493                         }
20494                         token = nextTokenJSDoc();
20495                     }
20496                     if (seenLessThan && seenGreaterThan) {
20497                         return comments.length === 0 ? undefined : comments.join("");
20498                     }
20499                 }
20500                 function parseImplementsTag(start, tagName) {
20501                     var result = createNode(308, start);
20502                     result.tagName = tagName;
20503                     result.class = parseExpressionWithTypeArgumentsForAugments();
20504                     return finishNode(result);
20505                 }
20506                 function parseAugmentsTag(start, tagName) {
20507                     var result = createNode(307, start);
20508                     result.tagName = tagName;
20509                     result.class = parseExpressionWithTypeArgumentsForAugments();
20510                     return finishNode(result);
20511                 }
20512                 function parseExpressionWithTypeArgumentsForAugments() {
20513                     var usedBrace = parseOptional(18);
20514                     var node = createNode(216);
20515                     node.expression = parsePropertyAccessEntityNameExpression();
20516                     node.typeArguments = tryParseTypeArguments();
20517                     var res = finishNode(node);
20518                     if (usedBrace) {
20519                         parseExpected(19);
20520                     }
20521                     return res;
20522                 }
20523                 function parsePropertyAccessEntityNameExpression() {
20524                     var node = parseJSDocIdentifierName();
20525                     while (parseOptional(24)) {
20526                         var prop = createNode(194, node.pos);
20527                         prop.expression = node;
20528                         prop.name = parseJSDocIdentifierName();
20529                         node = finishNode(prop);
20530                     }
20531                     return node;
20532                 }
20533                 function parseSimpleTag(start, kind, tagName) {
20534                     var tag = createNode(kind, start);
20535                     tag.tagName = tagName;
20536                     return finishNode(tag);
20537                 }
20538                 function parseThisTag(start, tagName) {
20539                     var tag = createNode(319, start);
20540                     tag.tagName = tagName;
20541                     tag.typeExpression = parseJSDocTypeExpression(true);
20542                     skipWhitespace();
20543                     return finishNode(tag);
20544                 }
20545                 function parseEnumTag(start, tagName) {
20546                     var tag = createNode(316, start);
20547                     tag.tagName = tagName;
20548                     tag.typeExpression = parseJSDocTypeExpression(true);
20549                     skipWhitespace();
20550                     return finishNode(tag);
20551                 }
20552                 function parseTypedefTag(start, tagName, indent) {
20553                     var typeExpression = tryParseTypeExpression();
20554                     skipWhitespaceOrAsterisk();
20555                     var typedefTag = createNode(322, start);
20556                     typedefTag.tagName = tagName;
20557                     typedefTag.fullName = parseJSDocTypeNameWithNamespace();
20558                     typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName);
20559                     skipWhitespace();
20560                     typedefTag.comment = parseTagComments(indent);
20561                     typedefTag.typeExpression = typeExpression;
20562                     var end;
20563                     if (!typeExpression || isObjectOrObjectArrayTypeReference(typeExpression.type)) {
20564                         var child = void 0;
20565                         var jsdocTypeLiteral = void 0;
20566                         var childTypeTag = void 0;
20567                         while (child = tryParse(function () { return parseChildPropertyTag(indent); })) {
20568                             if (!jsdocTypeLiteral) {
20569                                 jsdocTypeLiteral = createNode(304, start);
20570                             }
20571                             if (child.kind === 320) {
20572                                 if (childTypeTag) {
20573                                     break;
20574                                 }
20575                                 else {
20576                                     childTypeTag = child;
20577                                 }
20578                             }
20579                             else {
20580                                 jsdocTypeLiteral.jsDocPropertyTags = ts.append(jsdocTypeLiteral.jsDocPropertyTags, child);
20581                             }
20582                         }
20583                         if (jsdocTypeLiteral) {
20584                             if (typeExpression && typeExpression.type.kind === 174) {
20585                                 jsdocTypeLiteral.isArrayType = true;
20586                             }
20587                             typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ?
20588                                 childTypeTag.typeExpression :
20589                                 finishNode(jsdocTypeLiteral);
20590                             end = typedefTag.typeExpression.end;
20591                         }
20592                     }
20593                     return finishNode(typedefTag, end || typedefTag.comment !== undefined ? scanner.getStartPos() : (typedefTag.fullName || typedefTag.typeExpression || typedefTag.tagName).end);
20594                 }
20595                 function parseJSDocTypeNameWithNamespace(nested) {
20596                     var pos = scanner.getTokenPos();
20597                     if (!ts.tokenIsIdentifierOrKeyword(token())) {
20598                         return undefined;
20599                     }
20600                     var typeNameOrNamespaceName = parseJSDocIdentifierName();
20601                     if (parseOptional(24)) {
20602                         var jsDocNamespaceNode = createNode(249, pos);
20603                         if (nested) {
20604                             jsDocNamespaceNode.flags |= 4;
20605                         }
20606                         jsDocNamespaceNode.name = typeNameOrNamespaceName;
20607                         jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(true);
20608                         return finishNode(jsDocNamespaceNode);
20609                     }
20610                     if (nested) {
20611                         typeNameOrNamespaceName.isInJSDocNamespace = true;
20612                     }
20613                     return typeNameOrNamespaceName;
20614                 }
20615                 function parseCallbackTag(start, tagName, indent) {
20616                     var callbackTag = createNode(315, start);
20617                     callbackTag.tagName = tagName;
20618                     callbackTag.fullName = parseJSDocTypeNameWithNamespace();
20619                     callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName);
20620                     skipWhitespace();
20621                     callbackTag.comment = parseTagComments(indent);
20622                     var child;
20623                     var jsdocSignature = createNode(305, start);
20624                     jsdocSignature.parameters = [];
20625                     while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4, indent); })) {
20626                         jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child);
20627                     }
20628                     var returnTag = tryParse(function () {
20629                         if (parseOptionalJsdoc(59)) {
20630                             var tag = parseTag(indent);
20631                             if (tag && tag.kind === 318) {
20632                                 return tag;
20633                             }
20634                         }
20635                     });
20636                     if (returnTag) {
20637                         jsdocSignature.type = returnTag;
20638                     }
20639                     callbackTag.typeExpression = finishNode(jsdocSignature);
20640                     return finishNode(callbackTag);
20641                 }
20642                 function getJSDocTypeAliasName(fullName) {
20643                     if (fullName) {
20644                         var rightNode = fullName;
20645                         while (true) {
20646                             if (ts.isIdentifier(rightNode) || !rightNode.body) {
20647                                 return ts.isIdentifier(rightNode) ? rightNode : rightNode.name;
20648                             }
20649                             rightNode = rightNode.body;
20650                         }
20651                     }
20652                 }
20653                 function escapedTextsEqual(a, b) {
20654                     while (!ts.isIdentifier(a) || !ts.isIdentifier(b)) {
20655                         if (!ts.isIdentifier(a) && !ts.isIdentifier(b) && a.right.escapedText === b.right.escapedText) {
20656                             a = a.left;
20657                             b = b.left;
20658                         }
20659                         else {
20660                             return false;
20661                         }
20662                     }
20663                     return a.escapedText === b.escapedText;
20664                 }
20665                 function parseChildPropertyTag(indent) {
20666                     return parseChildParameterOrPropertyTag(1, indent);
20667                 }
20668                 function parseChildParameterOrPropertyTag(target, indent, name) {
20669                     var canParseTag = true;
20670                     var seenAsterisk = false;
20671                     while (true) {
20672                         switch (nextTokenJSDoc()) {
20673                             case 59:
20674                                 if (canParseTag) {
20675                                     var child = tryParseChildTag(target, indent);
20676                                     if (child && (child.kind === 317 || child.kind === 323) &&
20677                                         target !== 4 &&
20678                                         name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) {
20679                                         return false;
20680                                     }
20681                                     return child;
20682                                 }
20683                                 seenAsterisk = false;
20684                                 break;
20685                             case 4:
20686                                 canParseTag = true;
20687                                 seenAsterisk = false;
20688                                 break;
20689                             case 41:
20690                                 if (seenAsterisk) {
20691                                     canParseTag = false;
20692                                 }
20693                                 seenAsterisk = true;
20694                                 break;
20695                             case 75:
20696                                 canParseTag = false;
20697                                 break;
20698                             case 1:
20699                                 return false;
20700                         }
20701                     }
20702                 }
20703                 function tryParseChildTag(target, indent) {
20704                     ts.Debug.assert(token() === 59);
20705                     var start = scanner.getStartPos();
20706                     nextTokenJSDoc();
20707                     var tagName = parseJSDocIdentifierName();
20708                     skipWhitespace();
20709                     var t;
20710                     switch (tagName.escapedText) {
20711                         case "type":
20712                             return target === 1 && parseTypeTag(start, tagName);
20713                         case "prop":
20714                         case "property":
20715                             t = 1;
20716                             break;
20717                         case "arg":
20718                         case "argument":
20719                         case "param":
20720                             t = 2 | 4;
20721                             break;
20722                         default:
20723                             return false;
20724                     }
20725                     if (!(target & t)) {
20726                         return false;
20727                     }
20728                     return parseParameterOrPropertyTag(start, tagName, target, indent);
20729                 }
20730                 function parseTemplateTag(start, tagName) {
20731                     var constraint;
20732                     if (token() === 18) {
20733                         constraint = parseJSDocTypeExpression();
20734                     }
20735                     var typeParameters = [];
20736                     var typeParametersPos = getNodePos();
20737                     do {
20738                         skipWhitespace();
20739                         var typeParameter = createNode(155);
20740                         typeParameter.name = parseJSDocIdentifierName(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces);
20741                         finishNode(typeParameter);
20742                         skipWhitespaceOrAsterisk();
20743                         typeParameters.push(typeParameter);
20744                     } while (parseOptionalJsdoc(27));
20745                     var result = createNode(321, start);
20746                     result.tagName = tagName;
20747                     result.constraint = constraint;
20748                     result.typeParameters = createNodeArray(typeParameters, typeParametersPos);
20749                     finishNode(result);
20750                     return result;
20751                 }
20752                 function parseOptionalJsdoc(t) {
20753                     if (token() === t) {
20754                         nextTokenJSDoc();
20755                         return true;
20756                     }
20757                     return false;
20758                 }
20759                 function parseJSDocEntityName() {
20760                     var entity = parseJSDocIdentifierName();
20761                     if (parseOptional(22)) {
20762                         parseExpected(23);
20763                     }
20764                     while (parseOptional(24)) {
20765                         var name = parseJSDocIdentifierName();
20766                         if (parseOptional(22)) {
20767                             parseExpected(23);
20768                         }
20769                         entity = createQualifiedName(entity, name);
20770                     }
20771                     return entity;
20772                 }
20773                 function parseJSDocIdentifierName(message) {
20774                     if (!ts.tokenIsIdentifierOrKeyword(token())) {
20775                         return createMissingNode(75, !message, message || ts.Diagnostics.Identifier_expected);
20776                     }
20777                     identifierCount++;
20778                     var pos = scanner.getTokenPos();
20779                     var end = scanner.getTextPos();
20780                     var result = createNode(75, pos);
20781                     if (token() !== 75) {
20782                         result.originalKeywordKind = token();
20783                     }
20784                     result.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue()));
20785                     finishNode(result, end);
20786                     nextTokenJSDoc();
20787                     return result;
20788                 }
20789             }
20790         })(JSDocParser = Parser.JSDocParser || (Parser.JSDocParser = {}));
20791     })(Parser || (Parser = {}));
20792     var IncrementalParser;
20793     (function (IncrementalParser) {
20794         function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) {
20795             aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2);
20796             checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks);
20797             if (ts.textChangeRangeIsUnchanged(textChangeRange)) {
20798                 return sourceFile;
20799             }
20800             if (sourceFile.statements.length === 0) {
20801                 return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, undefined, true, sourceFile.scriptKind);
20802             }
20803             var incrementalSourceFile = sourceFile;
20804             ts.Debug.assert(!incrementalSourceFile.hasBeenIncrementallyParsed);
20805             incrementalSourceFile.hasBeenIncrementallyParsed = true;
20806             var oldText = sourceFile.text;
20807             var syntaxCursor = createSyntaxCursor(sourceFile);
20808             var changeRange = extendToAffectedRange(sourceFile, textChangeRange);
20809             checkChangeRange(sourceFile, newText, changeRange, aggressiveChecks);
20810             ts.Debug.assert(changeRange.span.start <= textChangeRange.span.start);
20811             ts.Debug.assert(ts.textSpanEnd(changeRange.span) === ts.textSpanEnd(textChangeRange.span));
20812             ts.Debug.assert(ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)) === ts.textSpanEnd(ts.textChangeRangeNewSpan(textChangeRange)));
20813             var delta = ts.textChangeRangeNewSpan(changeRange).length - changeRange.span.length;
20814             updateTokenPositionsAndMarkElements(incrementalSourceFile, changeRange.span.start, ts.textSpanEnd(changeRange.span), ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)), delta, oldText, newText, aggressiveChecks);
20815             var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, true, sourceFile.scriptKind);
20816             result.commentDirectives = getNewCommentDirectives(sourceFile.commentDirectives, result.commentDirectives, changeRange.span.start, ts.textSpanEnd(changeRange.span), delta, oldText, newText, aggressiveChecks);
20817             return result;
20818         }
20819         IncrementalParser.updateSourceFile = updateSourceFile;
20820         function getNewCommentDirectives(oldDirectives, newDirectives, changeStart, changeRangeOldEnd, delta, oldText, newText, aggressiveChecks) {
20821             if (!oldDirectives)
20822                 return newDirectives;
20823             var commentDirectives;
20824             var addedNewlyScannedDirectives = false;
20825             for (var _i = 0, oldDirectives_1 = oldDirectives; _i < oldDirectives_1.length; _i++) {
20826                 var directive = oldDirectives_1[_i];
20827                 var range = directive.range, type = directive.type;
20828                 if (range.end < changeStart) {
20829                     commentDirectives = ts.append(commentDirectives, directive);
20830                 }
20831                 else if (range.pos > changeRangeOldEnd) {
20832                     addNewlyScannedDirectives();
20833                     var updatedDirective = {
20834                         range: { pos: range.pos + delta, end: range.end + delta },
20835                         type: type
20836                     };
20837                     commentDirectives = ts.append(commentDirectives, updatedDirective);
20838                     if (aggressiveChecks) {
20839                         ts.Debug.assert(oldText.substring(range.pos, range.end) === newText.substring(updatedDirective.range.pos, updatedDirective.range.end));
20840                     }
20841                 }
20842             }
20843             addNewlyScannedDirectives();
20844             return commentDirectives;
20845             function addNewlyScannedDirectives() {
20846                 if (addedNewlyScannedDirectives)
20847                     return;
20848                 addedNewlyScannedDirectives = true;
20849                 if (!commentDirectives) {
20850                     commentDirectives = newDirectives;
20851                 }
20852                 else if (newDirectives) {
20853                     commentDirectives.push.apply(commentDirectives, newDirectives);
20854                 }
20855             }
20856         }
20857         function moveElementEntirelyPastChangeRange(element, isArray, delta, oldText, newText, aggressiveChecks) {
20858             if (isArray) {
20859                 visitArray(element);
20860             }
20861             else {
20862                 visitNode(element);
20863             }
20864             return;
20865             function visitNode(node) {
20866                 var text = "";
20867                 if (aggressiveChecks && shouldCheckNode(node)) {
20868                     text = oldText.substring(node.pos, node.end);
20869                 }
20870                 if (node._children) {
20871                     node._children = undefined;
20872                 }
20873                 node.pos += delta;
20874                 node.end += delta;
20875                 if (aggressiveChecks && shouldCheckNode(node)) {
20876                     ts.Debug.assert(text === newText.substring(node.pos, node.end));
20877                 }
20878                 forEachChild(node, visitNode, visitArray);
20879                 if (ts.hasJSDocNodes(node)) {
20880                     for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) {
20881                         var jsDocComment = _a[_i];
20882                         visitNode(jsDocComment);
20883                     }
20884                 }
20885                 checkNodePositions(node, aggressiveChecks);
20886             }
20887             function visitArray(array) {
20888                 array._children = undefined;
20889                 array.pos += delta;
20890                 array.end += delta;
20891                 for (var _i = 0, array_8 = array; _i < array_8.length; _i++) {
20892                     var node = array_8[_i];
20893                     visitNode(node);
20894                 }
20895             }
20896         }
20897         function shouldCheckNode(node) {
20898             switch (node.kind) {
20899                 case 10:
20900                 case 8:
20901                 case 75:
20902                     return true;
20903             }
20904             return false;
20905         }
20906         function adjustIntersectingElement(element, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta) {
20907             ts.Debug.assert(element.end >= changeStart, "Adjusting an element that was entirely before the change range");
20908             ts.Debug.assert(element.pos <= changeRangeOldEnd, "Adjusting an element that was entirely after the change range");
20909             ts.Debug.assert(element.pos <= element.end);
20910             element.pos = Math.min(element.pos, changeRangeNewEnd);
20911             if (element.end >= changeRangeOldEnd) {
20912                 element.end += delta;
20913             }
20914             else {
20915                 element.end = Math.min(element.end, changeRangeNewEnd);
20916             }
20917             ts.Debug.assert(element.pos <= element.end);
20918             if (element.parent) {
20919                 ts.Debug.assert(element.pos >= element.parent.pos);
20920                 ts.Debug.assert(element.end <= element.parent.end);
20921             }
20922         }
20923         function checkNodePositions(node, aggressiveChecks) {
20924             if (aggressiveChecks) {
20925                 var pos_2 = node.pos;
20926                 var visitNode_1 = function (child) {
20927                     ts.Debug.assert(child.pos >= pos_2);
20928                     pos_2 = child.end;
20929                 };
20930                 if (ts.hasJSDocNodes(node)) {
20931                     for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) {
20932                         var jsDocComment = _a[_i];
20933                         visitNode_1(jsDocComment);
20934                     }
20935                 }
20936                 forEachChild(node, visitNode_1);
20937                 ts.Debug.assert(pos_2 <= node.end);
20938             }
20939         }
20940         function updateTokenPositionsAndMarkElements(sourceFile, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta, oldText, newText, aggressiveChecks) {
20941             visitNode(sourceFile);
20942             return;
20943             function visitNode(child) {
20944                 ts.Debug.assert(child.pos <= child.end);
20945                 if (child.pos > changeRangeOldEnd) {
20946                     moveElementEntirelyPastChangeRange(child, false, delta, oldText, newText, aggressiveChecks);
20947                     return;
20948                 }
20949                 var fullEnd = child.end;
20950                 if (fullEnd >= changeStart) {
20951                     child.intersectsChange = true;
20952                     child._children = undefined;
20953                     adjustIntersectingElement(child, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta);
20954                     forEachChild(child, visitNode, visitArray);
20955                     if (ts.hasJSDocNodes(child)) {
20956                         for (var _i = 0, _a = child.jsDoc; _i < _a.length; _i++) {
20957                             var jsDocComment = _a[_i];
20958                             visitNode(jsDocComment);
20959                         }
20960                     }
20961                     checkNodePositions(child, aggressiveChecks);
20962                     return;
20963                 }
20964                 ts.Debug.assert(fullEnd < changeStart);
20965             }
20966             function visitArray(array) {
20967                 ts.Debug.assert(array.pos <= array.end);
20968                 if (array.pos > changeRangeOldEnd) {
20969                     moveElementEntirelyPastChangeRange(array, true, delta, oldText, newText, aggressiveChecks);
20970                     return;
20971                 }
20972                 var fullEnd = array.end;
20973                 if (fullEnd >= changeStart) {
20974                     array.intersectsChange = true;
20975                     array._children = undefined;
20976                     adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta);
20977                     for (var _i = 0, array_9 = array; _i < array_9.length; _i++) {
20978                         var node = array_9[_i];
20979                         visitNode(node);
20980                     }
20981                     return;
20982                 }
20983                 ts.Debug.assert(fullEnd < changeStart);
20984             }
20985         }
20986         function extendToAffectedRange(sourceFile, changeRange) {
20987             var maxLookahead = 1;
20988             var start = changeRange.span.start;
20989             for (var i = 0; start > 0 && i <= maxLookahead; i++) {
20990                 var nearestNode = findNearestNodeStartingBeforeOrAtPosition(sourceFile, start);
20991                 ts.Debug.assert(nearestNode.pos <= start);
20992                 var position = nearestNode.pos;
20993                 start = Math.max(0, position - 1);
20994             }
20995             var finalSpan = ts.createTextSpanFromBounds(start, ts.textSpanEnd(changeRange.span));
20996             var finalLength = changeRange.newLength + (changeRange.span.start - start);
20997             return ts.createTextChangeRange(finalSpan, finalLength);
20998         }
20999         function findNearestNodeStartingBeforeOrAtPosition(sourceFile, position) {
21000             var bestResult = sourceFile;
21001             var lastNodeEntirelyBeforePosition;
21002             forEachChild(sourceFile, visit);
21003             if (lastNodeEntirelyBeforePosition) {
21004                 var lastChildOfLastEntireNodeBeforePosition = getLastDescendant(lastNodeEntirelyBeforePosition);
21005                 if (lastChildOfLastEntireNodeBeforePosition.pos > bestResult.pos) {
21006                     bestResult = lastChildOfLastEntireNodeBeforePosition;
21007                 }
21008             }
21009             return bestResult;
21010             function getLastDescendant(node) {
21011                 while (true) {
21012                     var lastChild = ts.getLastChild(node);
21013                     if (lastChild) {
21014                         node = lastChild;
21015                     }
21016                     else {
21017                         return node;
21018                     }
21019                 }
21020             }
21021             function visit(child) {
21022                 if (ts.nodeIsMissing(child)) {
21023                     return;
21024                 }
21025                 if (child.pos <= position) {
21026                     if (child.pos >= bestResult.pos) {
21027                         bestResult = child;
21028                     }
21029                     if (position < child.end) {
21030                         forEachChild(child, visit);
21031                         return true;
21032                     }
21033                     else {
21034                         ts.Debug.assert(child.end <= position);
21035                         lastNodeEntirelyBeforePosition = child;
21036                     }
21037                 }
21038                 else {
21039                     ts.Debug.assert(child.pos > position);
21040                     return true;
21041                 }
21042             }
21043         }
21044         function checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks) {
21045             var oldText = sourceFile.text;
21046             if (textChangeRange) {
21047                 ts.Debug.assert((oldText.length - textChangeRange.span.length + textChangeRange.newLength) === newText.length);
21048                 if (aggressiveChecks || ts.Debug.shouldAssert(3)) {
21049                     var oldTextPrefix = oldText.substr(0, textChangeRange.span.start);
21050                     var newTextPrefix = newText.substr(0, textChangeRange.span.start);
21051                     ts.Debug.assert(oldTextPrefix === newTextPrefix);
21052                     var oldTextSuffix = oldText.substring(ts.textSpanEnd(textChangeRange.span), oldText.length);
21053                     var newTextSuffix = newText.substring(ts.textSpanEnd(ts.textChangeRangeNewSpan(textChangeRange)), newText.length);
21054                     ts.Debug.assert(oldTextSuffix === newTextSuffix);
21055                 }
21056             }
21057         }
21058         function createSyntaxCursor(sourceFile) {
21059             var currentArray = sourceFile.statements;
21060             var currentArrayIndex = 0;
21061             ts.Debug.assert(currentArrayIndex < currentArray.length);
21062             var current = currentArray[currentArrayIndex];
21063             var lastQueriedPosition = -1;
21064             return {
21065                 currentNode: function (position) {
21066                     if (position !== lastQueriedPosition) {
21067                         if (current && current.end === position && currentArrayIndex < (currentArray.length - 1)) {
21068                             currentArrayIndex++;
21069                             current = currentArray[currentArrayIndex];
21070                         }
21071                         if (!current || current.pos !== position) {
21072                             findHighestListElementThatStartsAtPosition(position);
21073                         }
21074                     }
21075                     lastQueriedPosition = position;
21076                     ts.Debug.assert(!current || current.pos === position);
21077                     return current;
21078                 }
21079             };
21080             function findHighestListElementThatStartsAtPosition(position) {
21081                 currentArray = undefined;
21082                 currentArrayIndex = -1;
21083                 current = undefined;
21084                 forEachChild(sourceFile, visitNode, visitArray);
21085                 return;
21086                 function visitNode(node) {
21087                     if (position >= node.pos && position < node.end) {
21088                         forEachChild(node, visitNode, visitArray);
21089                         return true;
21090                     }
21091                     return false;
21092                 }
21093                 function visitArray(array) {
21094                     if (position >= array.pos && position < array.end) {
21095                         for (var i = 0; i < array.length; i++) {
21096                             var child = array[i];
21097                             if (child) {
21098                                 if (child.pos === position) {
21099                                     currentArray = array;
21100                                     currentArrayIndex = i;
21101                                     current = child;
21102                                     return true;
21103                                 }
21104                                 else {
21105                                     if (child.pos < position && position < child.end) {
21106                                         forEachChild(child, visitNode, visitArray);
21107                                         return true;
21108                                     }
21109                                 }
21110                             }
21111                         }
21112                     }
21113                     return false;
21114                 }
21115             }
21116         }
21117     })(IncrementalParser || (IncrementalParser = {}));
21118     function isDeclarationFileName(fileName) {
21119         return ts.fileExtensionIs(fileName, ".d.ts");
21120     }
21121     ts.isDeclarationFileName = isDeclarationFileName;
21122     function processCommentPragmas(context, sourceText) {
21123         var pragmas = [];
21124         for (var _i = 0, _a = ts.getLeadingCommentRanges(sourceText, 0) || ts.emptyArray; _i < _a.length; _i++) {
21125             var range = _a[_i];
21126             var comment = sourceText.substring(range.pos, range.end);
21127             extractPragmas(pragmas, range, comment);
21128         }
21129         context.pragmas = ts.createMap();
21130         for (var _b = 0, pragmas_1 = pragmas; _b < pragmas_1.length; _b++) {
21131             var pragma = pragmas_1[_b];
21132             if (context.pragmas.has(pragma.name)) {
21133                 var currentValue = context.pragmas.get(pragma.name);
21134                 if (currentValue instanceof Array) {
21135                     currentValue.push(pragma.args);
21136                 }
21137                 else {
21138                     context.pragmas.set(pragma.name, [currentValue, pragma.args]);
21139                 }
21140                 continue;
21141             }
21142             context.pragmas.set(pragma.name, pragma.args);
21143         }
21144     }
21145     ts.processCommentPragmas = processCommentPragmas;
21146     function processPragmasIntoFields(context, reportDiagnostic) {
21147         context.checkJsDirective = undefined;
21148         context.referencedFiles = [];
21149         context.typeReferenceDirectives = [];
21150         context.libReferenceDirectives = [];
21151         context.amdDependencies = [];
21152         context.hasNoDefaultLib = false;
21153         context.pragmas.forEach(function (entryOrList, key) {
21154             switch (key) {
21155                 case "reference": {
21156                     var referencedFiles_1 = context.referencedFiles;
21157                     var typeReferenceDirectives_1 = context.typeReferenceDirectives;
21158                     var libReferenceDirectives_1 = context.libReferenceDirectives;
21159                     ts.forEach(ts.toArray(entryOrList), function (arg) {
21160                         var _a = arg.arguments, types = _a.types, lib = _a.lib, path = _a.path;
21161                         if (arg.arguments["no-default-lib"]) {
21162                             context.hasNoDefaultLib = true;
21163                         }
21164                         else if (types) {
21165                             typeReferenceDirectives_1.push({ pos: types.pos, end: types.end, fileName: types.value });
21166                         }
21167                         else if (lib) {
21168                             libReferenceDirectives_1.push({ pos: lib.pos, end: lib.end, fileName: lib.value });
21169                         }
21170                         else if (path) {
21171                             referencedFiles_1.push({ pos: path.pos, end: path.end, fileName: path.value });
21172                         }
21173                         else {
21174                             reportDiagnostic(arg.range.pos, arg.range.end - arg.range.pos, ts.Diagnostics.Invalid_reference_directive_syntax);
21175                         }
21176                     });
21177                     break;
21178                 }
21179                 case "amd-dependency": {
21180                     context.amdDependencies = ts.map(ts.toArray(entryOrList), function (x) { return ({ name: x.arguments.name, path: x.arguments.path }); });
21181                     break;
21182                 }
21183                 case "amd-module": {
21184                     if (entryOrList instanceof Array) {
21185                         for (var _i = 0, entryOrList_1 = entryOrList; _i < entryOrList_1.length; _i++) {
21186                             var entry = entryOrList_1[_i];
21187                             if (context.moduleName) {
21188                                 reportDiagnostic(entry.range.pos, entry.range.end - entry.range.pos, ts.Diagnostics.An_AMD_module_cannot_have_multiple_name_assignments);
21189                             }
21190                             context.moduleName = entry.arguments.name;
21191                         }
21192                     }
21193                     else {
21194                         context.moduleName = entryOrList.arguments.name;
21195                     }
21196                     break;
21197                 }
21198                 case "ts-nocheck":
21199                 case "ts-check": {
21200                     ts.forEach(ts.toArray(entryOrList), function (entry) {
21201                         if (!context.checkJsDirective || entry.range.pos > context.checkJsDirective.pos) {
21202                             context.checkJsDirective = {
21203                                 enabled: key === "ts-check",
21204                                 end: entry.range.end,
21205                                 pos: entry.range.pos
21206                             };
21207                         }
21208                     });
21209                     break;
21210                 }
21211                 case "jsx": return;
21212                 default: ts.Debug.fail("Unhandled pragma kind");
21213             }
21214         });
21215     }
21216     ts.processPragmasIntoFields = processPragmasIntoFields;
21217     var namedArgRegExCache = ts.createMap();
21218     function getNamedArgRegEx(name) {
21219         if (namedArgRegExCache.has(name)) {
21220             return namedArgRegExCache.get(name);
21221         }
21222         var result = new RegExp("(\\s" + name + "\\s*=\\s*)('|\")(.+?)\\2", "im");
21223         namedArgRegExCache.set(name, result);
21224         return result;
21225     }
21226     var tripleSlashXMLCommentStartRegEx = /^\/\/\/\s*<(\S+)\s.*?\/>/im;
21227     var singleLinePragmaRegEx = /^\/\/\/?\s*@(\S+)\s*(.*)\s*$/im;
21228     function extractPragmas(pragmas, range, text) {
21229         var tripleSlash = range.kind === 2 && tripleSlashXMLCommentStartRegEx.exec(text);
21230         if (tripleSlash) {
21231             var name = tripleSlash[1].toLowerCase();
21232             var pragma = ts.commentPragmas[name];
21233             if (!pragma || !(pragma.kind & 1)) {
21234                 return;
21235             }
21236             if (pragma.args) {
21237                 var argument = {};
21238                 for (var _i = 0, _a = pragma.args; _i < _a.length; _i++) {
21239                     var arg = _a[_i];
21240                     var matcher = getNamedArgRegEx(arg.name);
21241                     var matchResult = matcher.exec(text);
21242                     if (!matchResult && !arg.optional) {
21243                         return;
21244                     }
21245                     else if (matchResult) {
21246                         if (arg.captureSpan) {
21247                             var startPos = range.pos + matchResult.index + matchResult[1].length + matchResult[2].length;
21248                             argument[arg.name] = {
21249                                 value: matchResult[3],
21250                                 pos: startPos,
21251                                 end: startPos + matchResult[3].length
21252                             };
21253                         }
21254                         else {
21255                             argument[arg.name] = matchResult[3];
21256                         }
21257                     }
21258                 }
21259                 pragmas.push({ name: name, args: { arguments: argument, range: range } });
21260             }
21261             else {
21262                 pragmas.push({ name: name, args: { arguments: {}, range: range } });
21263             }
21264             return;
21265         }
21266         var singleLine = range.kind === 2 && singleLinePragmaRegEx.exec(text);
21267         if (singleLine) {
21268             return addPragmaForMatch(pragmas, range, 2, singleLine);
21269         }
21270         if (range.kind === 3) {
21271             var multiLinePragmaRegEx = /\s*@(\S+)\s*(.*)\s*$/gim;
21272             var multiLineMatch = void 0;
21273             while (multiLineMatch = multiLinePragmaRegEx.exec(text)) {
21274                 addPragmaForMatch(pragmas, range, 4, multiLineMatch);
21275             }
21276         }
21277     }
21278     function addPragmaForMatch(pragmas, range, kind, match) {
21279         if (!match)
21280             return;
21281         var name = match[1].toLowerCase();
21282         var pragma = ts.commentPragmas[name];
21283         if (!pragma || !(pragma.kind & kind)) {
21284             return;
21285         }
21286         var args = match[2];
21287         var argument = getNamedPragmaArguments(pragma, args);
21288         if (argument === "fail")
21289             return;
21290         pragmas.push({ name: name, args: { arguments: argument, range: range } });
21291         return;
21292     }
21293     function getNamedPragmaArguments(pragma, text) {
21294         if (!text)
21295             return {};
21296         if (!pragma.args)
21297             return {};
21298         var args = text.split(/\s+/);
21299         var argMap = {};
21300         for (var i = 0; i < pragma.args.length; i++) {
21301             var argument = pragma.args[i];
21302             if (!args[i] && !argument.optional) {
21303                 return "fail";
21304             }
21305             if (argument.captureSpan) {
21306                 return ts.Debug.fail("Capture spans not yet implemented for non-xml pragmas");
21307             }
21308             argMap[argument.name] = args[i];
21309         }
21310         return argMap;
21311     }
21312     function tagNamesAreEquivalent(lhs, rhs) {
21313         if (lhs.kind !== rhs.kind) {
21314             return false;
21315         }
21316         if (lhs.kind === 75) {
21317             return lhs.escapedText === rhs.escapedText;
21318         }
21319         if (lhs.kind === 104) {
21320             return true;
21321         }
21322         return lhs.name.escapedText === rhs.name.escapedText &&
21323             tagNamesAreEquivalent(lhs.expression, rhs.expression);
21324     }
21325     ts.tagNamesAreEquivalent = tagNamesAreEquivalent;
21326 })(ts || (ts = {}));
21327 var ts;
21328 (function (ts) {
21329     ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" };
21330     var libEntries = [
21331         ["es5", "lib.es5.d.ts"],
21332         ["es6", "lib.es2015.d.ts"],
21333         ["es2015", "lib.es2015.d.ts"],
21334         ["es7", "lib.es2016.d.ts"],
21335         ["es2016", "lib.es2016.d.ts"],
21336         ["es2017", "lib.es2017.d.ts"],
21337         ["es2018", "lib.es2018.d.ts"],
21338         ["es2019", "lib.es2019.d.ts"],
21339         ["es2020", "lib.es2020.d.ts"],
21340         ["esnext", "lib.esnext.d.ts"],
21341         ["dom", "lib.dom.d.ts"],
21342         ["dom.iterable", "lib.dom.iterable.d.ts"],
21343         ["webworker", "lib.webworker.d.ts"],
21344         ["webworker.importscripts", "lib.webworker.importscripts.d.ts"],
21345         ["scripthost", "lib.scripthost.d.ts"],
21346         ["es2015.core", "lib.es2015.core.d.ts"],
21347         ["es2015.collection", "lib.es2015.collection.d.ts"],
21348         ["es2015.generator", "lib.es2015.generator.d.ts"],
21349         ["es2015.iterable", "lib.es2015.iterable.d.ts"],
21350         ["es2015.promise", "lib.es2015.promise.d.ts"],
21351         ["es2015.proxy", "lib.es2015.proxy.d.ts"],
21352         ["es2015.reflect", "lib.es2015.reflect.d.ts"],
21353         ["es2015.symbol", "lib.es2015.symbol.d.ts"],
21354         ["es2015.symbol.wellknown", "lib.es2015.symbol.wellknown.d.ts"],
21355         ["es2016.array.include", "lib.es2016.array.include.d.ts"],
21356         ["es2017.object", "lib.es2017.object.d.ts"],
21357         ["es2017.sharedmemory", "lib.es2017.sharedmemory.d.ts"],
21358         ["es2017.string", "lib.es2017.string.d.ts"],
21359         ["es2017.intl", "lib.es2017.intl.d.ts"],
21360         ["es2017.typedarrays", "lib.es2017.typedarrays.d.ts"],
21361         ["es2018.asyncgenerator", "lib.es2018.asyncgenerator.d.ts"],
21362         ["es2018.asynciterable", "lib.es2018.asynciterable.d.ts"],
21363         ["es2018.intl", "lib.es2018.intl.d.ts"],
21364         ["es2018.promise", "lib.es2018.promise.d.ts"],
21365         ["es2018.regexp", "lib.es2018.regexp.d.ts"],
21366         ["es2019.array", "lib.es2019.array.d.ts"],
21367         ["es2019.object", "lib.es2019.object.d.ts"],
21368         ["es2019.string", "lib.es2019.string.d.ts"],
21369         ["es2019.symbol", "lib.es2019.symbol.d.ts"],
21370         ["es2020.bigint", "lib.es2020.bigint.d.ts"],
21371         ["es2020.promise", "lib.es2020.promise.d.ts"],
21372         ["es2020.string", "lib.es2020.string.d.ts"],
21373         ["es2020.symbol.wellknown", "lib.es2020.symbol.wellknown.d.ts"],
21374         ["esnext.array", "lib.es2019.array.d.ts"],
21375         ["esnext.symbol", "lib.es2019.symbol.d.ts"],
21376         ["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"],
21377         ["esnext.intl", "lib.esnext.intl.d.ts"],
21378         ["esnext.bigint", "lib.es2020.bigint.d.ts"],
21379         ["esnext.string", "lib.esnext.string.d.ts"],
21380         ["esnext.promise", "lib.esnext.promise.d.ts"]
21381     ];
21382     ts.libs = libEntries.map(function (entry) { return entry[0]; });
21383     ts.libMap = ts.createMapFromEntries(libEntries);
21384     ts.optionsForWatch = [
21385         {
21386             name: "watchFile",
21387             type: ts.createMapFromTemplate({
21388                 fixedpollinginterval: ts.WatchFileKind.FixedPollingInterval,
21389                 prioritypollinginterval: ts.WatchFileKind.PriorityPollingInterval,
21390                 dynamicprioritypolling: ts.WatchFileKind.DynamicPriorityPolling,
21391                 usefsevents: ts.WatchFileKind.UseFsEvents,
21392                 usefseventsonparentdirectory: ts.WatchFileKind.UseFsEventsOnParentDirectory,
21393             }),
21394             category: ts.Diagnostics.Advanced_Options,
21395             description: ts.Diagnostics.Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_UseFsEvents_UseFsEventsOnParentDirectory,
21396         },
21397         {
21398             name: "watchDirectory",
21399             type: ts.createMapFromTemplate({
21400                 usefsevents: ts.WatchDirectoryKind.UseFsEvents,
21401                 fixedpollinginterval: ts.WatchDirectoryKind.FixedPollingInterval,
21402                 dynamicprioritypolling: ts.WatchDirectoryKind.DynamicPriorityPolling,
21403             }),
21404             category: ts.Diagnostics.Advanced_Options,
21405             description: ts.Diagnostics.Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling,
21406         },
21407         {
21408             name: "fallbackPolling",
21409             type: ts.createMapFromTemplate({
21410                 fixedinterval: ts.PollingWatchKind.FixedInterval,
21411                 priorityinterval: ts.PollingWatchKind.PriorityInterval,
21412                 dynamicpriority: ts.PollingWatchKind.DynamicPriority,
21413             }),
21414             category: ts.Diagnostics.Advanced_Options,
21415             description: ts.Diagnostics.Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority,
21416         },
21417         {
21418             name: "synchronousWatchDirectory",
21419             type: "boolean",
21420             category: ts.Diagnostics.Advanced_Options,
21421             description: ts.Diagnostics.Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively,
21422         },
21423     ];
21424     ts.commonOptionsWithBuild = [
21425         {
21426             name: "help",
21427             shortName: "h",
21428             type: "boolean",
21429             showInSimplifiedHelpView: true,
21430             category: ts.Diagnostics.Command_line_Options,
21431             description: ts.Diagnostics.Print_this_message,
21432         },
21433         {
21434             name: "help",
21435             shortName: "?",
21436             type: "boolean"
21437         },
21438         {
21439             name: "watch",
21440             shortName: "w",
21441             type: "boolean",
21442             showInSimplifiedHelpView: true,
21443             category: ts.Diagnostics.Command_line_Options,
21444             description: ts.Diagnostics.Watch_input_files,
21445         },
21446         {
21447             name: "preserveWatchOutput",
21448             type: "boolean",
21449             showInSimplifiedHelpView: false,
21450             category: ts.Diagnostics.Command_line_Options,
21451             description: ts.Diagnostics.Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen,
21452         },
21453         {
21454             name: "listFiles",
21455             type: "boolean",
21456             category: ts.Diagnostics.Advanced_Options,
21457             description: ts.Diagnostics.Print_names_of_files_part_of_the_compilation
21458         },
21459         {
21460             name: "listEmittedFiles",
21461             type: "boolean",
21462             category: ts.Diagnostics.Advanced_Options,
21463             description: ts.Diagnostics.Print_names_of_generated_files_part_of_the_compilation
21464         },
21465         {
21466             name: "pretty",
21467             type: "boolean",
21468             showInSimplifiedHelpView: true,
21469             category: ts.Diagnostics.Command_line_Options,
21470             description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental
21471         },
21472         {
21473             name: "traceResolution",
21474             type: "boolean",
21475             category: ts.Diagnostics.Advanced_Options,
21476             description: ts.Diagnostics.Enable_tracing_of_the_name_resolution_process
21477         },
21478         {
21479             name: "diagnostics",
21480             type: "boolean",
21481             category: ts.Diagnostics.Advanced_Options,
21482             description: ts.Diagnostics.Show_diagnostic_information
21483         },
21484         {
21485             name: "extendedDiagnostics",
21486             type: "boolean",
21487             category: ts.Diagnostics.Advanced_Options,
21488             description: ts.Diagnostics.Show_verbose_diagnostic_information
21489         },
21490         {
21491             name: "generateCpuProfile",
21492             type: "string",
21493             isFilePath: true,
21494             paramType: ts.Diagnostics.FILE_OR_DIRECTORY,
21495             category: ts.Diagnostics.Advanced_Options,
21496             description: ts.Diagnostics.Generates_a_CPU_profile
21497         },
21498         {
21499             name: "incremental",
21500             shortName: "i",
21501             type: "boolean",
21502             category: ts.Diagnostics.Basic_Options,
21503             description: ts.Diagnostics.Enable_incremental_compilation,
21504             transpileOptionValue: undefined
21505         },
21506         {
21507             name: "assumeChangesOnlyAffectDirectDependencies",
21508             type: "boolean",
21509             affectsSemanticDiagnostics: true,
21510             affectsEmit: true,
21511             category: ts.Diagnostics.Advanced_Options,
21512             description: ts.Diagnostics.Have_recompiles_in_incremental_and_watch_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it
21513         },
21514         {
21515             name: "locale",
21516             type: "string",
21517             category: ts.Diagnostics.Advanced_Options,
21518             description: ts.Diagnostics.The_locale_used_when_displaying_messages_to_the_user_e_g_en_us
21519         },
21520     ];
21521     ts.optionDeclarations = __spreadArrays(ts.commonOptionsWithBuild, [
21522         {
21523             name: "all",
21524             type: "boolean",
21525             showInSimplifiedHelpView: true,
21526             category: ts.Diagnostics.Command_line_Options,
21527             description: ts.Diagnostics.Show_all_compiler_options,
21528         },
21529         {
21530             name: "version",
21531             shortName: "v",
21532             type: "boolean",
21533             showInSimplifiedHelpView: true,
21534             category: ts.Diagnostics.Command_line_Options,
21535             description: ts.Diagnostics.Print_the_compiler_s_version,
21536         },
21537         {
21538             name: "init",
21539             type: "boolean",
21540             showInSimplifiedHelpView: true,
21541             category: ts.Diagnostics.Command_line_Options,
21542             description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file,
21543         },
21544         {
21545             name: "project",
21546             shortName: "p",
21547             type: "string",
21548             isFilePath: true,
21549             showInSimplifiedHelpView: true,
21550             category: ts.Diagnostics.Command_line_Options,
21551             paramType: ts.Diagnostics.FILE_OR_DIRECTORY,
21552             description: ts.Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json,
21553         },
21554         {
21555             name: "build",
21556             type: "boolean",
21557             shortName: "b",
21558             showInSimplifiedHelpView: true,
21559             category: ts.Diagnostics.Command_line_Options,
21560             description: ts.Diagnostics.Build_one_or_more_projects_and_their_dependencies_if_out_of_date
21561         },
21562         {
21563             name: "showConfig",
21564             type: "boolean",
21565             category: ts.Diagnostics.Command_line_Options,
21566             isCommandLineOnly: true,
21567             description: ts.Diagnostics.Print_the_final_configuration_instead_of_building
21568         },
21569         {
21570             name: "listFilesOnly",
21571             type: "boolean",
21572             category: ts.Diagnostics.Command_line_Options,
21573             affectsSemanticDiagnostics: true,
21574             affectsEmit: true,
21575             isCommandLineOnly: true,
21576             description: ts.Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing
21577         },
21578         {
21579             name: "target",
21580             shortName: "t",
21581             type: ts.createMapFromTemplate({
21582                 es3: 0,
21583                 es5: 1,
21584                 es6: 2,
21585                 es2015: 2,
21586                 es2016: 3,
21587                 es2017: 4,
21588                 es2018: 5,
21589                 es2019: 6,
21590                 es2020: 7,
21591                 esnext: 99,
21592             }),
21593             affectsSourceFile: true,
21594             affectsModuleResolution: true,
21595             affectsEmit: true,
21596             paramType: ts.Diagnostics.VERSION,
21597             showInSimplifiedHelpView: true,
21598             category: ts.Diagnostics.Basic_Options,
21599             description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_or_ESNEXT,
21600         },
21601         {
21602             name: "module",
21603             shortName: "m",
21604             type: ts.createMapFromTemplate({
21605                 none: ts.ModuleKind.None,
21606                 commonjs: ts.ModuleKind.CommonJS,
21607                 amd: ts.ModuleKind.AMD,
21608                 system: ts.ModuleKind.System,
21609                 umd: ts.ModuleKind.UMD,
21610                 es6: ts.ModuleKind.ES2015,
21611                 es2015: ts.ModuleKind.ES2015,
21612                 es2020: ts.ModuleKind.ES2020,
21613                 esnext: ts.ModuleKind.ESNext
21614             }),
21615             affectsModuleResolution: true,
21616             affectsEmit: true,
21617             paramType: ts.Diagnostics.KIND,
21618             showInSimplifiedHelpView: true,
21619             category: ts.Diagnostics.Basic_Options,
21620             description: ts.Diagnostics.Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_es2020_or_ESNext,
21621         },
21622         {
21623             name: "lib",
21624             type: "list",
21625             element: {
21626                 name: "lib",
21627                 type: ts.libMap
21628             },
21629             affectsModuleResolution: true,
21630             showInSimplifiedHelpView: true,
21631             category: ts.Diagnostics.Basic_Options,
21632             description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation,
21633             transpileOptionValue: undefined
21634         },
21635         {
21636             name: "allowJs",
21637             type: "boolean",
21638             affectsModuleResolution: true,
21639             showInSimplifiedHelpView: true,
21640             category: ts.Diagnostics.Basic_Options,
21641             description: ts.Diagnostics.Allow_javascript_files_to_be_compiled
21642         },
21643         {
21644             name: "checkJs",
21645             type: "boolean",
21646             category: ts.Diagnostics.Basic_Options,
21647             description: ts.Diagnostics.Report_errors_in_js_files
21648         },
21649         {
21650             name: "jsx",
21651             type: ts.createMapFromTemplate({
21652                 "preserve": 1,
21653                 "react-native": 3,
21654                 "react": 2
21655             }),
21656             affectsSourceFile: true,
21657             paramType: ts.Diagnostics.KIND,
21658             showInSimplifiedHelpView: true,
21659             category: ts.Diagnostics.Basic_Options,
21660             description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react,
21661         },
21662         {
21663             name: "declaration",
21664             shortName: "d",
21665             type: "boolean",
21666             affectsEmit: true,
21667             showInSimplifiedHelpView: true,
21668             category: ts.Diagnostics.Basic_Options,
21669             description: ts.Diagnostics.Generates_corresponding_d_ts_file,
21670             transpileOptionValue: undefined
21671         },
21672         {
21673             name: "declarationMap",
21674             type: "boolean",
21675             affectsEmit: true,
21676             showInSimplifiedHelpView: true,
21677             category: ts.Diagnostics.Basic_Options,
21678             description: ts.Diagnostics.Generates_a_sourcemap_for_each_corresponding_d_ts_file,
21679             transpileOptionValue: undefined
21680         },
21681         {
21682             name: "emitDeclarationOnly",
21683             type: "boolean",
21684             affectsEmit: true,
21685             category: ts.Diagnostics.Advanced_Options,
21686             description: ts.Diagnostics.Only_emit_d_ts_declaration_files,
21687             transpileOptionValue: undefined
21688         },
21689         {
21690             name: "sourceMap",
21691             type: "boolean",
21692             affectsEmit: true,
21693             showInSimplifiedHelpView: true,
21694             category: ts.Diagnostics.Basic_Options,
21695             description: ts.Diagnostics.Generates_corresponding_map_file,
21696         },
21697         {
21698             name: "outFile",
21699             type: "string",
21700             affectsEmit: true,
21701             isFilePath: true,
21702             paramType: ts.Diagnostics.FILE,
21703             showInSimplifiedHelpView: true,
21704             category: ts.Diagnostics.Basic_Options,
21705             description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file,
21706             transpileOptionValue: undefined
21707         },
21708         {
21709             name: "outDir",
21710             type: "string",
21711             affectsEmit: true,
21712             isFilePath: true,
21713             paramType: ts.Diagnostics.DIRECTORY,
21714             showInSimplifiedHelpView: true,
21715             category: ts.Diagnostics.Basic_Options,
21716             description: ts.Diagnostics.Redirect_output_structure_to_the_directory,
21717         },
21718         {
21719             name: "rootDir",
21720             type: "string",
21721             affectsEmit: true,
21722             isFilePath: true,
21723             paramType: ts.Diagnostics.LOCATION,
21724             category: ts.Diagnostics.Basic_Options,
21725             description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir,
21726         },
21727         {
21728             name: "composite",
21729             type: "boolean",
21730             affectsEmit: true,
21731             isTSConfigOnly: true,
21732             category: ts.Diagnostics.Basic_Options,
21733             description: ts.Diagnostics.Enable_project_compilation,
21734             transpileOptionValue: undefined
21735         },
21736         {
21737             name: "tsBuildInfoFile",
21738             type: "string",
21739             affectsEmit: true,
21740             isFilePath: true,
21741             paramType: ts.Diagnostics.FILE,
21742             category: ts.Diagnostics.Basic_Options,
21743             description: ts.Diagnostics.Specify_file_to_store_incremental_compilation_information,
21744             transpileOptionValue: undefined
21745         },
21746         {
21747             name: "removeComments",
21748             type: "boolean",
21749             affectsEmit: true,
21750             showInSimplifiedHelpView: true,
21751             category: ts.Diagnostics.Basic_Options,
21752             description: ts.Diagnostics.Do_not_emit_comments_to_output,
21753         },
21754         {
21755             name: "noEmit",
21756             type: "boolean",
21757             affectsEmit: true,
21758             showInSimplifiedHelpView: true,
21759             category: ts.Diagnostics.Basic_Options,
21760             description: ts.Diagnostics.Do_not_emit_outputs,
21761             transpileOptionValue: undefined
21762         },
21763         {
21764             name: "importHelpers",
21765             type: "boolean",
21766             affectsEmit: true,
21767             category: ts.Diagnostics.Basic_Options,
21768             description: ts.Diagnostics.Import_emit_helpers_from_tslib
21769         },
21770         {
21771             name: "importsNotUsedAsValues",
21772             type: ts.createMapFromTemplate({
21773                 remove: 0,
21774                 preserve: 1,
21775                 error: 2
21776             }),
21777             affectsEmit: true,
21778             affectsSemanticDiagnostics: true,
21779             category: ts.Diagnostics.Advanced_Options,
21780             description: ts.Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types
21781         },
21782         {
21783             name: "downlevelIteration",
21784             type: "boolean",
21785             affectsEmit: true,
21786             category: ts.Diagnostics.Basic_Options,
21787             description: ts.Diagnostics.Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3
21788         },
21789         {
21790             name: "isolatedModules",
21791             type: "boolean",
21792             category: ts.Diagnostics.Basic_Options,
21793             description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule,
21794             transpileOptionValue: true
21795         },
21796         {
21797             name: "strict",
21798             type: "boolean",
21799             showInSimplifiedHelpView: true,
21800             category: ts.Diagnostics.Strict_Type_Checking_Options,
21801             description: ts.Diagnostics.Enable_all_strict_type_checking_options
21802         },
21803         {
21804             name: "noImplicitAny",
21805             type: "boolean",
21806             affectsSemanticDiagnostics: true,
21807             strictFlag: true,
21808             showInSimplifiedHelpView: true,
21809             category: ts.Diagnostics.Strict_Type_Checking_Options,
21810             description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type
21811         },
21812         {
21813             name: "strictNullChecks",
21814             type: "boolean",
21815             affectsSemanticDiagnostics: true,
21816             strictFlag: true,
21817             showInSimplifiedHelpView: true,
21818             category: ts.Diagnostics.Strict_Type_Checking_Options,
21819             description: ts.Diagnostics.Enable_strict_null_checks
21820         },
21821         {
21822             name: "strictFunctionTypes",
21823             type: "boolean",
21824             affectsSemanticDiagnostics: true,
21825             strictFlag: true,
21826             showInSimplifiedHelpView: true,
21827             category: ts.Diagnostics.Strict_Type_Checking_Options,
21828             description: ts.Diagnostics.Enable_strict_checking_of_function_types
21829         },
21830         {
21831             name: "strictBindCallApply",
21832             type: "boolean",
21833             strictFlag: true,
21834             showInSimplifiedHelpView: true,
21835             category: ts.Diagnostics.Strict_Type_Checking_Options,
21836             description: ts.Diagnostics.Enable_strict_bind_call_and_apply_methods_on_functions
21837         },
21838         {
21839             name: "strictPropertyInitialization",
21840             type: "boolean",
21841             affectsSemanticDiagnostics: true,
21842             strictFlag: true,
21843             showInSimplifiedHelpView: true,
21844             category: ts.Diagnostics.Strict_Type_Checking_Options,
21845             description: ts.Diagnostics.Enable_strict_checking_of_property_initialization_in_classes
21846         },
21847         {
21848             name: "noImplicitThis",
21849             type: "boolean",
21850             affectsSemanticDiagnostics: true,
21851             strictFlag: true,
21852             showInSimplifiedHelpView: true,
21853             category: ts.Diagnostics.Strict_Type_Checking_Options,
21854             description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type,
21855         },
21856         {
21857             name: "alwaysStrict",
21858             type: "boolean",
21859             affectsSourceFile: true,
21860             strictFlag: true,
21861             showInSimplifiedHelpView: true,
21862             category: ts.Diagnostics.Strict_Type_Checking_Options,
21863             description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file
21864         },
21865         {
21866             name: "noUnusedLocals",
21867             type: "boolean",
21868             affectsSemanticDiagnostics: true,
21869             showInSimplifiedHelpView: true,
21870             category: ts.Diagnostics.Additional_Checks,
21871             description: ts.Diagnostics.Report_errors_on_unused_locals,
21872         },
21873         {
21874             name: "noUnusedParameters",
21875             type: "boolean",
21876             affectsSemanticDiagnostics: true,
21877             showInSimplifiedHelpView: true,
21878             category: ts.Diagnostics.Additional_Checks,
21879             description: ts.Diagnostics.Report_errors_on_unused_parameters,
21880         },
21881         {
21882             name: "noImplicitReturns",
21883             type: "boolean",
21884             affectsSemanticDiagnostics: true,
21885             showInSimplifiedHelpView: true,
21886             category: ts.Diagnostics.Additional_Checks,
21887             description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value
21888         },
21889         {
21890             name: "noFallthroughCasesInSwitch",
21891             type: "boolean",
21892             affectsBindDiagnostics: true,
21893             affectsSemanticDiagnostics: true,
21894             showInSimplifiedHelpView: true,
21895             category: ts.Diagnostics.Additional_Checks,
21896             description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement
21897         },
21898         {
21899             name: "moduleResolution",
21900             type: ts.createMapFromTemplate({
21901                 node: ts.ModuleResolutionKind.NodeJs,
21902                 classic: ts.ModuleResolutionKind.Classic,
21903             }),
21904             affectsModuleResolution: true,
21905             paramType: ts.Diagnostics.STRATEGY,
21906             category: ts.Diagnostics.Module_Resolution_Options,
21907             description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6,
21908         },
21909         {
21910             name: "baseUrl",
21911             type: "string",
21912             affectsModuleResolution: true,
21913             isFilePath: true,
21914             category: ts.Diagnostics.Module_Resolution_Options,
21915             description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names
21916         },
21917         {
21918             name: "paths",
21919             type: "object",
21920             affectsModuleResolution: true,
21921             isTSConfigOnly: true,
21922             category: ts.Diagnostics.Module_Resolution_Options,
21923             description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl,
21924             transpileOptionValue: undefined
21925         },
21926         {
21927             name: "rootDirs",
21928             type: "list",
21929             isTSConfigOnly: true,
21930             element: {
21931                 name: "rootDirs",
21932                 type: "string",
21933                 isFilePath: true
21934             },
21935             affectsModuleResolution: true,
21936             category: ts.Diagnostics.Module_Resolution_Options,
21937             description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime,
21938             transpileOptionValue: undefined
21939         },
21940         {
21941             name: "typeRoots",
21942             type: "list",
21943             element: {
21944                 name: "typeRoots",
21945                 type: "string",
21946                 isFilePath: true
21947             },
21948             affectsModuleResolution: true,
21949             category: ts.Diagnostics.Module_Resolution_Options,
21950             description: ts.Diagnostics.List_of_folders_to_include_type_definitions_from
21951         },
21952         {
21953             name: "types",
21954             type: "list",
21955             element: {
21956                 name: "types",
21957                 type: "string"
21958             },
21959             affectsModuleResolution: true,
21960             showInSimplifiedHelpView: true,
21961             category: ts.Diagnostics.Module_Resolution_Options,
21962             description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation,
21963             transpileOptionValue: undefined
21964         },
21965         {
21966             name: "allowSyntheticDefaultImports",
21967             type: "boolean",
21968             affectsSemanticDiagnostics: true,
21969             category: ts.Diagnostics.Module_Resolution_Options,
21970             description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking
21971         },
21972         {
21973             name: "esModuleInterop",
21974             type: "boolean",
21975             affectsSemanticDiagnostics: true,
21976             affectsEmit: true,
21977             showInSimplifiedHelpView: true,
21978             category: ts.Diagnostics.Module_Resolution_Options,
21979             description: ts.Diagnostics.Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports
21980         },
21981         {
21982             name: "preserveSymlinks",
21983             type: "boolean",
21984             category: ts.Diagnostics.Module_Resolution_Options,
21985             description: ts.Diagnostics.Do_not_resolve_the_real_path_of_symlinks,
21986         },
21987         {
21988             name: "allowUmdGlobalAccess",
21989             type: "boolean",
21990             affectsSemanticDiagnostics: true,
21991             category: ts.Diagnostics.Module_Resolution_Options,
21992             description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules,
21993         },
21994         {
21995             name: "sourceRoot",
21996             type: "string",
21997             affectsEmit: true,
21998             paramType: ts.Diagnostics.LOCATION,
21999             category: ts.Diagnostics.Source_Map_Options,
22000             description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations,
22001         },
22002         {
22003             name: "mapRoot",
22004             type: "string",
22005             affectsEmit: true,
22006             paramType: ts.Diagnostics.LOCATION,
22007             category: ts.Diagnostics.Source_Map_Options,
22008             description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations,
22009         },
22010         {
22011             name: "inlineSourceMap",
22012             type: "boolean",
22013             affectsEmit: true,
22014             category: ts.Diagnostics.Source_Map_Options,
22015             description: ts.Diagnostics.Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file
22016         },
22017         {
22018             name: "inlineSources",
22019             type: "boolean",
22020             affectsEmit: true,
22021             category: ts.Diagnostics.Source_Map_Options,
22022             description: ts.Diagnostics.Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set
22023         },
22024         {
22025             name: "experimentalDecorators",
22026             type: "boolean",
22027             affectsSemanticDiagnostics: true,
22028             category: ts.Diagnostics.Experimental_Options,
22029             description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators
22030         },
22031         {
22032             name: "emitDecoratorMetadata",
22033             type: "boolean",
22034             affectsSemanticDiagnostics: true,
22035             affectsEmit: true,
22036             category: ts.Diagnostics.Experimental_Options,
22037             description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators
22038         },
22039         {
22040             name: "jsxFactory",
22041             type: "string",
22042             category: ts.Diagnostics.Advanced_Options,
22043             description: ts.Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h
22044         },
22045         {
22046             name: "resolveJsonModule",
22047             type: "boolean",
22048             affectsModuleResolution: true,
22049             category: ts.Diagnostics.Advanced_Options,
22050             description: ts.Diagnostics.Include_modules_imported_with_json_extension
22051         },
22052         {
22053             name: "out",
22054             type: "string",
22055             affectsEmit: true,
22056             isFilePath: false,
22057             category: ts.Diagnostics.Advanced_Options,
22058             paramType: ts.Diagnostics.FILE,
22059             description: ts.Diagnostics.Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file,
22060             transpileOptionValue: undefined
22061         },
22062         {
22063             name: "reactNamespace",
22064             type: "string",
22065             affectsEmit: true,
22066             category: ts.Diagnostics.Advanced_Options,
22067             description: ts.Diagnostics.Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react_JSX_emit
22068         },
22069         {
22070             name: "skipDefaultLibCheck",
22071             type: "boolean",
22072             category: ts.Diagnostics.Advanced_Options,
22073             description: ts.Diagnostics.Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files
22074         },
22075         {
22076             name: "charset",
22077             type: "string",
22078             category: ts.Diagnostics.Advanced_Options,
22079             description: ts.Diagnostics.The_character_set_of_the_input_files
22080         },
22081         {
22082             name: "emitBOM",
22083             type: "boolean",
22084             affectsEmit: true,
22085             category: ts.Diagnostics.Advanced_Options,
22086             description: ts.Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files
22087         },
22088         {
22089             name: "newLine",
22090             type: ts.createMapFromTemplate({
22091                 crlf: 0,
22092                 lf: 1
22093             }),
22094             affectsEmit: true,
22095             paramType: ts.Diagnostics.NEWLINE,
22096             category: ts.Diagnostics.Advanced_Options,
22097             description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix,
22098         },
22099         {
22100             name: "noErrorTruncation",
22101             type: "boolean",
22102             affectsSemanticDiagnostics: true,
22103             category: ts.Diagnostics.Advanced_Options,
22104             description: ts.Diagnostics.Do_not_truncate_error_messages
22105         },
22106         {
22107             name: "noLib",
22108             type: "boolean",
22109             affectsModuleResolution: true,
22110             category: ts.Diagnostics.Advanced_Options,
22111             description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts,
22112             transpileOptionValue: true
22113         },
22114         {
22115             name: "noResolve",
22116             type: "boolean",
22117             affectsModuleResolution: true,
22118             category: ts.Diagnostics.Advanced_Options,
22119             description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files,
22120             transpileOptionValue: true
22121         },
22122         {
22123             name: "stripInternal",
22124             type: "boolean",
22125             affectsEmit: true,
22126             category: ts.Diagnostics.Advanced_Options,
22127             description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation,
22128         },
22129         {
22130             name: "disableSizeLimit",
22131             type: "boolean",
22132             affectsSourceFile: true,
22133             category: ts.Diagnostics.Advanced_Options,
22134             description: ts.Diagnostics.Disable_size_limitations_on_JavaScript_projects
22135         },
22136         {
22137             name: "disableSourceOfProjectReferenceRedirect",
22138             type: "boolean",
22139             isTSConfigOnly: true,
22140             category: ts.Diagnostics.Advanced_Options,
22141             description: ts.Diagnostics.Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects
22142         },
22143         {
22144             name: "disableSolutionSearching",
22145             type: "boolean",
22146             isTSConfigOnly: true,
22147             category: ts.Diagnostics.Advanced_Options,
22148             description: ts.Diagnostics.Disable_solution_searching_for_this_project
22149         },
22150         {
22151             name: "noImplicitUseStrict",
22152             type: "boolean",
22153             affectsSemanticDiagnostics: true,
22154             category: ts.Diagnostics.Advanced_Options,
22155             description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output
22156         },
22157         {
22158             name: "noEmitHelpers",
22159             type: "boolean",
22160             affectsEmit: true,
22161             category: ts.Diagnostics.Advanced_Options,
22162             description: ts.Diagnostics.Do_not_generate_custom_helper_functions_like_extends_in_compiled_output
22163         },
22164         {
22165             name: "noEmitOnError",
22166             type: "boolean",
22167             affectsEmit: true,
22168             category: ts.Diagnostics.Advanced_Options,
22169             description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported,
22170             transpileOptionValue: undefined
22171         },
22172         {
22173             name: "preserveConstEnums",
22174             type: "boolean",
22175             affectsEmit: true,
22176             category: ts.Diagnostics.Advanced_Options,
22177             description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code
22178         },
22179         {
22180             name: "declarationDir",
22181             type: "string",
22182             affectsEmit: true,
22183             isFilePath: true,
22184             paramType: ts.Diagnostics.DIRECTORY,
22185             category: ts.Diagnostics.Advanced_Options,
22186             description: ts.Diagnostics.Output_directory_for_generated_declaration_files,
22187             transpileOptionValue: undefined
22188         },
22189         {
22190             name: "skipLibCheck",
22191             type: "boolean",
22192             category: ts.Diagnostics.Advanced_Options,
22193             description: ts.Diagnostics.Skip_type_checking_of_declaration_files,
22194         },
22195         {
22196             name: "allowUnusedLabels",
22197             type: "boolean",
22198             affectsBindDiagnostics: true,
22199             affectsSemanticDiagnostics: true,
22200             category: ts.Diagnostics.Advanced_Options,
22201             description: ts.Diagnostics.Do_not_report_errors_on_unused_labels
22202         },
22203         {
22204             name: "allowUnreachableCode",
22205             type: "boolean",
22206             affectsBindDiagnostics: true,
22207             affectsSemanticDiagnostics: true,
22208             category: ts.Diagnostics.Advanced_Options,
22209             description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code
22210         },
22211         {
22212             name: "suppressExcessPropertyErrors",
22213             type: "boolean",
22214             affectsSemanticDiagnostics: true,
22215             category: ts.Diagnostics.Advanced_Options,
22216             description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals,
22217         },
22218         {
22219             name: "suppressImplicitAnyIndexErrors",
22220             type: "boolean",
22221             affectsSemanticDiagnostics: true,
22222             category: ts.Diagnostics.Advanced_Options,
22223             description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures,
22224         },
22225         {
22226             name: "forceConsistentCasingInFileNames",
22227             type: "boolean",
22228             affectsModuleResolution: true,
22229             category: ts.Diagnostics.Advanced_Options,
22230             description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file
22231         },
22232         {
22233             name: "maxNodeModuleJsDepth",
22234             type: "number",
22235             affectsModuleResolution: true,
22236             category: ts.Diagnostics.Advanced_Options,
22237             description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files
22238         },
22239         {
22240             name: "noStrictGenericChecks",
22241             type: "boolean",
22242             affectsSemanticDiagnostics: true,
22243             category: ts.Diagnostics.Advanced_Options,
22244             description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types,
22245         },
22246         {
22247             name: "useDefineForClassFields",
22248             type: "boolean",
22249             affectsSemanticDiagnostics: true,
22250             affectsEmit: true,
22251             category: ts.Diagnostics.Advanced_Options,
22252             description: ts.Diagnostics.Emit_class_fields_with_Define_instead_of_Set,
22253         },
22254         {
22255             name: "keyofStringsOnly",
22256             type: "boolean",
22257             category: ts.Diagnostics.Advanced_Options,
22258             description: ts.Diagnostics.Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols,
22259         },
22260         {
22261             name: "plugins",
22262             type: "list",
22263             isTSConfigOnly: true,
22264             element: {
22265                 name: "plugin",
22266                 type: "object"
22267             },
22268             description: ts.Diagnostics.List_of_language_service_plugins
22269         },
22270     ]);
22271     ts.semanticDiagnosticsOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsSemanticDiagnostics; });
22272     ts.affectsEmitOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsEmit; });
22273     ts.moduleResolutionOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsModuleResolution; });
22274     ts.sourceFileAffectingCompilerOptions = ts.optionDeclarations.filter(function (option) {
22275         return !!option.affectsSourceFile || !!option.affectsModuleResolution || !!option.affectsBindDiagnostics;
22276     });
22277     ts.transpileOptionValueCompilerOptions = ts.optionDeclarations.filter(function (option) {
22278         return ts.hasProperty(option, "transpileOptionValue");
22279     });
22280     ts.buildOpts = __spreadArrays(ts.commonOptionsWithBuild, [
22281         {
22282             name: "verbose",
22283             shortName: "v",
22284             category: ts.Diagnostics.Command_line_Options,
22285             description: ts.Diagnostics.Enable_verbose_logging,
22286             type: "boolean"
22287         },
22288         {
22289             name: "dry",
22290             shortName: "d",
22291             category: ts.Diagnostics.Command_line_Options,
22292             description: ts.Diagnostics.Show_what_would_be_built_or_deleted_if_specified_with_clean,
22293             type: "boolean"
22294         },
22295         {
22296             name: "force",
22297             shortName: "f",
22298             category: ts.Diagnostics.Command_line_Options,
22299             description: ts.Diagnostics.Build_all_projects_including_those_that_appear_to_be_up_to_date,
22300             type: "boolean"
22301         },
22302         {
22303             name: "clean",
22304             category: ts.Diagnostics.Command_line_Options,
22305             description: ts.Diagnostics.Delete_the_outputs_of_all_projects,
22306             type: "boolean"
22307         }
22308     ]);
22309     ts.typeAcquisitionDeclarations = [
22310         {
22311             name: "enableAutoDiscovery",
22312             type: "boolean",
22313         },
22314         {
22315             name: "enable",
22316             type: "boolean",
22317         },
22318         {
22319             name: "include",
22320             type: "list",
22321             element: {
22322                 name: "include",
22323                 type: "string"
22324             }
22325         },
22326         {
22327             name: "exclude",
22328             type: "list",
22329             element: {
22330                 name: "exclude",
22331                 type: "string"
22332             }
22333         }
22334     ];
22335     function createOptionNameMap(optionDeclarations) {
22336         var optionsNameMap = ts.createMap();
22337         var shortOptionNames = ts.createMap();
22338         ts.forEach(optionDeclarations, function (option) {
22339             optionsNameMap.set(option.name.toLowerCase(), option);
22340             if (option.shortName) {
22341                 shortOptionNames.set(option.shortName, option.name);
22342             }
22343         });
22344         return { optionsNameMap: optionsNameMap, shortOptionNames: shortOptionNames };
22345     }
22346     ts.createOptionNameMap = createOptionNameMap;
22347     var optionsNameMapCache;
22348     function getOptionsNameMap() {
22349         return optionsNameMapCache || (optionsNameMapCache = createOptionNameMap(ts.optionDeclarations));
22350     }
22351     ts.getOptionsNameMap = getOptionsNameMap;
22352     ts.defaultInitCompilerOptions = {
22353         module: ts.ModuleKind.CommonJS,
22354         target: 1,
22355         strict: true,
22356         esModuleInterop: true,
22357         forceConsistentCasingInFileNames: true,
22358         skipLibCheck: true
22359     };
22360     function convertEnableAutoDiscoveryToEnable(typeAcquisition) {
22361         if (typeAcquisition && typeAcquisition.enableAutoDiscovery !== undefined && typeAcquisition.enable === undefined) {
22362             return {
22363                 enable: typeAcquisition.enableAutoDiscovery,
22364                 include: typeAcquisition.include || [],
22365                 exclude: typeAcquisition.exclude || []
22366             };
22367         }
22368         return typeAcquisition;
22369     }
22370     ts.convertEnableAutoDiscoveryToEnable = convertEnableAutoDiscoveryToEnable;
22371     function createCompilerDiagnosticForInvalidCustomType(opt) {
22372         return createDiagnosticForInvalidCustomType(opt, ts.createCompilerDiagnostic);
22373     }
22374     ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType;
22375     function createDiagnosticForInvalidCustomType(opt, createDiagnostic) {
22376         var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'" + key + "'"; }).join(", ");
22377         return createDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType);
22378     }
22379     function parseCustomTypeOption(opt, value, errors) {
22380         return convertJsonOptionOfCustomType(opt, trimString(value || ""), errors);
22381     }
22382     ts.parseCustomTypeOption = parseCustomTypeOption;
22383     function parseListTypeOption(opt, value, errors) {
22384         if (value === void 0) { value = ""; }
22385         value = trimString(value);
22386         if (ts.startsWith(value, "-")) {
22387             return undefined;
22388         }
22389         if (value === "") {
22390             return [];
22391         }
22392         var values = value.split(",");
22393         switch (opt.element.type) {
22394             case "number":
22395                 return ts.map(values, parseInt);
22396             case "string":
22397                 return ts.map(values, function (v) { return v || ""; });
22398             default:
22399                 return ts.mapDefined(values, function (v) { return parseCustomTypeOption(opt.element, v, errors); });
22400         }
22401     }
22402     ts.parseListTypeOption = parseListTypeOption;
22403     function getOptionName(option) {
22404         return option.name;
22405     }
22406     function createUnknownOptionError(unknownOption, diagnostics, createDiagnostics, unknownOptionErrorText) {
22407         var possibleOption = ts.getSpellingSuggestion(unknownOption, diagnostics.optionDeclarations, getOptionName);
22408         return possibleOption ?
22409             createDiagnostics(diagnostics.unknownDidYouMeanDiagnostic, unknownOptionErrorText || unknownOption, possibleOption.name) :
22410             createDiagnostics(diagnostics.unknownOptionDiagnostic, unknownOptionErrorText || unknownOption);
22411     }
22412     function parseCommandLineWorker(diagnostics, commandLine, readFile) {
22413         var options = {};
22414         var watchOptions;
22415         var fileNames = [];
22416         var errors = [];
22417         parseStrings(commandLine);
22418         return {
22419             options: options,
22420             watchOptions: watchOptions,
22421             fileNames: fileNames,
22422             errors: errors
22423         };
22424         function parseStrings(args) {
22425             var i = 0;
22426             while (i < args.length) {
22427                 var s = args[i];
22428                 i++;
22429                 if (s.charCodeAt(0) === 64) {
22430                     parseResponseFile(s.slice(1));
22431                 }
22432                 else if (s.charCodeAt(0) === 45) {
22433                     var inputOptionName = s.slice(s.charCodeAt(1) === 45 ? 2 : 1);
22434                     var opt = getOptionDeclarationFromName(diagnostics.getOptionsNameMap, inputOptionName, true);
22435                     if (opt) {
22436                         i = parseOptionValue(args, i, diagnostics, opt, options, errors);
22437                     }
22438                     else {
22439                         var watchOpt = getOptionDeclarationFromName(watchOptionsDidYouMeanDiagnostics.getOptionsNameMap, inputOptionName, true);
22440                         if (watchOpt) {
22441                             i = parseOptionValue(args, i, watchOptionsDidYouMeanDiagnostics, watchOpt, watchOptions || (watchOptions = {}), errors);
22442                         }
22443                         else {
22444                             errors.push(createUnknownOptionError(inputOptionName, diagnostics, ts.createCompilerDiagnostic, s));
22445                         }
22446                     }
22447                 }
22448                 else {
22449                     fileNames.push(s);
22450                 }
22451             }
22452         }
22453         function parseResponseFile(fileName) {
22454             var text = tryReadFile(fileName, readFile || (function (fileName) { return ts.sys.readFile(fileName); }));
22455             if (!ts.isString(text)) {
22456                 errors.push(text);
22457                 return;
22458             }
22459             var args = [];
22460             var pos = 0;
22461             while (true) {
22462                 while (pos < text.length && text.charCodeAt(pos) <= 32)
22463                     pos++;
22464                 if (pos >= text.length)
22465                     break;
22466                 var start = pos;
22467                 if (text.charCodeAt(start) === 34) {
22468                     pos++;
22469                     while (pos < text.length && text.charCodeAt(pos) !== 34)
22470                         pos++;
22471                     if (pos < text.length) {
22472                         args.push(text.substring(start + 1, pos));
22473                         pos++;
22474                     }
22475                     else {
22476                         errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unterminated_quoted_string_in_response_file_0, fileName));
22477                     }
22478                 }
22479                 else {
22480                     while (text.charCodeAt(pos) > 32)
22481                         pos++;
22482                     args.push(text.substring(start, pos));
22483                 }
22484             }
22485             parseStrings(args);
22486         }
22487     }
22488     ts.parseCommandLineWorker = parseCommandLineWorker;
22489     function parseOptionValue(args, i, diagnostics, opt, options, errors) {
22490         if (opt.isTSConfigOnly) {
22491             var optValue = args[i];
22492             if (optValue === "null") {
22493                 options[opt.name] = undefined;
22494                 i++;
22495             }
22496             else if (opt.type === "boolean") {
22497                 if (optValue === "false") {
22498                     options[opt.name] = false;
22499                     i++;
22500                 }
22501                 else {
22502                     if (optValue === "true")
22503                         i++;
22504                     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));
22505                 }
22506             }
22507             else {
22508                 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));
22509                 if (optValue && !ts.startsWith(optValue, "-"))
22510                     i++;
22511             }
22512         }
22513         else {
22514             if (!args[i] && opt.type !== "boolean") {
22515                 errors.push(ts.createCompilerDiagnostic(diagnostics.optionTypeMismatchDiagnostic, opt.name, getCompilerOptionValueTypeString(opt)));
22516             }
22517             if (args[i] !== "null") {
22518                 switch (opt.type) {
22519                     case "number":
22520                         options[opt.name] = parseInt(args[i]);
22521                         i++;
22522                         break;
22523                     case "boolean":
22524                         var optValue = args[i];
22525                         options[opt.name] = optValue !== "false";
22526                         if (optValue === "false" || optValue === "true") {
22527                             i++;
22528                         }
22529                         break;
22530                     case "string":
22531                         options[opt.name] = args[i] || "";
22532                         i++;
22533                         break;
22534                     case "list":
22535                         var result = parseListTypeOption(opt, args[i], errors);
22536                         options[opt.name] = result || [];
22537                         if (result) {
22538                             i++;
22539                         }
22540                         break;
22541                     default:
22542                         options[opt.name] = parseCustomTypeOption(opt, args[i], errors);
22543                         i++;
22544                         break;
22545                 }
22546             }
22547             else {
22548                 options[opt.name] = undefined;
22549                 i++;
22550             }
22551         }
22552         return i;
22553     }
22554     ts.compilerOptionsDidYouMeanDiagnostics = {
22555         getOptionsNameMap: getOptionsNameMap,
22556         optionDeclarations: ts.optionDeclarations,
22557         unknownOptionDiagnostic: ts.Diagnostics.Unknown_compiler_option_0,
22558         unknownDidYouMeanDiagnostic: ts.Diagnostics.Unknown_compiler_option_0_Did_you_mean_1,
22559         optionTypeMismatchDiagnostic: ts.Diagnostics.Compiler_option_0_expects_an_argument
22560     };
22561     function parseCommandLine(commandLine, readFile) {
22562         return parseCommandLineWorker(ts.compilerOptionsDidYouMeanDiagnostics, commandLine, readFile);
22563     }
22564     ts.parseCommandLine = parseCommandLine;
22565     function getOptionFromName(optionName, allowShort) {
22566         return getOptionDeclarationFromName(getOptionsNameMap, optionName, allowShort);
22567     }
22568     ts.getOptionFromName = getOptionFromName;
22569     function getOptionDeclarationFromName(getOptionNameMap, optionName, allowShort) {
22570         if (allowShort === void 0) { allowShort = false; }
22571         optionName = optionName.toLowerCase();
22572         var _a = getOptionNameMap(), optionsNameMap = _a.optionsNameMap, shortOptionNames = _a.shortOptionNames;
22573         if (allowShort) {
22574             var short = shortOptionNames.get(optionName);
22575             if (short !== undefined) {
22576                 optionName = short;
22577             }
22578         }
22579         return optionsNameMap.get(optionName);
22580     }
22581     var buildOptionsNameMapCache;
22582     function getBuildOptionsNameMap() {
22583         return buildOptionsNameMapCache || (buildOptionsNameMapCache = createOptionNameMap(ts.buildOpts));
22584     }
22585     var buildOptionsDidYouMeanDiagnostics = {
22586         getOptionsNameMap: getBuildOptionsNameMap,
22587         optionDeclarations: ts.buildOpts,
22588         unknownOptionDiagnostic: ts.Diagnostics.Unknown_build_option_0,
22589         unknownDidYouMeanDiagnostic: ts.Diagnostics.Unknown_build_option_0_Did_you_mean_1,
22590         optionTypeMismatchDiagnostic: ts.Diagnostics.Build_option_0_requires_a_value_of_type_1
22591     };
22592     function parseBuildCommand(args) {
22593         var _a = parseCommandLineWorker(buildOptionsDidYouMeanDiagnostics, args), options = _a.options, watchOptions = _a.watchOptions, projects = _a.fileNames, errors = _a.errors;
22594         var buildOptions = options;
22595         if (projects.length === 0) {
22596             projects.push(".");
22597         }
22598         if (buildOptions.clean && buildOptions.force) {
22599             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Options_0_and_1_cannot_be_combined, "clean", "force"));
22600         }
22601         if (buildOptions.clean && buildOptions.verbose) {
22602             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Options_0_and_1_cannot_be_combined, "clean", "verbose"));
22603         }
22604         if (buildOptions.clean && buildOptions.watch) {
22605             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Options_0_and_1_cannot_be_combined, "clean", "watch"));
22606         }
22607         if (buildOptions.watch && buildOptions.dry) {
22608             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Options_0_and_1_cannot_be_combined, "watch", "dry"));
22609         }
22610         return { buildOptions: buildOptions, watchOptions: watchOptions, projects: projects, errors: errors };
22611     }
22612     ts.parseBuildCommand = parseBuildCommand;
22613     function getDiagnosticText(_message) {
22614         var _args = [];
22615         for (var _i = 1; _i < arguments.length; _i++) {
22616             _args[_i - 1] = arguments[_i];
22617         }
22618         var diagnostic = ts.createCompilerDiagnostic.apply(undefined, arguments);
22619         return diagnostic.messageText;
22620     }
22621     ts.getDiagnosticText = getDiagnosticText;
22622     function getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host, extendedConfigCache, watchOptionsToExtend, extraFileExtensions) {
22623         var configFileText = tryReadFile(configFileName, function (fileName) { return host.readFile(fileName); });
22624         if (!ts.isString(configFileText)) {
22625             host.onUnRecoverableConfigFileDiagnostic(configFileText);
22626             return undefined;
22627         }
22628         var result = ts.parseJsonText(configFileName, configFileText);
22629         var cwd = host.getCurrentDirectory();
22630         result.path = ts.toPath(configFileName, cwd, ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames));
22631         result.resolvedPath = result.path;
22632         result.originalFileName = result.fileName;
22633         return parseJsonSourceFileConfigFileContent(result, host, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), cwd), optionsToExtend, ts.getNormalizedAbsolutePath(configFileName, cwd), undefined, extraFileExtensions, extendedConfigCache, watchOptionsToExtend);
22634     }
22635     ts.getParsedCommandLineOfConfigFile = getParsedCommandLineOfConfigFile;
22636     function readConfigFile(fileName, readFile) {
22637         var textOrDiagnostic = tryReadFile(fileName, readFile);
22638         return ts.isString(textOrDiagnostic) ? parseConfigFileTextToJson(fileName, textOrDiagnostic) : { config: {}, error: textOrDiagnostic };
22639     }
22640     ts.readConfigFile = readConfigFile;
22641     function parseConfigFileTextToJson(fileName, jsonText) {
22642         var jsonSourceFile = ts.parseJsonText(fileName, jsonText);
22643         return {
22644             config: convertToObject(jsonSourceFile, jsonSourceFile.parseDiagnostics),
22645             error: jsonSourceFile.parseDiagnostics.length ? jsonSourceFile.parseDiagnostics[0] : undefined
22646         };
22647     }
22648     ts.parseConfigFileTextToJson = parseConfigFileTextToJson;
22649     function readJsonConfigFile(fileName, readFile) {
22650         var textOrDiagnostic = tryReadFile(fileName, readFile);
22651         return ts.isString(textOrDiagnostic) ? ts.parseJsonText(fileName, textOrDiagnostic) : { parseDiagnostics: [textOrDiagnostic] };
22652     }
22653     ts.readJsonConfigFile = readJsonConfigFile;
22654     function tryReadFile(fileName, readFile) {
22655         var text;
22656         try {
22657             text = readFile(fileName);
22658         }
22659         catch (e) {
22660             return ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message);
22661         }
22662         return text === undefined ? ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0, fileName) : text;
22663     }
22664     ts.tryReadFile = tryReadFile;
22665     function commandLineOptionsToMap(options) {
22666         return ts.arrayToMap(options, getOptionName);
22667     }
22668     var typeAcquisitionDidYouMeanDiagnostics = {
22669         optionDeclarations: ts.typeAcquisitionDeclarations,
22670         unknownOptionDiagnostic: ts.Diagnostics.Unknown_type_acquisition_option_0,
22671         unknownDidYouMeanDiagnostic: ts.Diagnostics.Unknown_type_acquisition_option_0_Did_you_mean_1,
22672     };
22673     var watchOptionsNameMapCache;
22674     function getWatchOptionsNameMap() {
22675         return watchOptionsNameMapCache || (watchOptionsNameMapCache = createOptionNameMap(ts.optionsForWatch));
22676     }
22677     var watchOptionsDidYouMeanDiagnostics = {
22678         getOptionsNameMap: getWatchOptionsNameMap,
22679         optionDeclarations: ts.optionsForWatch,
22680         unknownOptionDiagnostic: ts.Diagnostics.Unknown_watch_option_0,
22681         unknownDidYouMeanDiagnostic: ts.Diagnostics.Unknown_watch_option_0_Did_you_mean_1,
22682         optionTypeMismatchDiagnostic: ts.Diagnostics.Watch_option_0_requires_a_value_of_type_1
22683     };
22684     var commandLineCompilerOptionsMapCache;
22685     function getCommandLineCompilerOptionsMap() {
22686         return commandLineCompilerOptionsMapCache || (commandLineCompilerOptionsMapCache = commandLineOptionsToMap(ts.optionDeclarations));
22687     }
22688     var commandLineWatchOptionsMapCache;
22689     function getCommandLineWatchOptionsMap() {
22690         return commandLineWatchOptionsMapCache || (commandLineWatchOptionsMapCache = commandLineOptionsToMap(ts.optionsForWatch));
22691     }
22692     var commandLineTypeAcquisitionMapCache;
22693     function getCommandLineTypeAcquisitionMap() {
22694         return commandLineTypeAcquisitionMapCache || (commandLineTypeAcquisitionMapCache = commandLineOptionsToMap(ts.typeAcquisitionDeclarations));
22695     }
22696     var _tsconfigRootOptions;
22697     function getTsconfigRootOptionsMap() {
22698         if (_tsconfigRootOptions === undefined) {
22699             _tsconfigRootOptions = {
22700                 name: undefined,
22701                 type: "object",
22702                 elementOptions: commandLineOptionsToMap([
22703                     {
22704                         name: "compilerOptions",
22705                         type: "object",
22706                         elementOptions: getCommandLineCompilerOptionsMap(),
22707                         extraKeyDiagnostics: ts.compilerOptionsDidYouMeanDiagnostics,
22708                     },
22709                     {
22710                         name: "watchOptions",
22711                         type: "object",
22712                         elementOptions: getCommandLineWatchOptionsMap(),
22713                         extraKeyDiagnostics: watchOptionsDidYouMeanDiagnostics,
22714                     },
22715                     {
22716                         name: "typingOptions",
22717                         type: "object",
22718                         elementOptions: getCommandLineTypeAcquisitionMap(),
22719                         extraKeyDiagnostics: typeAcquisitionDidYouMeanDiagnostics,
22720                     },
22721                     {
22722                         name: "typeAcquisition",
22723                         type: "object",
22724                         elementOptions: getCommandLineTypeAcquisitionMap(),
22725                         extraKeyDiagnostics: typeAcquisitionDidYouMeanDiagnostics
22726                     },
22727                     {
22728                         name: "extends",
22729                         type: "string"
22730                     },
22731                     {
22732                         name: "references",
22733                         type: "list",
22734                         element: {
22735                             name: "references",
22736                             type: "object"
22737                         }
22738                     },
22739                     {
22740                         name: "files",
22741                         type: "list",
22742                         element: {
22743                             name: "files",
22744                             type: "string"
22745                         }
22746                     },
22747                     {
22748                         name: "include",
22749                         type: "list",
22750                         element: {
22751                             name: "include",
22752                             type: "string"
22753                         }
22754                     },
22755                     {
22756                         name: "exclude",
22757                         type: "list",
22758                         element: {
22759                             name: "exclude",
22760                             type: "string"
22761                         }
22762                     },
22763                     ts.compileOnSaveCommandLineOption
22764                 ])
22765             };
22766         }
22767         return _tsconfigRootOptions;
22768     }
22769     function convertToObject(sourceFile, errors) {
22770         return convertToObjectWorker(sourceFile, errors, true, undefined, undefined);
22771     }
22772     ts.convertToObject = convertToObject;
22773     function convertToObjectWorker(sourceFile, errors, returnValue, knownRootOptions, jsonConversionNotifier) {
22774         if (!sourceFile.statements.length) {
22775             return returnValue ? {} : undefined;
22776         }
22777         return convertPropertyValueToJson(sourceFile.statements[0].expression, knownRootOptions);
22778         function isRootOptionMap(knownOptions) {
22779             return knownRootOptions && knownRootOptions.elementOptions === knownOptions;
22780         }
22781         function convertObjectLiteralExpressionToJson(node, knownOptions, extraKeyDiagnostics, parentOption) {
22782             var result = returnValue ? {} : undefined;
22783             var _loop_3 = function (element) {
22784                 if (element.kind !== 281) {
22785                     errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected));
22786                     return "continue";
22787                 }
22788                 if (element.questionToken) {
22789                     errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element.questionToken, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?"));
22790                 }
22791                 if (!isDoubleQuotedString(element.name)) {
22792                     errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element.name, ts.Diagnostics.String_literal_with_double_quotes_expected));
22793                 }
22794                 var textOfKey = ts.isComputedNonLiteralName(element.name) ? undefined : ts.getTextOfPropertyName(element.name);
22795                 var keyText = textOfKey && ts.unescapeLeadingUnderscores(textOfKey);
22796                 var option = keyText && knownOptions ? knownOptions.get(keyText) : undefined;
22797                 if (keyText && extraKeyDiagnostics && !option) {
22798                     if (knownOptions) {
22799                         errors.push(createUnknownOptionError(keyText, extraKeyDiagnostics, function (message, arg0, arg1) { return ts.createDiagnosticForNodeInSourceFile(sourceFile, element.name, message, arg0, arg1); }));
22800                     }
22801                     else {
22802                         errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element.name, extraKeyDiagnostics.unknownOptionDiagnostic, keyText));
22803                     }
22804                 }
22805                 var value = convertPropertyValueToJson(element.initializer, option);
22806                 if (typeof keyText !== "undefined") {
22807                     if (returnValue) {
22808                         result[keyText] = value;
22809                     }
22810                     if (jsonConversionNotifier &&
22811                         (parentOption || isRootOptionMap(knownOptions))) {
22812                         var isValidOptionValue = isCompilerOptionsValue(option, value);
22813                         if (parentOption) {
22814                             if (isValidOptionValue) {
22815                                 jsonConversionNotifier.onSetValidOptionKeyValueInParent(parentOption, option, value);
22816                             }
22817                         }
22818                         else if (isRootOptionMap(knownOptions)) {
22819                             if (isValidOptionValue) {
22820                                 jsonConversionNotifier.onSetValidOptionKeyValueInRoot(keyText, element.name, value, element.initializer);
22821                             }
22822                             else if (!option) {
22823                                 jsonConversionNotifier.onSetUnknownOptionKeyValueInRoot(keyText, element.name, value, element.initializer);
22824                             }
22825                         }
22826                     }
22827                 }
22828             };
22829             for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
22830                 var element = _a[_i];
22831                 _loop_3(element);
22832             }
22833             return result;
22834         }
22835         function convertArrayLiteralExpressionToJson(elements, elementOption) {
22836             if (!returnValue) {
22837                 return elements.forEach(function (element) { return convertPropertyValueToJson(element, elementOption); });
22838             }
22839             return ts.filter(elements.map(function (element) { return convertPropertyValueToJson(element, elementOption); }), function (v) { return v !== undefined; });
22840         }
22841         function convertPropertyValueToJson(valueExpression, option) {
22842             switch (valueExpression.kind) {
22843                 case 106:
22844                     reportInvalidOptionValue(option && option.type !== "boolean");
22845                     return true;
22846                 case 91:
22847                     reportInvalidOptionValue(option && option.type !== "boolean");
22848                     return false;
22849                 case 100:
22850                     reportInvalidOptionValue(option && option.name === "extends");
22851                     return null;
22852                 case 10:
22853                     if (!isDoubleQuotedString(valueExpression)) {
22854                         errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected));
22855                     }
22856                     reportInvalidOptionValue(option && (ts.isString(option.type) && option.type !== "string"));
22857                     var text = valueExpression.text;
22858                     if (option && !ts.isString(option.type)) {
22859                         var customOption = option;
22860                         if (!customOption.type.has(text.toLowerCase())) {
22861                             errors.push(createDiagnosticForInvalidCustomType(customOption, function (message, arg0, arg1) { return ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, message, arg0, arg1); }));
22862                         }
22863                     }
22864                     return text;
22865                 case 8:
22866                     reportInvalidOptionValue(option && option.type !== "number");
22867                     return Number(valueExpression.text);
22868                 case 207:
22869                     if (valueExpression.operator !== 40 || valueExpression.operand.kind !== 8) {
22870                         break;
22871                     }
22872                     reportInvalidOptionValue(option && option.type !== "number");
22873                     return -Number(valueExpression.operand.text);
22874                 case 193:
22875                     reportInvalidOptionValue(option && option.type !== "object");
22876                     var objectLiteralExpression = valueExpression;
22877                     if (option) {
22878                         var _a = option, elementOptions = _a.elementOptions, extraKeyDiagnostics = _a.extraKeyDiagnostics, optionName = _a.name;
22879                         return convertObjectLiteralExpressionToJson(objectLiteralExpression, elementOptions, extraKeyDiagnostics, optionName);
22880                     }
22881                     else {
22882                         return convertObjectLiteralExpressionToJson(objectLiteralExpression, undefined, undefined, undefined);
22883                     }
22884                 case 192:
22885                     reportInvalidOptionValue(option && option.type !== "list");
22886                     return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element);
22887             }
22888             if (option) {
22889                 reportInvalidOptionValue(true);
22890             }
22891             else {
22892                 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));
22893             }
22894             return undefined;
22895             function reportInvalidOptionValue(isError) {
22896                 if (isError) {
22897                     errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, option.name, getCompilerOptionValueTypeString(option)));
22898                 }
22899             }
22900         }
22901         function isDoubleQuotedString(node) {
22902             return ts.isStringLiteral(node) && ts.isStringDoubleQuoted(node, sourceFile);
22903         }
22904     }
22905     ts.convertToObjectWorker = convertToObjectWorker;
22906     function getCompilerOptionValueTypeString(option) {
22907         return option.type === "list" ?
22908             "Array" :
22909             ts.isString(option.type) ? option.type : "string";
22910     }
22911     function isCompilerOptionsValue(option, value) {
22912         if (option) {
22913             if (isNullOrUndefined(value))
22914                 return true;
22915             if (option.type === "list") {
22916                 return ts.isArray(value);
22917             }
22918             var expectedType = ts.isString(option.type) ? option.type : "string";
22919             return typeof value === expectedType;
22920         }
22921         return false;
22922     }
22923     function convertToTSConfig(configParseResult, configFileName, host) {
22924         var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames);
22925         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); });
22926         var optionMap = serializeCompilerOptions(configParseResult.options, { configFilePath: ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), useCaseSensitiveFileNames: host.useCaseSensitiveFileNames });
22927         var watchOptionMap = configParseResult.watchOptions && serializeWatchOptions(configParseResult.watchOptions);
22928         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 ? {
22929             include: filterSameAsDefaultInclude(configParseResult.configFileSpecs.validatedIncludeSpecs),
22930             exclude: configParseResult.configFileSpecs.validatedExcludeSpecs
22931         } : {})), { compileOnSave: !!configParseResult.compileOnSave ? true : undefined });
22932         return config;
22933     }
22934     ts.convertToTSConfig = convertToTSConfig;
22935     function optionMapToObject(optionMap) {
22936         return __assign({}, ts.arrayFrom(optionMap.entries()).reduce(function (prev, cur) {
22937             var _a;
22938             return (__assign(__assign({}, prev), (_a = {}, _a[cur[0]] = cur[1], _a)));
22939         }, {}));
22940     }
22941     function filterSameAsDefaultInclude(specs) {
22942         if (!ts.length(specs))
22943             return undefined;
22944         if (ts.length(specs) !== 1)
22945             return specs;
22946         if (specs[0] === "**/*")
22947             return undefined;
22948         return specs;
22949     }
22950     function matchesSpecs(path, includeSpecs, excludeSpecs, host) {
22951         if (!includeSpecs)
22952             return function (_) { return true; };
22953         var patterns = ts.getFileMatcherPatterns(path, excludeSpecs, includeSpecs, host.useCaseSensitiveFileNames, host.getCurrentDirectory());
22954         var excludeRe = patterns.excludePattern && ts.getRegexFromPattern(patterns.excludePattern, host.useCaseSensitiveFileNames);
22955         var includeRe = patterns.includeFilePattern && ts.getRegexFromPattern(patterns.includeFilePattern, host.useCaseSensitiveFileNames);
22956         if (includeRe) {
22957             if (excludeRe) {
22958                 return function (path) { return !(includeRe.test(path) && !excludeRe.test(path)); };
22959             }
22960             return function (path) { return !includeRe.test(path); };
22961         }
22962         if (excludeRe) {
22963             return function (path) { return excludeRe.test(path); };
22964         }
22965         return function (_) { return true; };
22966     }
22967     function getCustomTypeMapOfCommandLineOption(optionDefinition) {
22968         if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean" || optionDefinition.type === "object") {
22969             return undefined;
22970         }
22971         else if (optionDefinition.type === "list") {
22972             return getCustomTypeMapOfCommandLineOption(optionDefinition.element);
22973         }
22974         else {
22975             return optionDefinition.type;
22976         }
22977     }
22978     function getNameOfCompilerOptionValue(value, customTypeMap) {
22979         return ts.forEachEntry(customTypeMap, function (mapValue, key) {
22980             if (mapValue === value) {
22981                 return key;
22982             }
22983         });
22984     }
22985     function serializeCompilerOptions(options, pathOptions) {
22986         return serializeOptionBaseObject(options, getOptionsNameMap(), pathOptions);
22987     }
22988     function serializeWatchOptions(options) {
22989         return serializeOptionBaseObject(options, getWatchOptionsNameMap());
22990     }
22991     function serializeOptionBaseObject(options, _a, pathOptions) {
22992         var optionsNameMap = _a.optionsNameMap;
22993         var result = ts.createMap();
22994         var getCanonicalFileName = pathOptions && ts.createGetCanonicalFileName(pathOptions.useCaseSensitiveFileNames);
22995         var _loop_4 = function (name) {
22996             if (ts.hasProperty(options, name)) {
22997                 if (optionsNameMap.has(name) && optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options) {
22998                     return "continue";
22999                 }
23000                 var value = options[name];
23001                 var optionDefinition = optionsNameMap.get(name.toLowerCase());
23002                 if (optionDefinition) {
23003                     var customTypeMap_1 = getCustomTypeMapOfCommandLineOption(optionDefinition);
23004                     if (!customTypeMap_1) {
23005                         if (pathOptions && optionDefinition.isFilePath) {
23006                             result.set(name, ts.getRelativePathFromFile(pathOptions.configFilePath, ts.getNormalizedAbsolutePath(value, ts.getDirectoryPath(pathOptions.configFilePath)), getCanonicalFileName));
23007                         }
23008                         else {
23009                             result.set(name, value);
23010                         }
23011                     }
23012                     else {
23013                         if (optionDefinition.type === "list") {
23014                             result.set(name, value.map(function (element) { return getNameOfCompilerOptionValue(element, customTypeMap_1); }));
23015                         }
23016                         else {
23017                             result.set(name, getNameOfCompilerOptionValue(value, customTypeMap_1));
23018                         }
23019                     }
23020                 }
23021             }
23022         };
23023         for (var name in options) {
23024             _loop_4(name);
23025         }
23026         return result;
23027     }
23028     function generateTSConfig(options, fileNames, newLine) {
23029         var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions);
23030         var compilerOptionsMap = serializeCompilerOptions(compilerOptions);
23031         return writeConfigurations();
23032         function getDefaultValueForOption(option) {
23033             switch (option.type) {
23034                 case "number":
23035                     return 1;
23036                 case "boolean":
23037                     return true;
23038                 case "string":
23039                     return option.isFilePath ? "./" : "";
23040                 case "list":
23041                     return [];
23042                 case "object":
23043                     return {};
23044                 default:
23045                     var iterResult = option.type.keys().next();
23046                     if (!iterResult.done)
23047                         return iterResult.value;
23048                     return ts.Debug.fail("Expected 'option.type' to have entries.");
23049             }
23050         }
23051         function makePadding(paddingLength) {
23052             return Array(paddingLength + 1).join(" ");
23053         }
23054         function isAllowedOption(_a) {
23055             var category = _a.category, name = _a.name;
23056             return category !== undefined
23057                 && category !== ts.Diagnostics.Command_line_Options
23058                 && (category !== ts.Diagnostics.Advanced_Options || compilerOptionsMap.has(name));
23059         }
23060         function writeConfigurations() {
23061             var categorizedOptions = ts.createMultiMap();
23062             for (var _i = 0, optionDeclarations_1 = ts.optionDeclarations; _i < optionDeclarations_1.length; _i++) {
23063                 var option = optionDeclarations_1[_i];
23064                 var category = option.category;
23065                 if (isAllowedOption(option)) {
23066                     categorizedOptions.add(ts.getLocaleSpecificMessage(category), option);
23067                 }
23068             }
23069             var marginLength = 0;
23070             var seenKnownKeys = 0;
23071             var entries = [];
23072             categorizedOptions.forEach(function (options, category) {
23073                 if (entries.length !== 0) {
23074                     entries.push({ value: "" });
23075                 }
23076                 entries.push({ value: "/* " + category + " */" });
23077                 for (var _i = 0, options_1 = options; _i < options_1.length; _i++) {
23078                     var option = options_1[_i];
23079                     var optionName = void 0;
23080                     if (compilerOptionsMap.has(option.name)) {
23081                         optionName = "\"" + option.name + "\": " + JSON.stringify(compilerOptionsMap.get(option.name)) + ((seenKnownKeys += 1) === compilerOptionsMap.size ? "" : ",");
23082                     }
23083                     else {
23084                         optionName = "// \"" + option.name + "\": " + JSON.stringify(getDefaultValueForOption(option)) + ",";
23085                     }
23086                     entries.push({
23087                         value: optionName,
23088                         description: "/* " + (option.description && ts.getLocaleSpecificMessage(option.description) || option.name) + " */"
23089                     });
23090                     marginLength = Math.max(optionName.length, marginLength);
23091                 }
23092             });
23093             var tab = makePadding(2);
23094             var result = [];
23095             result.push("{");
23096             result.push(tab + "\"compilerOptions\": {");
23097             result.push("" + tab + tab + "/* " + ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_json_to_read_more_about_this_file) + " */");
23098             result.push("");
23099             for (var _a = 0, entries_3 = entries; _a < entries_3.length; _a++) {
23100                 var entry = entries_3[_a];
23101                 var value = entry.value, _b = entry.description, description = _b === void 0 ? "" : _b;
23102                 result.push(value && "" + tab + tab + value + (description && (makePadding(marginLength - value.length + 2) + description)));
23103             }
23104             if (fileNames.length) {
23105                 result.push(tab + "},");
23106                 result.push(tab + "\"files\": [");
23107                 for (var i = 0; i < fileNames.length; i++) {
23108                     result.push("" + tab + tab + JSON.stringify(fileNames[i]) + (i === fileNames.length - 1 ? "" : ","));
23109                 }
23110                 result.push(tab + "]");
23111             }
23112             else {
23113                 result.push(tab + "}");
23114             }
23115             result.push("}");
23116             return result.join(newLine) + newLine;
23117         }
23118     }
23119     ts.generateTSConfig = generateTSConfig;
23120     function convertToOptionsWithAbsolutePaths(options, toAbsolutePath) {
23121         var result = {};
23122         var optionsNameMap = getOptionsNameMap().optionsNameMap;
23123         for (var name in options) {
23124             if (ts.hasProperty(options, name)) {
23125                 result[name] = convertToOptionValueWithAbsolutePaths(optionsNameMap.get(name.toLowerCase()), options[name], toAbsolutePath);
23126             }
23127         }
23128         if (result.configFilePath) {
23129             result.configFilePath = toAbsolutePath(result.configFilePath);
23130         }
23131         return result;
23132     }
23133     ts.convertToOptionsWithAbsolutePaths = convertToOptionsWithAbsolutePaths;
23134     function convertToOptionValueWithAbsolutePaths(option, value, toAbsolutePath) {
23135         if (option && !isNullOrUndefined(value)) {
23136             if (option.type === "list") {
23137                 var values = value;
23138                 if (option.element.isFilePath && values.length) {
23139                     return values.map(toAbsolutePath);
23140                 }
23141             }
23142             else if (option.isFilePath) {
23143                 return toAbsolutePath(value);
23144             }
23145         }
23146         return value;
23147     }
23148     function parseJsonConfigFileContent(json, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache, existingWatchOptions) {
23149         return parseJsonConfigFileContentWorker(json, undefined, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache);
23150     }
23151     ts.parseJsonConfigFileContent = parseJsonConfigFileContent;
23152     function parseJsonSourceFileConfigFileContent(sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache, existingWatchOptions) {
23153         return parseJsonConfigFileContentWorker(undefined, sourceFile, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache);
23154     }
23155     ts.parseJsonSourceFileConfigFileContent = parseJsonSourceFileConfigFileContent;
23156     function setConfigFileInOptions(options, configFile) {
23157         if (configFile) {
23158             Object.defineProperty(options, "configFile", { enumerable: false, writable: false, value: configFile });
23159         }
23160     }
23161     ts.setConfigFileInOptions = setConfigFileInOptions;
23162     function isNullOrUndefined(x) {
23163         return x === undefined || x === null;
23164     }
23165     function directoryOfCombinedPath(fileName, basePath) {
23166         return ts.getDirectoryPath(ts.getNormalizedAbsolutePath(fileName, basePath));
23167     }
23168     function parseJsonConfigFileContentWorker(json, sourceFile, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache) {
23169         if (existingOptions === void 0) { existingOptions = {}; }
23170         if (resolutionStack === void 0) { resolutionStack = []; }
23171         if (extraFileExtensions === void 0) { extraFileExtensions = []; }
23172         ts.Debug.assert((json === undefined && sourceFile !== undefined) || (json !== undefined && sourceFile === undefined));
23173         var errors = [];
23174         var parsedConfig = parseConfig(json, sourceFile, host, basePath, configFileName, resolutionStack, errors, extendedConfigCache);
23175         var raw = parsedConfig.raw;
23176         var options = ts.extend(existingOptions, parsedConfig.options || {});
23177         var watchOptions = existingWatchOptions && parsedConfig.watchOptions ?
23178             ts.extend(existingWatchOptions, parsedConfig.watchOptions) :
23179             parsedConfig.watchOptions || existingWatchOptions;
23180         options.configFilePath = configFileName && ts.normalizeSlashes(configFileName);
23181         setConfigFileInOptions(options, sourceFile);
23182         var projectReferences;
23183         var _a = getFileNames(), fileNames = _a.fileNames, wildcardDirectories = _a.wildcardDirectories, spec = _a.spec;
23184         return {
23185             options: options,
23186             watchOptions: watchOptions,
23187             fileNames: fileNames,
23188             projectReferences: projectReferences,
23189             typeAcquisition: parsedConfig.typeAcquisition || getDefaultTypeAcquisition(),
23190             raw: raw,
23191             errors: errors,
23192             wildcardDirectories: wildcardDirectories,
23193             compileOnSave: !!raw.compileOnSave,
23194             configFileSpecs: spec
23195         };
23196         function getFileNames() {
23197             var filesSpecs;
23198             if (ts.hasProperty(raw, "files") && !isNullOrUndefined(raw.files)) {
23199                 if (ts.isArray(raw.files)) {
23200                     filesSpecs = raw.files;
23201                     var hasReferences = ts.hasProperty(raw, "references") && !isNullOrUndefined(raw.references);
23202                     var hasZeroOrNoReferences = !hasReferences || raw.references.length === 0;
23203                     var hasExtends = ts.hasProperty(raw, "extends");
23204                     if (filesSpecs.length === 0 && hasZeroOrNoReferences && !hasExtends) {
23205                         if (sourceFile) {
23206                             var fileName = configFileName || "tsconfig.json";
23207                             var diagnosticMessage = ts.Diagnostics.The_files_list_in_config_file_0_is_empty;
23208                             var nodeValue = ts.firstDefined(ts.getTsConfigPropArray(sourceFile, "files"), function (property) { return property.initializer; });
23209                             var error = nodeValue
23210                                 ? ts.createDiagnosticForNodeInSourceFile(sourceFile, nodeValue, diagnosticMessage, fileName)
23211                                 : ts.createCompilerDiagnostic(diagnosticMessage, fileName);
23212                             errors.push(error);
23213                         }
23214                         else {
23215                             createCompilerDiagnosticOnlyIfJson(ts.Diagnostics.The_files_list_in_config_file_0_is_empty, configFileName || "tsconfig.json");
23216                         }
23217                     }
23218                 }
23219                 else {
23220                     createCompilerDiagnosticOnlyIfJson(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array");
23221                 }
23222             }
23223             var includeSpecs;
23224             if (ts.hasProperty(raw, "include") && !isNullOrUndefined(raw.include)) {
23225                 if (ts.isArray(raw.include)) {
23226                     includeSpecs = raw.include;
23227                 }
23228                 else {
23229                     createCompilerDiagnosticOnlyIfJson(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "include", "Array");
23230                 }
23231             }
23232             var excludeSpecs;
23233             if (ts.hasProperty(raw, "exclude") && !isNullOrUndefined(raw.exclude)) {
23234                 if (ts.isArray(raw.exclude)) {
23235                     excludeSpecs = raw.exclude;
23236                 }
23237                 else {
23238                     createCompilerDiagnosticOnlyIfJson(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "exclude", "Array");
23239                 }
23240             }
23241             else if (raw.compilerOptions) {
23242                 var outDir = raw.compilerOptions.outDir;
23243                 var declarationDir = raw.compilerOptions.declarationDir;
23244                 if (outDir || declarationDir) {
23245                     excludeSpecs = [outDir, declarationDir].filter(function (d) { return !!d; });
23246                 }
23247             }
23248             if (filesSpecs === undefined && includeSpecs === undefined) {
23249                 includeSpecs = ["**/*"];
23250             }
23251             var result = matchFileNames(filesSpecs, includeSpecs, excludeSpecs, configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath, options, host, errors, extraFileExtensions, sourceFile);
23252             if (shouldReportNoInputFiles(result, canJsonReportNoInutFiles(raw), resolutionStack)) {
23253                 errors.push(getErrorForNoInputFiles(result.spec, configFileName));
23254             }
23255             if (ts.hasProperty(raw, "references") && !isNullOrUndefined(raw.references)) {
23256                 if (ts.isArray(raw.references)) {
23257                     for (var _i = 0, _a = raw.references; _i < _a.length; _i++) {
23258                         var ref = _a[_i];
23259                         if (typeof ref.path !== "string") {
23260                             createCompilerDiagnosticOnlyIfJson(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "reference.path", "string");
23261                         }
23262                         else {
23263                             (projectReferences || (projectReferences = [])).push({
23264                                 path: ts.getNormalizedAbsolutePath(ref.path, basePath),
23265                                 originalPath: ref.path,
23266                                 prepend: ref.prepend,
23267                                 circular: ref.circular
23268                             });
23269                         }
23270                     }
23271                 }
23272                 else {
23273                     createCompilerDiagnosticOnlyIfJson(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "references", "Array");
23274                 }
23275             }
23276             return result;
23277         }
23278         function createCompilerDiagnosticOnlyIfJson(message, arg0, arg1) {
23279             if (!sourceFile) {
23280                 errors.push(ts.createCompilerDiagnostic(message, arg0, arg1));
23281             }
23282         }
23283     }
23284     function isErrorNoInputFiles(error) {
23285         return error.code === ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2.code;
23286     }
23287     function getErrorForNoInputFiles(_a, configFileName) {
23288         var includeSpecs = _a.includeSpecs, excludeSpecs = _a.excludeSpecs;
23289         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 || []));
23290     }
23291     function shouldReportNoInputFiles(result, canJsonReportNoInutFiles, resolutionStack) {
23292         return result.fileNames.length === 0 && canJsonReportNoInutFiles && (!resolutionStack || resolutionStack.length === 0);
23293     }
23294     function canJsonReportNoInutFiles(raw) {
23295         return !ts.hasProperty(raw, "files") && !ts.hasProperty(raw, "references");
23296     }
23297     ts.canJsonReportNoInutFiles = canJsonReportNoInutFiles;
23298     function updateErrorForNoInputFiles(result, configFileName, configFileSpecs, configParseDiagnostics, canJsonReportNoInutFiles) {
23299         var existingErrors = configParseDiagnostics.length;
23300         if (shouldReportNoInputFiles(result, canJsonReportNoInutFiles)) {
23301             configParseDiagnostics.push(getErrorForNoInputFiles(configFileSpecs, configFileName));
23302         }
23303         else {
23304             ts.filterMutate(configParseDiagnostics, function (error) { return !isErrorNoInputFiles(error); });
23305         }
23306         return existingErrors !== configParseDiagnostics.length;
23307     }
23308     ts.updateErrorForNoInputFiles = updateErrorForNoInputFiles;
23309     function isSuccessfulParsedTsconfig(value) {
23310         return !!value.options;
23311     }
23312     function parseConfig(json, sourceFile, host, basePath, configFileName, resolutionStack, errors, extendedConfigCache) {
23313         basePath = ts.normalizeSlashes(basePath);
23314         var resolvedPath = ts.getNormalizedAbsolutePath(configFileName || "", basePath);
23315         if (resolutionStack.indexOf(resolvedPath) >= 0) {
23316             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, __spreadArrays(resolutionStack, [resolvedPath]).join(" -> ")));
23317             return { raw: json || convertToObject(sourceFile, errors) };
23318         }
23319         var ownConfig = json ?
23320             parseOwnConfigOfJson(json, host, basePath, configFileName, errors) :
23321             parseOwnConfigOfJsonSourceFile(sourceFile, host, basePath, configFileName, errors);
23322         if (ownConfig.extendedConfigPath) {
23323             resolutionStack = resolutionStack.concat([resolvedPath]);
23324             var extendedConfig = getExtendedConfig(sourceFile, ownConfig.extendedConfigPath, host, basePath, resolutionStack, errors, extendedConfigCache);
23325             if (extendedConfig && isSuccessfulParsedTsconfig(extendedConfig)) {
23326                 var baseRaw_1 = extendedConfig.raw;
23327                 var raw_1 = ownConfig.raw;
23328                 var setPropertyInRawIfNotUndefined = function (propertyName) {
23329                     var value = raw_1[propertyName] || baseRaw_1[propertyName];
23330                     if (value) {
23331                         raw_1[propertyName] = value;
23332                     }
23333                 };
23334                 setPropertyInRawIfNotUndefined("include");
23335                 setPropertyInRawIfNotUndefined("exclude");
23336                 setPropertyInRawIfNotUndefined("files");
23337                 if (raw_1.compileOnSave === undefined) {
23338                     raw_1.compileOnSave = baseRaw_1.compileOnSave;
23339                 }
23340                 ownConfig.options = ts.assign({}, extendedConfig.options, ownConfig.options);
23341                 ownConfig.watchOptions = ownConfig.watchOptions && extendedConfig.watchOptions ?
23342                     ts.assign({}, extendedConfig.watchOptions, ownConfig.watchOptions) :
23343                     ownConfig.watchOptions || extendedConfig.watchOptions;
23344             }
23345         }
23346         return ownConfig;
23347     }
23348     function parseOwnConfigOfJson(json, host, basePath, configFileName, errors) {
23349         if (ts.hasProperty(json, "excludes")) {
23350             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_option_excludes_Did_you_mean_exclude));
23351         }
23352         var options = convertCompilerOptionsFromJsonWorker(json.compilerOptions, basePath, errors, configFileName);
23353         var typeAcquisition = convertTypeAcquisitionFromJsonWorker(json.typeAcquisition || json.typingOptions, basePath, errors, configFileName);
23354         var watchOptions = convertWatchOptionsFromJsonWorker(json.watchOptions, basePath, errors);
23355         json.compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors);
23356         var extendedConfigPath;
23357         if (json.extends) {
23358             if (!ts.isString(json.extends)) {
23359                 errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string"));
23360             }
23361             else {
23362                 var newBase = configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath;
23363                 extendedConfigPath = getExtendsConfigPath(json.extends, host, newBase, errors, ts.createCompilerDiagnostic);
23364             }
23365         }
23366         return { raw: json, options: options, watchOptions: watchOptions, typeAcquisition: typeAcquisition, extendedConfigPath: extendedConfigPath };
23367     }
23368     function parseOwnConfigOfJsonSourceFile(sourceFile, host, basePath, configFileName, errors) {
23369         var options = getDefaultCompilerOptions(configFileName);
23370         var typeAcquisition, typingOptionstypeAcquisition;
23371         var watchOptions;
23372         var extendedConfigPath;
23373         var optionsIterator = {
23374             onSetValidOptionKeyValueInParent: function (parentOption, option, value) {
23375                 var currentOption;
23376                 switch (parentOption) {
23377                     case "compilerOptions":
23378                         currentOption = options;
23379                         break;
23380                     case "watchOptions":
23381                         currentOption = (watchOptions || (watchOptions = {}));
23382                         break;
23383                     case "typeAcquisition":
23384                         currentOption = (typeAcquisition || (typeAcquisition = getDefaultTypeAcquisition(configFileName)));
23385                         break;
23386                     case "typingOptions":
23387                         currentOption = (typingOptionstypeAcquisition || (typingOptionstypeAcquisition = getDefaultTypeAcquisition(configFileName)));
23388                         break;
23389                     default:
23390                         ts.Debug.fail("Unknown option");
23391                 }
23392                 currentOption[option.name] = normalizeOptionValue(option, basePath, value);
23393             },
23394             onSetValidOptionKeyValueInRoot: function (key, _keyNode, value, valueNode) {
23395                 switch (key) {
23396                     case "extends":
23397                         var newBase = configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath;
23398                         extendedConfigPath = getExtendsConfigPath(value, host, newBase, errors, function (message, arg0) {
23399                             return ts.createDiagnosticForNodeInSourceFile(sourceFile, valueNode, message, arg0);
23400                         });
23401                         return;
23402                 }
23403             },
23404             onSetUnknownOptionKeyValueInRoot: function (key, keyNode, _value, _valueNode) {
23405                 if (key === "excludes") {
23406                     errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, keyNode, ts.Diagnostics.Unknown_option_excludes_Did_you_mean_exclude));
23407                 }
23408             }
23409         };
23410         var json = convertToObjectWorker(sourceFile, errors, true, getTsconfigRootOptionsMap(), optionsIterator);
23411         if (!typeAcquisition) {
23412             if (typingOptionstypeAcquisition) {
23413                 typeAcquisition = (typingOptionstypeAcquisition.enableAutoDiscovery !== undefined) ?
23414                     {
23415                         enable: typingOptionstypeAcquisition.enableAutoDiscovery,
23416                         include: typingOptionstypeAcquisition.include,
23417                         exclude: typingOptionstypeAcquisition.exclude
23418                     } :
23419                     typingOptionstypeAcquisition;
23420             }
23421             else {
23422                 typeAcquisition = getDefaultTypeAcquisition(configFileName);
23423             }
23424         }
23425         return { raw: json, options: options, watchOptions: watchOptions, typeAcquisition: typeAcquisition, extendedConfigPath: extendedConfigPath };
23426     }
23427     function getExtendsConfigPath(extendedConfig, host, basePath, errors, createDiagnostic) {
23428         extendedConfig = ts.normalizeSlashes(extendedConfig);
23429         if (ts.isRootedDiskPath(extendedConfig) || ts.startsWith(extendedConfig, "./") || ts.startsWith(extendedConfig, "../")) {
23430             var extendedConfigPath = ts.getNormalizedAbsolutePath(extendedConfig, basePath);
23431             if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json")) {
23432                 extendedConfigPath = extendedConfigPath + ".json";
23433                 if (!host.fileExists(extendedConfigPath)) {
23434                     errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig));
23435                     return undefined;
23436                 }
23437             }
23438             return extendedConfigPath;
23439         }
23440         var resolved = ts.nodeModuleNameResolver(extendedConfig, ts.combinePaths(basePath, "tsconfig.json"), { moduleResolution: ts.ModuleResolutionKind.NodeJs }, host, undefined, undefined, true);
23441         if (resolved.resolvedModule) {
23442             return resolved.resolvedModule.resolvedFileName;
23443         }
23444         errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig));
23445         return undefined;
23446     }
23447     function getExtendedConfig(sourceFile, extendedConfigPath, host, basePath, resolutionStack, errors, extendedConfigCache) {
23448         var _a;
23449         var path = host.useCaseSensitiveFileNames ? extendedConfigPath : ts.toFileNameLowerCase(extendedConfigPath);
23450         var value;
23451         var extendedResult;
23452         var extendedConfig;
23453         if (extendedConfigCache && (value = extendedConfigCache.get(path))) {
23454             (extendedResult = value.extendedResult, extendedConfig = value.extendedConfig);
23455         }
23456         else {
23457             extendedResult = readJsonConfigFile(extendedConfigPath, function (path) { return host.readFile(path); });
23458             if (!extendedResult.parseDiagnostics.length) {
23459                 var extendedDirname = ts.getDirectoryPath(extendedConfigPath);
23460                 extendedConfig = parseConfig(undefined, extendedResult, host, extendedDirname, ts.getBaseFileName(extendedConfigPath), resolutionStack, errors, extendedConfigCache);
23461                 if (isSuccessfulParsedTsconfig(extendedConfig)) {
23462                     var relativeDifference_1 = ts.convertToRelativePath(extendedDirname, basePath, ts.identity);
23463                     var updatePath_1 = function (path) { return ts.isRootedDiskPath(path) ? path : ts.combinePaths(relativeDifference_1, path); };
23464                     var mapPropertiesInRawIfNotUndefined = function (propertyName) {
23465                         if (raw_2[propertyName]) {
23466                             raw_2[propertyName] = ts.map(raw_2[propertyName], updatePath_1);
23467                         }
23468                     };
23469                     var raw_2 = extendedConfig.raw;
23470                     mapPropertiesInRawIfNotUndefined("include");
23471                     mapPropertiesInRawIfNotUndefined("exclude");
23472                     mapPropertiesInRawIfNotUndefined("files");
23473                 }
23474             }
23475             if (extendedConfigCache) {
23476                 extendedConfigCache.set(path, { extendedResult: extendedResult, extendedConfig: extendedConfig });
23477             }
23478         }
23479         if (sourceFile) {
23480             sourceFile.extendedSourceFiles = [extendedResult.fileName];
23481             if (extendedResult.extendedSourceFiles) {
23482                 (_a = sourceFile.extendedSourceFiles).push.apply(_a, extendedResult.extendedSourceFiles);
23483             }
23484         }
23485         if (extendedResult.parseDiagnostics.length) {
23486             errors.push.apply(errors, extendedResult.parseDiagnostics);
23487             return undefined;
23488         }
23489         return extendedConfig;
23490     }
23491     function convertCompileOnSaveOptionFromJson(jsonOption, basePath, errors) {
23492         if (!ts.hasProperty(jsonOption, ts.compileOnSaveCommandLineOption.name)) {
23493             return false;
23494         }
23495         var result = convertJsonOption(ts.compileOnSaveCommandLineOption, jsonOption.compileOnSave, basePath, errors);
23496         return typeof result === "boolean" && result;
23497     }
23498     function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) {
23499         var errors = [];
23500         var options = convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName);
23501         return { options: options, errors: errors };
23502     }
23503     ts.convertCompilerOptionsFromJson = convertCompilerOptionsFromJson;
23504     function convertTypeAcquisitionFromJson(jsonOptions, basePath, configFileName) {
23505         var errors = [];
23506         var options = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName);
23507         return { options: options, errors: errors };
23508     }
23509     ts.convertTypeAcquisitionFromJson = convertTypeAcquisitionFromJson;
23510     function getDefaultCompilerOptions(configFileName) {
23511         var options = configFileName && ts.getBaseFileName(configFileName) === "jsconfig.json"
23512             ? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, skipLibCheck: true, noEmit: true }
23513             : {};
23514         return options;
23515     }
23516     function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) {
23517         var options = getDefaultCompilerOptions(configFileName);
23518         convertOptionsFromJson(getCommandLineCompilerOptionsMap(), jsonOptions, basePath, options, ts.compilerOptionsDidYouMeanDiagnostics, errors);
23519         if (configFileName) {
23520             options.configFilePath = ts.normalizeSlashes(configFileName);
23521         }
23522         return options;
23523     }
23524     function getDefaultTypeAcquisition(configFileName) {
23525         return { enable: !!configFileName && ts.getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] };
23526     }
23527     function convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName) {
23528         var options = getDefaultTypeAcquisition(configFileName);
23529         var typeAcquisition = convertEnableAutoDiscoveryToEnable(jsonOptions);
23530         convertOptionsFromJson(getCommandLineTypeAcquisitionMap(), typeAcquisition, basePath, options, typeAcquisitionDidYouMeanDiagnostics, errors);
23531         return options;
23532     }
23533     function convertWatchOptionsFromJsonWorker(jsonOptions, basePath, errors) {
23534         return convertOptionsFromJson(getCommandLineWatchOptionsMap(), jsonOptions, basePath, undefined, watchOptionsDidYouMeanDiagnostics, errors);
23535     }
23536     function convertOptionsFromJson(optionsNameMap, jsonOptions, basePath, defaultOptions, diagnostics, errors) {
23537         if (!jsonOptions) {
23538             return;
23539         }
23540         for (var id in jsonOptions) {
23541             var opt = optionsNameMap.get(id);
23542             if (opt) {
23543                 (defaultOptions || (defaultOptions = {}))[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors);
23544             }
23545             else {
23546                 errors.push(createUnknownOptionError(id, diagnostics, ts.createCompilerDiagnostic));
23547             }
23548         }
23549         return defaultOptions;
23550     }
23551     function convertJsonOption(opt, value, basePath, errors) {
23552         if (isCompilerOptionsValue(opt, value)) {
23553             var optType = opt.type;
23554             if (optType === "list" && ts.isArray(value)) {
23555                 return convertJsonOptionOfListType(opt, value, basePath, errors);
23556             }
23557             else if (!ts.isString(optType)) {
23558                 return convertJsonOptionOfCustomType(opt, value, errors);
23559             }
23560             return normalizeNonListOptionValue(opt, basePath, value);
23561         }
23562         else {
23563             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, opt.name, getCompilerOptionValueTypeString(opt)));
23564         }
23565     }
23566     function normalizeOptionValue(option, basePath, value) {
23567         if (isNullOrUndefined(value))
23568             return undefined;
23569         if (option.type === "list") {
23570             var listOption_1 = option;
23571             if (listOption_1.element.isFilePath || !ts.isString(listOption_1.element.type)) {
23572                 return ts.filter(ts.map(value, function (v) { return normalizeOptionValue(listOption_1.element, basePath, v); }), function (v) { return !!v; });
23573             }
23574             return value;
23575         }
23576         else if (!ts.isString(option.type)) {
23577             return option.type.get(ts.isString(value) ? value.toLowerCase() : value);
23578         }
23579         return normalizeNonListOptionValue(option, basePath, value);
23580     }
23581     function normalizeNonListOptionValue(option, basePath, value) {
23582         if (option.isFilePath) {
23583             value = ts.getNormalizedAbsolutePath(value, basePath);
23584             if (value === "") {
23585                 value = ".";
23586             }
23587         }
23588         return value;
23589     }
23590     function convertJsonOptionOfCustomType(opt, value, errors) {
23591         if (isNullOrUndefined(value))
23592             return undefined;
23593         var key = value.toLowerCase();
23594         var val = opt.type.get(key);
23595         if (val !== undefined) {
23596             return val;
23597         }
23598         else {
23599             errors.push(createCompilerDiagnosticForInvalidCustomType(opt));
23600         }
23601     }
23602     function convertJsonOptionOfListType(option, values, basePath, errors) {
23603         return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return !!v; });
23604     }
23605     function trimString(s) {
23606         return typeof s.trim === "function" ? s.trim() : s.replace(/^[\s]+|[\s]+$/g, "");
23607     }
23608     var invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/;
23609     var invalidDotDotAfterRecursiveWildcardPattern = /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/;
23610     var watchRecursivePattern = /\/[^/]*?[*?][^/]*\//;
23611     var wildcardDirectoryPattern = /^[^*?]*(?=\/[^/]*[*?])/;
23612     function matchFileNames(filesSpecs, includeSpecs, excludeSpecs, basePath, options, host, errors, extraFileExtensions, jsonSourceFile) {
23613         basePath = ts.normalizePath(basePath);
23614         var validatedIncludeSpecs, validatedExcludeSpecs;
23615         if (includeSpecs) {
23616             validatedIncludeSpecs = validateSpecs(includeSpecs, errors, false, jsonSourceFile, "include");
23617         }
23618         if (excludeSpecs) {
23619             validatedExcludeSpecs = validateSpecs(excludeSpecs, errors, true, jsonSourceFile, "exclude");
23620         }
23621         var wildcardDirectories = getWildcardDirectories(validatedIncludeSpecs, validatedExcludeSpecs, basePath, host.useCaseSensitiveFileNames);
23622         var spec = { filesSpecs: filesSpecs, includeSpecs: includeSpecs, excludeSpecs: excludeSpecs, validatedIncludeSpecs: validatedIncludeSpecs, validatedExcludeSpecs: validatedExcludeSpecs, wildcardDirectories: wildcardDirectories };
23623         return getFileNamesFromConfigSpecs(spec, basePath, options, host, extraFileExtensions);
23624     }
23625     function getFileNamesFromConfigSpecs(spec, basePath, options, host, extraFileExtensions) {
23626         if (extraFileExtensions === void 0) { extraFileExtensions = []; }
23627         basePath = ts.normalizePath(basePath);
23628         var keyMapper = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames);
23629         var literalFileMap = ts.createMap();
23630         var wildcardFileMap = ts.createMap();
23631         var wildCardJsonFileMap = ts.createMap();
23632         var filesSpecs = spec.filesSpecs, validatedIncludeSpecs = spec.validatedIncludeSpecs, validatedExcludeSpecs = spec.validatedExcludeSpecs, wildcardDirectories = spec.wildcardDirectories;
23633         var supportedExtensions = ts.getSupportedExtensions(options, extraFileExtensions);
23634         var supportedExtensionsWithJsonIfResolveJsonModule = ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions);
23635         if (filesSpecs) {
23636             for (var _i = 0, filesSpecs_1 = filesSpecs; _i < filesSpecs_1.length; _i++) {
23637                 var fileName = filesSpecs_1[_i];
23638                 var file = ts.getNormalizedAbsolutePath(fileName, basePath);
23639                 literalFileMap.set(keyMapper(file), file);
23640             }
23641         }
23642         var jsonOnlyIncludeRegexes;
23643         if (validatedIncludeSpecs && validatedIncludeSpecs.length > 0) {
23644             var _loop_5 = function (file) {
23645                 if (ts.fileExtensionIs(file, ".json")) {
23646                     if (!jsonOnlyIncludeRegexes) {
23647                         var includes = validatedIncludeSpecs.filter(function (s) { return ts.endsWith(s, ".json"); });
23648                         var includeFilePatterns = ts.map(ts.getRegularExpressionsForWildcards(includes, basePath, "files"), function (pattern) { return "^" + pattern + "$"; });
23649                         jsonOnlyIncludeRegexes = includeFilePatterns ? includeFilePatterns.map(function (pattern) { return ts.getRegexFromPattern(pattern, host.useCaseSensitiveFileNames); }) : ts.emptyArray;
23650                     }
23651                     var includeIndex = ts.findIndex(jsonOnlyIncludeRegexes, function (re) { return re.test(file); });
23652                     if (includeIndex !== -1) {
23653                         var key_1 = keyMapper(file);
23654                         if (!literalFileMap.has(key_1) && !wildCardJsonFileMap.has(key_1)) {
23655                             wildCardJsonFileMap.set(key_1, file);
23656                         }
23657                     }
23658                     return "continue";
23659                 }
23660                 if (hasFileWithHigherPriorityExtension(file, literalFileMap, wildcardFileMap, supportedExtensions, keyMapper)) {
23661                     return "continue";
23662                 }
23663                 removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper);
23664                 var key = keyMapper(file);
23665                 if (!literalFileMap.has(key) && !wildcardFileMap.has(key)) {
23666                     wildcardFileMap.set(key, file);
23667                 }
23668             };
23669             for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensionsWithJsonIfResolveJsonModule, validatedExcludeSpecs, validatedIncludeSpecs, undefined); _a < _b.length; _a++) {
23670                 var file = _b[_a];
23671                 _loop_5(file);
23672             }
23673         }
23674         var literalFiles = ts.arrayFrom(literalFileMap.values());
23675         var wildcardFiles = ts.arrayFrom(wildcardFileMap.values());
23676         return {
23677             fileNames: literalFiles.concat(wildcardFiles, ts.arrayFrom(wildCardJsonFileMap.values())),
23678             wildcardDirectories: wildcardDirectories,
23679             spec: spec
23680         };
23681     }
23682     ts.getFileNamesFromConfigSpecs = getFileNamesFromConfigSpecs;
23683     function validateSpecs(specs, errors, allowTrailingRecursion, jsonSourceFile, specKey) {
23684         return specs.filter(function (spec) {
23685             var diag = specToDiagnostic(spec, allowTrailingRecursion);
23686             if (diag !== undefined) {
23687                 errors.push(createDiagnostic(diag, spec));
23688             }
23689             return diag === undefined;
23690         });
23691         function createDiagnostic(message, spec) {
23692             var element = ts.getTsConfigPropArrayElementValue(jsonSourceFile, specKey, spec);
23693             return element ?
23694                 ts.createDiagnosticForNodeInSourceFile(jsonSourceFile, element, message, spec) :
23695                 ts.createCompilerDiagnostic(message, spec);
23696         }
23697     }
23698     function specToDiagnostic(spec, allowTrailingRecursion) {
23699         if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) {
23700             return ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0;
23701         }
23702         else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) {
23703             return ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0;
23704         }
23705     }
23706     function getWildcardDirectories(include, exclude, path, useCaseSensitiveFileNames) {
23707         var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude");
23708         var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i");
23709         var wildcardDirectories = {};
23710         if (include !== undefined) {
23711             var recursiveKeys = [];
23712             for (var _i = 0, include_1 = include; _i < include_1.length; _i++) {
23713                 var file = include_1[_i];
23714                 var spec = ts.normalizePath(ts.combinePaths(path, file));
23715                 if (excludeRegex && excludeRegex.test(spec)) {
23716                     continue;
23717                 }
23718                 var match = getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames);
23719                 if (match) {
23720                     var key = match.key, flags = match.flags;
23721                     var existingFlags = wildcardDirectories[key];
23722                     if (existingFlags === undefined || existingFlags < flags) {
23723                         wildcardDirectories[key] = flags;
23724                         if (flags === 1) {
23725                             recursiveKeys.push(key);
23726                         }
23727                     }
23728                 }
23729             }
23730             for (var key in wildcardDirectories) {
23731                 if (ts.hasProperty(wildcardDirectories, key)) {
23732                     for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) {
23733                         var recursiveKey = recursiveKeys_1[_a];
23734                         if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) {
23735                             delete wildcardDirectories[key];
23736                         }
23737                     }
23738                 }
23739             }
23740         }
23741         return wildcardDirectories;
23742     }
23743     function getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames) {
23744         var match = wildcardDirectoryPattern.exec(spec);
23745         if (match) {
23746             return {
23747                 key: useCaseSensitiveFileNames ? match[0] : ts.toFileNameLowerCase(match[0]),
23748                 flags: watchRecursivePattern.test(spec) ? 1 : 0
23749             };
23750         }
23751         if (ts.isImplicitGlob(spec)) {
23752             return { key: spec, flags: 1 };
23753         }
23754         return undefined;
23755     }
23756     function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) {
23757         var extensionPriority = ts.getExtensionPriority(file, extensions);
23758         var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority, extensions);
23759         for (var i = 0; i < adjustedExtensionPriority; i++) {
23760             var higherPriorityExtension = extensions[i];
23761             var higherPriorityPath = keyMapper(ts.changeExtension(file, higherPriorityExtension));
23762             if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) {
23763                 return true;
23764             }
23765         }
23766         return false;
23767     }
23768     function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) {
23769         var extensionPriority = ts.getExtensionPriority(file, extensions);
23770         var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority, extensions);
23771         for (var i = nextExtensionPriority; i < extensions.length; i++) {
23772             var lowerPriorityExtension = extensions[i];
23773             var lowerPriorityPath = keyMapper(ts.changeExtension(file, lowerPriorityExtension));
23774             wildcardFiles.delete(lowerPriorityPath);
23775         }
23776     }
23777     function convertCompilerOptionsForTelemetry(opts) {
23778         var out = {};
23779         for (var key in opts) {
23780             if (opts.hasOwnProperty(key)) {
23781                 var type = getOptionFromName(key);
23782                 if (type !== undefined) {
23783                     out[key] = getOptionValueWithEmptyStrings(opts[key], type);
23784                 }
23785             }
23786         }
23787         return out;
23788     }
23789     ts.convertCompilerOptionsForTelemetry = convertCompilerOptionsForTelemetry;
23790     function getOptionValueWithEmptyStrings(value, option) {
23791         switch (option.type) {
23792             case "object":
23793                 return "";
23794             case "string":
23795                 return "";
23796             case "number":
23797                 return typeof value === "number" ? value : "";
23798             case "boolean":
23799                 return typeof value === "boolean" ? value : "";
23800             case "list":
23801                 var elementType_1 = option.element;
23802                 return ts.isArray(value) ? value.map(function (v) { return getOptionValueWithEmptyStrings(v, elementType_1); }) : "";
23803             default:
23804                 return ts.forEachEntry(option.type, function (optionEnumValue, optionStringValue) {
23805                     if (optionEnumValue === value) {
23806                         return optionStringValue;
23807                     }
23808                 });
23809         }
23810     }
23811 })(ts || (ts = {}));
23812 var ts;
23813 (function (ts) {
23814     function trace(host) {
23815         host.trace(ts.formatMessage.apply(undefined, arguments));
23816     }
23817     ts.trace = trace;
23818     function isTraceEnabled(compilerOptions, host) {
23819         return !!compilerOptions.traceResolution && host.trace !== undefined;
23820     }
23821     ts.isTraceEnabled = isTraceEnabled;
23822     function withPackageId(packageInfo, r) {
23823         var packageId;
23824         if (r && packageInfo) {
23825             var packageJsonContent = packageInfo.packageJsonContent;
23826             if (typeof packageJsonContent.name === "string" && typeof packageJsonContent.version === "string") {
23827                 packageId = {
23828                     name: packageJsonContent.name,
23829                     subModuleName: r.path.slice(packageInfo.packageDirectory.length + ts.directorySeparator.length),
23830                     version: packageJsonContent.version
23831                 };
23832             }
23833         }
23834         return r && { path: r.path, extension: r.ext, packageId: packageId };
23835     }
23836     function noPackageId(r) {
23837         return withPackageId(undefined, r);
23838     }
23839     function removeIgnoredPackageId(r) {
23840         if (r) {
23841             ts.Debug.assert(r.packageId === undefined);
23842             return { path: r.path, ext: r.extension };
23843         }
23844     }
23845     var Extensions;
23846     (function (Extensions) {
23847         Extensions[Extensions["TypeScript"] = 0] = "TypeScript";
23848         Extensions[Extensions["JavaScript"] = 1] = "JavaScript";
23849         Extensions[Extensions["Json"] = 2] = "Json";
23850         Extensions[Extensions["TSConfig"] = 3] = "TSConfig";
23851         Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly";
23852     })(Extensions || (Extensions = {}));
23853     function resolvedTypeScriptOnly(resolved) {
23854         if (!resolved) {
23855             return undefined;
23856         }
23857         ts.Debug.assert(ts.extensionIsTS(resolved.extension));
23858         return { fileName: resolved.path, packageId: resolved.packageId };
23859     }
23860     function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, resultFromCache) {
23861         var _a;
23862         if (resultFromCache) {
23863             (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations);
23864             return resultFromCache;
23865         }
23866         return {
23867             resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId },
23868             failedLookupLocations: failedLookupLocations
23869         };
23870     }
23871     function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) {
23872         if (!ts.hasProperty(jsonContent, fieldName)) {
23873             if (state.traceEnabled) {
23874                 trace(state.host, ts.Diagnostics.package_json_does_not_have_a_0_field, fieldName);
23875             }
23876             return;
23877         }
23878         var value = jsonContent[fieldName];
23879         if (typeof value !== typeOfTag || value === null) {
23880             if (state.traceEnabled) {
23881                 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);
23882             }
23883             return;
23884         }
23885         return value;
23886     }
23887     function readPackageJsonPathField(jsonContent, fieldName, baseDirectory, state) {
23888         var fileName = readPackageJsonField(jsonContent, fieldName, "string", state);
23889         if (fileName === undefined) {
23890             return;
23891         }
23892         if (!fileName) {
23893             if (state.traceEnabled) {
23894                 trace(state.host, ts.Diagnostics.package_json_had_a_falsy_0_field, fieldName);
23895             }
23896             return;
23897         }
23898         var path = ts.normalizePath(ts.combinePaths(baseDirectory, fileName));
23899         if (state.traceEnabled) {
23900             trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, fileName, path);
23901         }
23902         return path;
23903     }
23904     function readPackageJsonTypesFields(jsonContent, baseDirectory, state) {
23905         return readPackageJsonPathField(jsonContent, "typings", baseDirectory, state)
23906             || readPackageJsonPathField(jsonContent, "types", baseDirectory, state);
23907     }
23908     function readPackageJsonTSConfigField(jsonContent, baseDirectory, state) {
23909         return readPackageJsonPathField(jsonContent, "tsconfig", baseDirectory, state);
23910     }
23911     function readPackageJsonMainField(jsonContent, baseDirectory, state) {
23912         return readPackageJsonPathField(jsonContent, "main", baseDirectory, state);
23913     }
23914     function readPackageJsonTypesVersionsField(jsonContent, state) {
23915         var typesVersions = readPackageJsonField(jsonContent, "typesVersions", "object", state);
23916         if (typesVersions === undefined)
23917             return;
23918         if (state.traceEnabled) {
23919             trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_field_with_version_specific_path_mappings);
23920         }
23921         return typesVersions;
23922     }
23923     function readPackageJsonTypesVersionPaths(jsonContent, state) {
23924         var typesVersions = readPackageJsonTypesVersionsField(jsonContent, state);
23925         if (typesVersions === undefined)
23926             return;
23927         if (state.traceEnabled) {
23928             for (var key in typesVersions) {
23929                 if (ts.hasProperty(typesVersions, key) && !ts.VersionRange.tryParse(key)) {
23930                     trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_is_not_a_valid_semver_range, key);
23931                 }
23932             }
23933         }
23934         var result = getPackageJsonTypesVersionsPaths(typesVersions);
23935         if (!result) {
23936             if (state.traceEnabled) {
23937                 trace(state.host, ts.Diagnostics.package_json_does_not_have_a_typesVersions_entry_that_matches_version_0, ts.versionMajorMinor);
23938             }
23939             return;
23940         }
23941         var bestVersionKey = result.version, bestVersionPaths = result.paths;
23942         if (typeof bestVersionPaths !== "object") {
23943             if (state.traceEnabled) {
23944                 trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, "typesVersions['" + bestVersionKey + "']", "object", typeof bestVersionPaths);
23945             }
23946             return;
23947         }
23948         return result;
23949     }
23950     var typeScriptVersion;
23951     function getPackageJsonTypesVersionsPaths(typesVersions) {
23952         if (!typeScriptVersion)
23953             typeScriptVersion = new ts.Version(ts.version);
23954         for (var key in typesVersions) {
23955             if (!ts.hasProperty(typesVersions, key))
23956                 continue;
23957             var keyRange = ts.VersionRange.tryParse(key);
23958             if (keyRange === undefined) {
23959                 continue;
23960             }
23961             if (keyRange.test(typeScriptVersion)) {
23962                 return { version: key, paths: typesVersions[key] };
23963             }
23964         }
23965     }
23966     ts.getPackageJsonTypesVersionsPaths = getPackageJsonTypesVersionsPaths;
23967     function getEffectiveTypeRoots(options, host) {
23968         if (options.typeRoots) {
23969             return options.typeRoots;
23970         }
23971         var currentDirectory;
23972         if (options.configFilePath) {
23973             currentDirectory = ts.getDirectoryPath(options.configFilePath);
23974         }
23975         else if (host.getCurrentDirectory) {
23976             currentDirectory = host.getCurrentDirectory();
23977         }
23978         if (currentDirectory !== undefined) {
23979             return getDefaultTypeRoots(currentDirectory, host);
23980         }
23981     }
23982     ts.getEffectiveTypeRoots = getEffectiveTypeRoots;
23983     function getDefaultTypeRoots(currentDirectory, host) {
23984         if (!host.directoryExists) {
23985             return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)];
23986         }
23987         var typeRoots;
23988         ts.forEachAncestorDirectory(ts.normalizePath(currentDirectory), function (directory) {
23989             var atTypes = ts.combinePaths(directory, nodeModulesAtTypes);
23990             if (host.directoryExists(atTypes)) {
23991                 (typeRoots || (typeRoots = [])).push(atTypes);
23992             }
23993             return undefined;
23994         });
23995         return typeRoots;
23996     }
23997     var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types");
23998     function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference) {
23999         var traceEnabled = isTraceEnabled(options, host);
24000         if (redirectedReference) {
24001             options = redirectedReference.commandLine.options;
24002         }
24003         var failedLookupLocations = [];
24004         var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations };
24005         var typeRoots = getEffectiveTypeRoots(options, host);
24006         if (traceEnabled) {
24007             if (containingFile === undefined) {
24008                 if (typeRoots === undefined) {
24009                     trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set, typeReferenceDirectiveName);
24010                 }
24011                 else {
24012                     trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, typeRoots);
24013                 }
24014             }
24015             else {
24016                 if (typeRoots === undefined) {
24017                     trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set, typeReferenceDirectiveName, containingFile);
24018                 }
24019                 else {
24020                     trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots);
24021                 }
24022             }
24023             if (redirectedReference) {
24024                 trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName);
24025             }
24026         }
24027         var resolved = primaryLookup();
24028         var primary = true;
24029         if (!resolved) {
24030             resolved = secondaryLookup();
24031             primary = false;
24032         }
24033         var resolvedTypeReferenceDirective;
24034         if (resolved) {
24035             var fileName = resolved.fileName, packageId = resolved.packageId;
24036             var resolvedFileName = options.preserveSymlinks ? fileName : realPath(fileName, host, traceEnabled);
24037             if (traceEnabled) {
24038                 if (packageId) {
24039                     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);
24040                 }
24041                 else {
24042                     trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFileName, primary);
24043                 }
24044             }
24045             resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolvedFileName, packageId: packageId, isExternalLibraryImport: pathContainsNodeModules(fileName) };
24046         }
24047         return { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations };
24048         function primaryLookup() {
24049             if (typeRoots && typeRoots.length) {
24050                 if (traceEnabled) {
24051                     trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", "));
24052                 }
24053                 return ts.firstDefined(typeRoots, function (typeRoot) {
24054                     var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName);
24055                     var candidateDirectory = ts.getDirectoryPath(candidate);
24056                     var directoryExists = ts.directoryProbablyExists(candidateDirectory, host);
24057                     if (!directoryExists && traceEnabled) {
24058                         trace(host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidateDirectory);
24059                     }
24060                     return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(Extensions.DtsOnly, candidate, !directoryExists, moduleResolutionState));
24061                 });
24062             }
24063             else {
24064                 if (traceEnabled) {
24065                     trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths);
24066                 }
24067             }
24068         }
24069         function secondaryLookup() {
24070             var initialLocationForSecondaryLookup = containingFile && ts.getDirectoryPath(containingFile);
24071             if (initialLocationForSecondaryLookup !== undefined) {
24072                 if (traceEnabled) {
24073                     trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup);
24074                 }
24075                 var result = void 0;
24076                 if (!ts.isExternalModuleNameRelative(typeReferenceDirectiveName)) {
24077                     var searchResult = loadModuleFromNearestNodeModulesDirectory(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, moduleResolutionState, undefined, undefined);
24078                     result = searchResult && searchResult.value;
24079                 }
24080                 else {
24081                     var candidate = ts.normalizePathAndParts(ts.combinePaths(initialLocationForSecondaryLookup, typeReferenceDirectiveName)).path;
24082                     result = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, false, moduleResolutionState, true);
24083                 }
24084                 var resolvedFile = resolvedTypeScriptOnly(result);
24085                 if (!resolvedFile && traceEnabled) {
24086                     trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName);
24087                 }
24088                 return resolvedFile;
24089             }
24090             else {
24091                 if (traceEnabled) {
24092                     trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder);
24093                 }
24094             }
24095         }
24096     }
24097     ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective;
24098     function getAutomaticTypeDirectiveNames(options, host) {
24099         if (options.types) {
24100             return options.types;
24101         }
24102         var result = [];
24103         if (host.directoryExists && host.getDirectories) {
24104             var typeRoots = getEffectiveTypeRoots(options, host);
24105             if (typeRoots) {
24106                 for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) {
24107                     var root = typeRoots_1[_i];
24108                     if (host.directoryExists(root)) {
24109                         for (var _a = 0, _b = host.getDirectories(root); _a < _b.length; _a++) {
24110                             var typeDirectivePath = _b[_a];
24111                             var normalized = ts.normalizePath(typeDirectivePath);
24112                             var packageJsonPath = ts.combinePaths(root, normalized, "package.json");
24113                             var isNotNeededPackage = host.fileExists(packageJsonPath) && ts.readJson(packageJsonPath, host).typings === null;
24114                             if (!isNotNeededPackage) {
24115                                 var baseFileName = ts.getBaseFileName(normalized);
24116                                 if (baseFileName.charCodeAt(0) !== 46) {
24117                                     result.push(baseFileName);
24118                                 }
24119                             }
24120                         }
24121                     }
24122                 }
24123             }
24124         }
24125         return result;
24126     }
24127     ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames;
24128     function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options) {
24129         return createModuleResolutionCacheWithMaps(createCacheWithRedirects(options), createCacheWithRedirects(options), currentDirectory, getCanonicalFileName);
24130     }
24131     ts.createModuleResolutionCache = createModuleResolutionCache;
24132     function createCacheWithRedirects(options) {
24133         var ownMap = ts.createMap();
24134         var redirectsMap = ts.createMap();
24135         return {
24136             ownMap: ownMap,
24137             redirectsMap: redirectsMap,
24138             getOrCreateMapOfCacheRedirects: getOrCreateMapOfCacheRedirects,
24139             clear: clear,
24140             setOwnOptions: setOwnOptions,
24141             setOwnMap: setOwnMap
24142         };
24143         function setOwnOptions(newOptions) {
24144             options = newOptions;
24145         }
24146         function setOwnMap(newOwnMap) {
24147             ownMap = newOwnMap;
24148         }
24149         function getOrCreateMapOfCacheRedirects(redirectedReference) {
24150             if (!redirectedReference) {
24151                 return ownMap;
24152             }
24153             var path = redirectedReference.sourceFile.path;
24154             var redirects = redirectsMap.get(path);
24155             if (!redirects) {
24156                 redirects = !options || ts.optionsHaveModuleResolutionChanges(options, redirectedReference.commandLine.options) ? ts.createMap() : ownMap;
24157                 redirectsMap.set(path, redirects);
24158             }
24159             return redirects;
24160         }
24161         function clear() {
24162             ownMap.clear();
24163             redirectsMap.clear();
24164         }
24165     }
24166     ts.createCacheWithRedirects = createCacheWithRedirects;
24167     function createModuleResolutionCacheWithMaps(directoryToModuleNameMap, moduleNameToDirectoryMap, currentDirectory, getCanonicalFileName) {
24168         return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, directoryToModuleNameMap: directoryToModuleNameMap, moduleNameToDirectoryMap: moduleNameToDirectoryMap };
24169         function getOrCreateCacheForDirectory(directoryName, redirectedReference) {
24170             var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName);
24171             return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, ts.createMap);
24172         }
24173         function getOrCreateCacheForModuleName(nonRelativeModuleName, redirectedReference) {
24174             ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName));
24175             return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, nonRelativeModuleName, createPerModuleNameCache);
24176         }
24177         function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) {
24178             var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
24179             var result = cache.get(key);
24180             if (!result) {
24181                 result = create();
24182                 cache.set(key, result);
24183             }
24184             return result;
24185         }
24186         function createPerModuleNameCache() {
24187             var directoryPathMap = ts.createMap();
24188             return { get: get, set: set };
24189             function get(directory) {
24190                 return directoryPathMap.get(ts.toPath(directory, currentDirectory, getCanonicalFileName));
24191             }
24192             function set(directory, result) {
24193                 var path = ts.toPath(directory, currentDirectory, getCanonicalFileName);
24194                 if (directoryPathMap.has(path)) {
24195                     return;
24196                 }
24197                 directoryPathMap.set(path, result);
24198                 var resolvedFileName = result.resolvedModule &&
24199                     (result.resolvedModule.originalPath || result.resolvedModule.resolvedFileName);
24200                 var commonPrefix = resolvedFileName && getCommonPrefix(path, resolvedFileName);
24201                 var current = path;
24202                 while (current !== commonPrefix) {
24203                     var parent = ts.getDirectoryPath(current);
24204                     if (parent === current || directoryPathMap.has(parent)) {
24205                         break;
24206                     }
24207                     directoryPathMap.set(parent, result);
24208                     current = parent;
24209                 }
24210             }
24211             function getCommonPrefix(directory, resolution) {
24212                 var resolutionDirectory = ts.toPath(ts.getDirectoryPath(resolution), currentDirectory, getCanonicalFileName);
24213                 var i = 0;
24214                 var limit = Math.min(directory.length, resolutionDirectory.length);
24215                 while (i < limit && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) {
24216                     i++;
24217                 }
24218                 if (i === directory.length && (resolutionDirectory.length === i || resolutionDirectory[i] === ts.directorySeparator)) {
24219                     return directory;
24220                 }
24221                 var rootLength = ts.getRootLength(directory);
24222                 if (i < rootLength) {
24223                     return undefined;
24224                 }
24225                 var sep = directory.lastIndexOf(ts.directorySeparator, i - 1);
24226                 if (sep === -1) {
24227                     return undefined;
24228                 }
24229                 return directory.substr(0, Math.max(sep, rootLength));
24230             }
24231         }
24232     }
24233     ts.createModuleResolutionCacheWithMaps = createModuleResolutionCacheWithMaps;
24234     function resolveModuleNameFromCache(moduleName, containingFile, cache) {
24235         var containingDirectory = ts.getDirectoryPath(containingFile);
24236         var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory);
24237         return perFolderCache && perFolderCache.get(moduleName);
24238     }
24239     ts.resolveModuleNameFromCache = resolveModuleNameFromCache;
24240     function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) {
24241         var traceEnabled = isTraceEnabled(compilerOptions, host);
24242         if (redirectedReference) {
24243             compilerOptions = redirectedReference.commandLine.options;
24244         }
24245         if (traceEnabled) {
24246             trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile);
24247             if (redirectedReference) {
24248                 trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName);
24249             }
24250         }
24251         var containingDirectory = ts.getDirectoryPath(containingFile);
24252         var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference);
24253         var result = perFolderCache && perFolderCache.get(moduleName);
24254         if (result) {
24255             if (traceEnabled) {
24256                 trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
24257             }
24258         }
24259         else {
24260             var moduleResolution = compilerOptions.moduleResolution;
24261             if (moduleResolution === undefined) {
24262                 moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic;
24263                 if (traceEnabled) {
24264                     trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]);
24265                 }
24266             }
24267             else {
24268                 if (traceEnabled) {
24269                     trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]);
24270                 }
24271             }
24272             ts.perfLogger.logStartResolveModule(moduleName);
24273             switch (moduleResolution) {
24274                 case ts.ModuleResolutionKind.NodeJs:
24275                     result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference);
24276                     break;
24277                 case ts.ModuleResolutionKind.Classic:
24278                     result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference);
24279                     break;
24280                 default:
24281                     return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution);
24282             }
24283             if (result && result.resolvedModule)
24284                 ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\"");
24285             ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null");
24286             if (perFolderCache) {
24287                 perFolderCache.set(moduleName, result);
24288                 if (!ts.isExternalModuleNameRelative(moduleName)) {
24289                     cache.getOrCreateCacheForModuleName(moduleName, redirectedReference).set(containingDirectory, result);
24290                 }
24291             }
24292         }
24293         if (traceEnabled) {
24294             if (result.resolvedModule) {
24295                 if (result.resolvedModule.packageId) {
24296                     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));
24297                 }
24298                 else {
24299                     trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName);
24300                 }
24301             }
24302             else {
24303                 trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName);
24304             }
24305         }
24306         return result;
24307     }
24308     ts.resolveModuleName = resolveModuleName;
24309     function tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state) {
24310         var resolved = tryLoadModuleUsingPathsIfEligible(extensions, moduleName, loader, state);
24311         if (resolved)
24312             return resolved.value;
24313         if (!ts.isExternalModuleNameRelative(moduleName)) {
24314             return tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, state);
24315         }
24316         else {
24317             return tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, state);
24318         }
24319     }
24320     function tryLoadModuleUsingPathsIfEligible(extensions, moduleName, loader, state) {
24321         var _a = state.compilerOptions, baseUrl = _a.baseUrl, paths = _a.paths;
24322         if (baseUrl && paths && !ts.pathIsRelative(moduleName)) {
24323             if (state.traceEnabled) {
24324                 trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, baseUrl, moduleName);
24325                 trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName);
24326             }
24327             return tryLoadModuleUsingPaths(extensions, moduleName, baseUrl, paths, loader, false, state);
24328         }
24329     }
24330     function tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, state) {
24331         if (!state.compilerOptions.rootDirs) {
24332             return undefined;
24333         }
24334         if (state.traceEnabled) {
24335             trace(state.host, ts.Diagnostics.rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0, moduleName);
24336         }
24337         var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName));
24338         var matchedRootDir;
24339         var matchedNormalizedPrefix;
24340         for (var _i = 0, _a = state.compilerOptions.rootDirs; _i < _a.length; _i++) {
24341             var rootDir = _a[_i];
24342             var normalizedRoot = ts.normalizePath(rootDir);
24343             if (!ts.endsWith(normalizedRoot, ts.directorySeparator)) {
24344                 normalizedRoot += ts.directorySeparator;
24345             }
24346             var isLongestMatchingPrefix = ts.startsWith(candidate, normalizedRoot) &&
24347                 (matchedNormalizedPrefix === undefined || matchedNormalizedPrefix.length < normalizedRoot.length);
24348             if (state.traceEnabled) {
24349                 trace(state.host, ts.Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix);
24350             }
24351             if (isLongestMatchingPrefix) {
24352                 matchedNormalizedPrefix = normalizedRoot;
24353                 matchedRootDir = rootDir;
24354             }
24355         }
24356         if (matchedNormalizedPrefix) {
24357             if (state.traceEnabled) {
24358                 trace(state.host, ts.Diagnostics.Longest_matching_prefix_for_0_is_1, candidate, matchedNormalizedPrefix);
24359             }
24360             var suffix = candidate.substr(matchedNormalizedPrefix.length);
24361             if (state.traceEnabled) {
24362                 trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate);
24363             }
24364             var resolvedFileName = loader(extensions, candidate, !ts.directoryProbablyExists(containingDirectory, state.host), state);
24365             if (resolvedFileName) {
24366                 return resolvedFileName;
24367             }
24368             if (state.traceEnabled) {
24369                 trace(state.host, ts.Diagnostics.Trying_other_entries_in_rootDirs);
24370             }
24371             for (var _b = 0, _c = state.compilerOptions.rootDirs; _b < _c.length; _b++) {
24372                 var rootDir = _c[_b];
24373                 if (rootDir === matchedRootDir) {
24374                     continue;
24375                 }
24376                 var candidate_1 = ts.combinePaths(ts.normalizePath(rootDir), suffix);
24377                 if (state.traceEnabled) {
24378                     trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate_1);
24379                 }
24380                 var baseDirectory = ts.getDirectoryPath(candidate_1);
24381                 var resolvedFileName_1 = loader(extensions, candidate_1, !ts.directoryProbablyExists(baseDirectory, state.host), state);
24382                 if (resolvedFileName_1) {
24383                     return resolvedFileName_1;
24384                 }
24385             }
24386             if (state.traceEnabled) {
24387                 trace(state.host, ts.Diagnostics.Module_resolution_using_rootDirs_has_failed);
24388             }
24389         }
24390         return undefined;
24391     }
24392     function tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, state) {
24393         var baseUrl = state.compilerOptions.baseUrl;
24394         if (!baseUrl) {
24395             return undefined;
24396         }
24397         if (state.traceEnabled) {
24398             trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, baseUrl, moduleName);
24399         }
24400         var candidate = ts.normalizePath(ts.combinePaths(baseUrl, moduleName));
24401         if (state.traceEnabled) {
24402             trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, baseUrl, candidate);
24403         }
24404         return loader(extensions, candidate, !ts.directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state);
24405     }
24406     function resolveJSModule(moduleName, initialDir, host) {
24407         var _a = tryResolveJSModuleWorker(moduleName, initialDir, host), resolvedModule = _a.resolvedModule, failedLookupLocations = _a.failedLookupLocations;
24408         if (!resolvedModule) {
24409             throw new Error("Could not resolve JS module '" + moduleName + "' starting at '" + initialDir + "'. Looked in: " + failedLookupLocations.join(", "));
24410         }
24411         return resolvedModule.resolvedFileName;
24412     }
24413     ts.resolveJSModule = resolveJSModule;
24414     function tryResolveJSModule(moduleName, initialDir, host) {
24415         var resolvedModule = tryResolveJSModuleWorker(moduleName, initialDir, host).resolvedModule;
24416         return resolvedModule && resolvedModule.resolvedFileName;
24417     }
24418     ts.tryResolveJSModule = tryResolveJSModule;
24419     var jsOnlyExtensions = [Extensions.JavaScript];
24420     var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
24421     var tsPlusJsonExtensions = __spreadArrays(tsExtensions, [Extensions.Json]);
24422     var tsconfigExtensions = [Extensions.TSConfig];
24423     function tryResolveJSModuleWorker(moduleName, initialDir, host) {
24424         return nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, undefined, jsOnlyExtensions, undefined);
24425     }
24426     function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) {
24427         return nodeModuleNameResolverWorker(moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference);
24428     }
24429     ts.nodeModuleNameResolver = nodeModuleNameResolver;
24430     function nodeModuleNameResolverWorker(moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) {
24431         var _a, _b;
24432         var traceEnabled = isTraceEnabled(compilerOptions, host);
24433         var failedLookupLocations = [];
24434         var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations };
24435         var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
24436         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);
24437         function tryResolve(extensions) {
24438             var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, true); };
24439             var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state);
24440             if (resolved) {
24441                 return toSearchResult({ resolved: resolved, isExternalLibraryImport: pathContainsNodeModules(resolved.path) });
24442             }
24443             if (!ts.isExternalModuleNameRelative(moduleName)) {
24444                 if (traceEnabled) {
24445                     trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]);
24446                 }
24447                 var resolved_1 = loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, containingDirectory, state, cache, redirectedReference);
24448                 if (!resolved_1)
24449                     return undefined;
24450                 var resolvedValue = resolved_1.value;
24451                 if (!compilerOptions.preserveSymlinks && resolvedValue && !resolvedValue.originalPath) {
24452                     var path = realPath(resolvedValue.path, host, traceEnabled);
24453                     var originalPath = path === resolvedValue.path ? undefined : resolvedValue.path;
24454                     resolvedValue = __assign(__assign({}, resolvedValue), { path: path, originalPath: originalPath });
24455                 }
24456                 return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } };
24457             }
24458             else {
24459                 var _a = ts.normalizePathAndParts(ts.combinePaths(containingDirectory, moduleName)), candidate = _a.path, parts = _a.parts;
24460                 var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, false, state, true);
24461                 return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: ts.contains(parts, "node_modules") });
24462             }
24463         }
24464     }
24465     function realPath(path, host, traceEnabled) {
24466         if (!host.realpath) {
24467             return path;
24468         }
24469         var real = ts.normalizePath(host.realpath(path));
24470         if (traceEnabled) {
24471             trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real);
24472         }
24473         ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real);
24474         return real;
24475     }
24476     function nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, considerPackageJson) {
24477         if (state.traceEnabled) {
24478             trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1, candidate, Extensions[extensions]);
24479         }
24480         if (!ts.hasTrailingDirectorySeparator(candidate)) {
24481             if (!onlyRecordFailures) {
24482                 var parentOfCandidate = ts.getDirectoryPath(candidate);
24483                 if (!ts.directoryProbablyExists(parentOfCandidate, state.host)) {
24484                     if (state.traceEnabled) {
24485                         trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, parentOfCandidate);
24486                     }
24487                     onlyRecordFailures = true;
24488                 }
24489             }
24490             var resolvedFromFile = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state);
24491             if (resolvedFromFile) {
24492                 var packageDirectory = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile) : undefined;
24493                 var packageInfo = packageDirectory ? getPackageJsonInfo(packageDirectory, false, state) : undefined;
24494                 return withPackageId(packageInfo, resolvedFromFile);
24495             }
24496         }
24497         if (!onlyRecordFailures) {
24498             var candidateExists = ts.directoryProbablyExists(candidate, state.host);
24499             if (!candidateExists) {
24500                 if (state.traceEnabled) {
24501                     trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidate);
24502                 }
24503                 onlyRecordFailures = true;
24504             }
24505         }
24506         return loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson);
24507     }
24508     ts.nodeModulesPathPart = "/node_modules/";
24509     function pathContainsNodeModules(path) {
24510         return ts.stringContains(path, ts.nodeModulesPathPart);
24511     }
24512     ts.pathContainsNodeModules = pathContainsNodeModules;
24513     function parseNodeModuleFromPath(resolved) {
24514         var path = ts.normalizePath(resolved.path);
24515         var idx = path.lastIndexOf(ts.nodeModulesPathPart);
24516         if (idx === -1) {
24517             return undefined;
24518         }
24519         var indexAfterNodeModules = idx + ts.nodeModulesPathPart.length;
24520         var indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterNodeModules);
24521         if (path.charCodeAt(indexAfterNodeModules) === 64) {
24522             indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterPackageName);
24523         }
24524         return path.slice(0, indexAfterPackageName);
24525     }
24526     function moveToNextDirectorySeparatorIfAvailable(path, prevSeparatorIndex) {
24527         var nextSeparatorIndex = path.indexOf(ts.directorySeparator, prevSeparatorIndex + 1);
24528         return nextSeparatorIndex === -1 ? prevSeparatorIndex : nextSeparatorIndex;
24529     }
24530     function loadModuleFromFileNoPackageId(extensions, candidate, onlyRecordFailures, state) {
24531         return noPackageId(loadModuleFromFile(extensions, candidate, onlyRecordFailures, state));
24532     }
24533     function loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) {
24534         if (extensions === Extensions.Json || extensions === Extensions.TSConfig) {
24535             var extensionLess = ts.tryRemoveExtension(candidate, ".json");
24536             return (extensionLess === undefined && extensions === Extensions.Json) ? undefined : tryAddingExtensions(extensionLess || candidate, extensions, onlyRecordFailures, state);
24537         }
24538         var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, onlyRecordFailures, state);
24539         if (resolvedByAddingExtension) {
24540             return resolvedByAddingExtension;
24541         }
24542         if (ts.hasJSFileExtension(candidate)) {
24543             var extensionless = ts.removeFileExtension(candidate);
24544             if (state.traceEnabled) {
24545                 var extension = candidate.substring(extensionless.length);
24546                 trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension);
24547             }
24548             return tryAddingExtensions(extensionless, extensions, onlyRecordFailures, state);
24549         }
24550     }
24551     function tryAddingExtensions(candidate, extensions, onlyRecordFailures, state) {
24552         if (!onlyRecordFailures) {
24553             var directory = ts.getDirectoryPath(candidate);
24554             if (directory) {
24555                 onlyRecordFailures = !ts.directoryProbablyExists(directory, state.host);
24556             }
24557         }
24558         switch (extensions) {
24559             case Extensions.DtsOnly:
24560                 return tryExtension(".d.ts");
24561             case Extensions.TypeScript:
24562                 return tryExtension(".ts") || tryExtension(".tsx") || tryExtension(".d.ts");
24563             case Extensions.JavaScript:
24564                 return tryExtension(".js") || tryExtension(".jsx");
24565             case Extensions.TSConfig:
24566             case Extensions.Json:
24567                 return tryExtension(".json");
24568         }
24569         function tryExtension(ext) {
24570             var path = tryFile(candidate + ext, onlyRecordFailures, state);
24571             return path === undefined ? undefined : { path: path, ext: ext };
24572         }
24573     }
24574     function tryFile(fileName, onlyRecordFailures, state) {
24575         if (!onlyRecordFailures) {
24576             if (state.host.fileExists(fileName)) {
24577                 if (state.traceEnabled) {
24578                     trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName);
24579                 }
24580                 return fileName;
24581             }
24582             else {
24583                 if (state.traceEnabled) {
24584                     trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName);
24585                 }
24586             }
24587         }
24588         state.failedLookupLocations.push(fileName);
24589         return undefined;
24590     }
24591     function loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson) {
24592         if (considerPackageJson === void 0) { considerPackageJson = true; }
24593         var packageInfo = considerPackageJson ? getPackageJsonInfo(candidate, onlyRecordFailures, state) : undefined;
24594         var packageJsonContent = packageInfo && packageInfo.packageJsonContent;
24595         var versionPaths = packageInfo && packageInfo.versionPaths;
24596         return withPackageId(packageInfo, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths));
24597     }
24598     function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
24599         var host = state.host, traceEnabled = state.traceEnabled;
24600         var directoryExists = !onlyRecordFailures && ts.directoryProbablyExists(packageDirectory, host);
24601         var packageJsonPath = ts.combinePaths(packageDirectory, "package.json");
24602         if (directoryExists && host.fileExists(packageJsonPath)) {
24603             var packageJsonContent = ts.readJson(packageJsonPath, host);
24604             if (traceEnabled) {
24605                 trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath);
24606             }
24607             var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
24608             return { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths };
24609         }
24610         else {
24611             if (directoryExists && traceEnabled) {
24612                 trace(host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath);
24613             }
24614             state.failedLookupLocations.push(packageJsonPath);
24615         }
24616     }
24617     function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, jsonContent, versionPaths) {
24618         var packageFile;
24619         if (jsonContent) {
24620             switch (extensions) {
24621                 case Extensions.JavaScript:
24622                 case Extensions.Json:
24623                     packageFile = readPackageJsonMainField(jsonContent, candidate, state);
24624                     break;
24625                 case Extensions.TypeScript:
24626                     packageFile = readPackageJsonTypesFields(jsonContent, candidate, state) || readPackageJsonMainField(jsonContent, candidate, state);
24627                     break;
24628                 case Extensions.DtsOnly:
24629                     packageFile = readPackageJsonTypesFields(jsonContent, candidate, state);
24630                     break;
24631                 case Extensions.TSConfig:
24632                     packageFile = readPackageJsonTSConfigField(jsonContent, candidate, state);
24633                     break;
24634                 default:
24635                     return ts.Debug.assertNever(extensions);
24636             }
24637         }
24638         var loader = function (extensions, candidate, onlyRecordFailures, state) {
24639             var fromFile = tryFile(candidate, onlyRecordFailures, state);
24640             if (fromFile) {
24641                 var resolved = resolvedIfExtensionMatches(extensions, fromFile);
24642                 if (resolved) {
24643                     return noPackageId(resolved);
24644                 }
24645                 if (state.traceEnabled) {
24646                     trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromFile);
24647                 }
24648             }
24649             var nextExtensions = extensions === Extensions.DtsOnly ? Extensions.TypeScript : extensions;
24650             return nodeLoadModuleByRelativeName(nextExtensions, candidate, onlyRecordFailures, state, false);
24651         };
24652         var onlyRecordFailuresForPackageFile = packageFile ? !ts.directoryProbablyExists(ts.getDirectoryPath(packageFile), state.host) : undefined;
24653         var onlyRecordFailuresForIndex = onlyRecordFailures || !ts.directoryProbablyExists(candidate, state.host);
24654         var indexPath = ts.combinePaths(candidate, extensions === Extensions.TSConfig ? "tsconfig" : "index");
24655         if (versionPaths && (!packageFile || ts.containsPath(candidate, packageFile))) {
24656             var moduleName = ts.getRelativePathFromDirectory(candidate, packageFile || indexPath, false);
24657             if (state.traceEnabled) {
24658                 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);
24659             }
24660             var result = tryLoadModuleUsingPaths(extensions, moduleName, candidate, versionPaths.paths, loader, onlyRecordFailuresForPackageFile || onlyRecordFailuresForIndex, state);
24661             if (result) {
24662                 return removeIgnoredPackageId(result.value);
24663             }
24664         }
24665         var packageFileResult = packageFile && removeIgnoredPackageId(loader(extensions, packageFile, onlyRecordFailuresForPackageFile, state));
24666         if (packageFileResult)
24667             return packageFileResult;
24668         return loadModuleFromFile(extensions, indexPath, onlyRecordFailuresForIndex, state);
24669     }
24670     function resolvedIfExtensionMatches(extensions, path) {
24671         var ext = ts.tryGetExtensionFromPath(path);
24672         return ext !== undefined && extensionIsOk(extensions, ext) ? { path: path, ext: ext } : undefined;
24673     }
24674     function extensionIsOk(extensions, extension) {
24675         switch (extensions) {
24676             case Extensions.JavaScript:
24677                 return extension === ".js" || extension === ".jsx";
24678             case Extensions.TSConfig:
24679             case Extensions.Json:
24680                 return extension === ".json";
24681             case Extensions.TypeScript:
24682                 return extension === ".ts" || extension === ".tsx" || extension === ".d.ts";
24683             case Extensions.DtsOnly:
24684                 return extension === ".d.ts";
24685         }
24686     }
24687     function parsePackageName(moduleName) {
24688         var idx = moduleName.indexOf(ts.directorySeparator);
24689         if (moduleName[0] === "@") {
24690             idx = moduleName.indexOf(ts.directorySeparator, idx + 1);
24691         }
24692         return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) };
24693     }
24694     ts.parsePackageName = parsePackageName;
24695     function loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, directory, state, cache, redirectedReference) {
24696         return loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, false, cache, redirectedReference);
24697     }
24698     function loadModuleFromNearestNodeModulesDirectoryTypesScope(moduleName, directory, state) {
24699         return loadModuleFromNearestNodeModulesDirectoryWorker(Extensions.DtsOnly, moduleName, directory, state, true, undefined, undefined);
24700     }
24701     function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) {
24702         var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, redirectedReference);
24703         return ts.forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) {
24704             if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
24705                 var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state);
24706                 if (resolutionFromCache) {
24707                     return resolutionFromCache;
24708                 }
24709                 return toSearchResult(loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, ancestorDirectory, state, typesScopeOnly));
24710             }
24711         });
24712     }
24713     function loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, directory, state, typesScopeOnly) {
24714         var nodeModulesFolder = ts.combinePaths(directory, "node_modules");
24715         var nodeModulesFolderExists = ts.directoryProbablyExists(nodeModulesFolder, state.host);
24716         if (!nodeModulesFolderExists && state.traceEnabled) {
24717             trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesFolder);
24718         }
24719         var packageResult = typesScopeOnly ? undefined : loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, state);
24720         if (packageResult) {
24721             return packageResult;
24722         }
24723         if (extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) {
24724             var nodeModulesAtTypes_1 = ts.combinePaths(nodeModulesFolder, "@types");
24725             var nodeModulesAtTypesExists = nodeModulesFolderExists;
24726             if (nodeModulesFolderExists && !ts.directoryProbablyExists(nodeModulesAtTypes_1, state.host)) {
24727                 if (state.traceEnabled) {
24728                     trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesAtTypes_1);
24729                 }
24730                 nodeModulesAtTypesExists = false;
24731             }
24732             return loadModuleFromSpecificNodeModulesDirectory(Extensions.DtsOnly, mangleScopedPackageNameWithTrace(moduleName, state), nodeModulesAtTypes_1, nodeModulesAtTypesExists, state);
24733         }
24734     }
24735     function loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesDirectory, nodeModulesDirectoryExists, state) {
24736         var candidate = ts.normalizePath(ts.combinePaths(nodeModulesDirectory, moduleName));
24737         var packageInfo = getPackageJsonInfo(candidate, !nodeModulesDirectoryExists, state);
24738         if (packageInfo) {
24739             var fromFile = loadModuleFromFile(extensions, candidate, !nodeModulesDirectoryExists, state);
24740             if (fromFile) {
24741                 return noPackageId(fromFile);
24742             }
24743             var fromDirectory = loadNodeModuleFromDirectoryWorker(extensions, candidate, !nodeModulesDirectoryExists, state, packageInfo.packageJsonContent, packageInfo.versionPaths);
24744             return withPackageId(packageInfo, fromDirectory);
24745         }
24746         var loader = function (extensions, candidate, onlyRecordFailures, state) {
24747             var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
24748                 loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.packageJsonContent, packageInfo && packageInfo.versionPaths);
24749             return withPackageId(packageInfo, pathAndExtension);
24750         };
24751         var _a = parsePackageName(moduleName), packageName = _a.packageName, rest = _a.rest;
24752         if (rest !== "") {
24753             var packageDirectory = ts.combinePaths(nodeModulesDirectory, packageName);
24754             packageInfo = getPackageJsonInfo(packageDirectory, !nodeModulesDirectoryExists, state);
24755             if (packageInfo && packageInfo.versionPaths) {
24756                 if (state.traceEnabled) {
24757                     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);
24758                 }
24759                 var packageDirectoryExists = nodeModulesDirectoryExists && ts.directoryProbablyExists(packageDirectory, state.host);
24760                 var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.versionPaths.paths, loader, !packageDirectoryExists, state);
24761                 if (fromPaths) {
24762                     return fromPaths.value;
24763                 }
24764             }
24765         }
24766         return loader(extensions, candidate, !nodeModulesDirectoryExists, state);
24767     }
24768     function tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, loader, onlyRecordFailures, state) {
24769         var matchedPattern = ts.matchPatternOrExact(ts.getOwnKeys(paths), moduleName);
24770         if (matchedPattern) {
24771             var matchedStar_1 = ts.isString(matchedPattern) ? undefined : ts.matchedText(matchedPattern, moduleName);
24772             var matchedPatternText = ts.isString(matchedPattern) ? matchedPattern : ts.patternText(matchedPattern);
24773             if (state.traceEnabled) {
24774                 trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText);
24775             }
24776             var resolved = ts.forEach(paths[matchedPatternText], function (subst) {
24777                 var path = matchedStar_1 ? subst.replace("*", matchedStar_1) : subst;
24778                 var candidate = ts.normalizePath(ts.combinePaths(baseDirectory, path));
24779                 if (state.traceEnabled) {
24780                     trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path);
24781                 }
24782                 var extension = ts.tryGetExtensionFromPath(candidate);
24783                 if (extension !== undefined) {
24784                     var path_1 = tryFile(candidate, onlyRecordFailures, state);
24785                     if (path_1 !== undefined) {
24786                         return noPackageId({ path: path_1, ext: extension });
24787                     }
24788                 }
24789                 return loader(extensions, candidate, onlyRecordFailures || !ts.directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state);
24790             });
24791             return { value: resolved };
24792         }
24793     }
24794     var mangledScopedPackageSeparator = "__";
24795     function mangleScopedPackageNameWithTrace(packageName, state) {
24796         var mangled = mangleScopedPackageName(packageName);
24797         if (state.traceEnabled && mangled !== packageName) {
24798             trace(state.host, ts.Diagnostics.Scoped_package_detected_looking_in_0, mangled);
24799         }
24800         return mangled;
24801     }
24802     function getTypesPackageName(packageName) {
24803         return "@types/" + mangleScopedPackageName(packageName);
24804     }
24805     ts.getTypesPackageName = getTypesPackageName;
24806     function mangleScopedPackageName(packageName) {
24807         if (ts.startsWith(packageName, "@")) {
24808             var replaceSlash = packageName.replace(ts.directorySeparator, mangledScopedPackageSeparator);
24809             if (replaceSlash !== packageName) {
24810                 return replaceSlash.slice(1);
24811             }
24812         }
24813         return packageName;
24814     }
24815     ts.mangleScopedPackageName = mangleScopedPackageName;
24816     function getPackageNameFromTypesPackageName(mangledName) {
24817         var withoutAtTypePrefix = ts.removePrefix(mangledName, "@types/");
24818         if (withoutAtTypePrefix !== mangledName) {
24819             return unmangleScopedPackageName(withoutAtTypePrefix);
24820         }
24821         return mangledName;
24822     }
24823     ts.getPackageNameFromTypesPackageName = getPackageNameFromTypesPackageName;
24824     function unmangleScopedPackageName(typesPackageName) {
24825         return ts.stringContains(typesPackageName, mangledScopedPackageSeparator) ?
24826             "@" + typesPackageName.replace(mangledScopedPackageSeparator, ts.directorySeparator) :
24827             typesPackageName;
24828     }
24829     ts.unmangleScopedPackageName = unmangleScopedPackageName;
24830     function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, state) {
24831         var result = cache && cache.get(containingDirectory);
24832         if (result) {
24833             if (state.traceEnabled) {
24834                 trace(state.host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
24835             }
24836             state.resultFromCache = result;
24837             return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, originalPath: result.resolvedModule.originalPath || true, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId } };
24838         }
24839     }
24840     function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) {
24841         var traceEnabled = isTraceEnabled(compilerOptions, host);
24842         var failedLookupLocations = [];
24843         var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations };
24844         var containingDirectory = ts.getDirectoryPath(containingFile);
24845         var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript);
24846         return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, false, failedLookupLocations, state.resultFromCache);
24847         function tryResolve(extensions) {
24848             var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state);
24849             if (resolvedUsingSettings) {
24850                 return { value: resolvedUsingSettings };
24851             }
24852             if (!ts.isExternalModuleNameRelative(moduleName)) {
24853                 var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName, redirectedReference);
24854                 var resolved_3 = ts.forEachAncestorDirectory(containingDirectory, function (directory) {
24855                     var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache_1, moduleName, directory, state);
24856                     if (resolutionFromCache) {
24857                         return resolutionFromCache;
24858                     }
24859                     var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName));
24860                     return toSearchResult(loadModuleFromFileNoPackageId(extensions, searchName, false, state));
24861                 });
24862                 if (resolved_3) {
24863                     return resolved_3;
24864                 }
24865                 if (extensions === Extensions.TypeScript) {
24866                     return loadModuleFromNearestNodeModulesDirectoryTypesScope(moduleName, containingDirectory, state);
24867                 }
24868             }
24869             else {
24870                 var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName));
24871                 return toSearchResult(loadModuleFromFileNoPackageId(extensions, candidate, false, state));
24872             }
24873         }
24874     }
24875     ts.classicNameResolver = classicNameResolver;
24876     function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache) {
24877         var traceEnabled = isTraceEnabled(compilerOptions, host);
24878         if (traceEnabled) {
24879             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);
24880         }
24881         var failedLookupLocations = [];
24882         var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations };
24883         var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, false);
24884         return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations, state.resultFromCache);
24885     }
24886     ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache;
24887     function toSearchResult(value) {
24888         return value !== undefined ? { value: value } : undefined;
24889     }
24890 })(ts || (ts = {}));
24891 var ts;
24892 (function (ts) {
24893     function getModuleInstanceState(node, visited) {
24894         if (node.body && !node.body.parent) {
24895             setParentPointers(node, node.body);
24896         }
24897         return node.body ? getModuleInstanceStateCached(node.body, visited) : 1;
24898     }
24899     ts.getModuleInstanceState = getModuleInstanceState;
24900     function getModuleInstanceStateCached(node, visited) {
24901         if (visited === void 0) { visited = ts.createMap(); }
24902         var nodeId = "" + ts.getNodeId(node);
24903         if (visited.has(nodeId)) {
24904             return visited.get(nodeId) || 0;
24905         }
24906         visited.set(nodeId, undefined);
24907         var result = getModuleInstanceStateWorker(node, visited);
24908         visited.set(nodeId, result);
24909         return result;
24910     }
24911     function getModuleInstanceStateWorker(node, visited) {
24912         switch (node.kind) {
24913             case 246:
24914             case 247:
24915                 return 0;
24916             case 248:
24917                 if (ts.isEnumConst(node)) {
24918                     return 2;
24919                 }
24920                 break;
24921             case 254:
24922             case 253:
24923                 if (!(ts.hasModifier(node, 1))) {
24924                     return 0;
24925                 }
24926                 break;
24927             case 260:
24928                 var exportDeclaration = node;
24929                 if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 261) {
24930                     var state = 0;
24931                     for (var _i = 0, _a = exportDeclaration.exportClause.elements; _i < _a.length; _i++) {
24932                         var specifier = _a[_i];
24933                         var specifierState = getModuleInstanceStateForAliasTarget(specifier, visited);
24934                         if (specifierState > state) {
24935                             state = specifierState;
24936                         }
24937                         if (state === 1) {
24938                             return state;
24939                         }
24940                     }
24941                     return state;
24942                 }
24943                 break;
24944             case 250: {
24945                 var state_1 = 0;
24946                 ts.forEachChild(node, function (n) {
24947                     var childState = getModuleInstanceStateCached(n, visited);
24948                     switch (childState) {
24949                         case 0:
24950                             return;
24951                         case 2:
24952                             state_1 = 2;
24953                             return;
24954                         case 1:
24955                             state_1 = 1;
24956                             return true;
24957                         default:
24958                             ts.Debug.assertNever(childState);
24959                     }
24960                 });
24961                 return state_1;
24962             }
24963             case 249:
24964                 return getModuleInstanceState(node, visited);
24965             case 75:
24966                 if (node.isInJSDocNamespace) {
24967                     return 0;
24968                 }
24969         }
24970         return 1;
24971     }
24972     function getModuleInstanceStateForAliasTarget(specifier, visited) {
24973         var name = specifier.propertyName || specifier.name;
24974         var p = specifier.parent;
24975         while (p) {
24976             if (ts.isBlock(p) || ts.isModuleBlock(p) || ts.isSourceFile(p)) {
24977                 var statements = p.statements;
24978                 var found = void 0;
24979                 for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) {
24980                     var statement = statements_1[_i];
24981                     if (ts.nodeHasName(statement, name)) {
24982                         if (!statement.parent) {
24983                             setParentPointers(p, statement);
24984                         }
24985                         var state = getModuleInstanceStateCached(statement, visited);
24986                         if (found === undefined || state > found) {
24987                             found = state;
24988                         }
24989                         if (found === 1) {
24990                             return found;
24991                         }
24992                     }
24993                 }
24994                 if (found !== undefined) {
24995                     return found;
24996                 }
24997             }
24998             p = p.parent;
24999         }
25000         return 1;
25001     }
25002     function initFlowNode(node) {
25003         ts.Debug.attachFlowNodeDebugInfo(node);
25004         return node;
25005     }
25006     var binder = createBinder();
25007     function bindSourceFile(file, options) {
25008         ts.performance.mark("beforeBind");
25009         ts.perfLogger.logStartBindFile("" + file.fileName);
25010         binder(file, options);
25011         ts.perfLogger.logStopBindFile();
25012         ts.performance.mark("afterBind");
25013         ts.performance.measure("Bind", "beforeBind", "afterBind");
25014     }
25015     ts.bindSourceFile = bindSourceFile;
25016     function createBinder() {
25017         var file;
25018         var options;
25019         var languageVersion;
25020         var parent;
25021         var container;
25022         var thisParentContainer;
25023         var blockScopeContainer;
25024         var lastContainer;
25025         var delayedTypeAliases;
25026         var seenThisKeyword;
25027         var currentFlow;
25028         var currentBreakTarget;
25029         var currentContinueTarget;
25030         var currentReturnTarget;
25031         var currentTrueTarget;
25032         var currentFalseTarget;
25033         var currentExceptionTarget;
25034         var preSwitchCaseFlow;
25035         var activeLabelList;
25036         var hasExplicitReturn;
25037         var emitFlags;
25038         var inStrictMode;
25039         var symbolCount = 0;
25040         var Symbol;
25041         var classifiableNames;
25042         var unreachableFlow = { flags: 1 };
25043         var reportedUnreachableFlow = { flags: 1 };
25044         var subtreeTransformFlags = 0;
25045         var skipTransformFlagAggregation;
25046         function createDiagnosticForNode(node, message, arg0, arg1, arg2) {
25047             return ts.createDiagnosticForNodeInSourceFile(ts.getSourceFileOfNode(node) || file, node, message, arg0, arg1, arg2);
25048         }
25049         function bindSourceFile(f, opts) {
25050             file = f;
25051             options = opts;
25052             languageVersion = ts.getEmitScriptTarget(options);
25053             inStrictMode = bindInStrictMode(file, opts);
25054             classifiableNames = ts.createUnderscoreEscapedMap();
25055             symbolCount = 0;
25056             skipTransformFlagAggregation = file.isDeclarationFile;
25057             Symbol = ts.objectAllocator.getSymbolConstructor();
25058             ts.Debug.attachFlowNodeDebugInfo(unreachableFlow);
25059             ts.Debug.attachFlowNodeDebugInfo(reportedUnreachableFlow);
25060             if (!file.locals) {
25061                 bind(file);
25062                 file.symbolCount = symbolCount;
25063                 file.classifiableNames = classifiableNames;
25064                 delayedBindJSDocTypedefTag();
25065             }
25066             file = undefined;
25067             options = undefined;
25068             languageVersion = undefined;
25069             parent = undefined;
25070             container = undefined;
25071             thisParentContainer = undefined;
25072             blockScopeContainer = undefined;
25073             lastContainer = undefined;
25074             delayedTypeAliases = undefined;
25075             seenThisKeyword = false;
25076             currentFlow = undefined;
25077             currentBreakTarget = undefined;
25078             currentContinueTarget = undefined;
25079             currentReturnTarget = undefined;
25080             currentTrueTarget = undefined;
25081             currentFalseTarget = undefined;
25082             currentExceptionTarget = undefined;
25083             activeLabelList = undefined;
25084             hasExplicitReturn = false;
25085             emitFlags = 0;
25086             subtreeTransformFlags = 0;
25087         }
25088         return bindSourceFile;
25089         function bindInStrictMode(file, opts) {
25090             if (ts.getStrictOptionValue(opts, "alwaysStrict") && !file.isDeclarationFile) {
25091                 return true;
25092             }
25093             else {
25094                 return !!file.externalModuleIndicator;
25095             }
25096         }
25097         function createSymbol(flags, name) {
25098             symbolCount++;
25099             return new Symbol(flags, name);
25100         }
25101         function addDeclarationToSymbol(symbol, node, symbolFlags) {
25102             symbol.flags |= symbolFlags;
25103             node.symbol = symbol;
25104             symbol.declarations = ts.appendIfUnique(symbol.declarations, node);
25105             if (symbolFlags & (32 | 384 | 1536 | 3) && !symbol.exports) {
25106                 symbol.exports = ts.createSymbolTable();
25107             }
25108             if (symbolFlags & (32 | 64 | 2048 | 4096) && !symbol.members) {
25109                 symbol.members = ts.createSymbolTable();
25110             }
25111             if (symbol.constEnumOnlyModule && (symbol.flags & (16 | 32 | 256))) {
25112                 symbol.constEnumOnlyModule = false;
25113             }
25114             if (symbolFlags & 111551) {
25115                 ts.setValueDeclaration(symbol, node);
25116             }
25117         }
25118         function getDeclarationName(node) {
25119             if (node.kind === 259) {
25120                 return node.isExportEquals ? "export=" : "default";
25121             }
25122             var name = ts.getNameOfDeclaration(node);
25123             if (name) {
25124                 if (ts.isAmbientModule(node)) {
25125                     var moduleName = ts.getTextOfIdentifierOrLiteral(name);
25126                     return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\"");
25127                 }
25128                 if (name.kind === 154) {
25129                     var nameExpression = name.expression;
25130                     if (ts.isStringOrNumericLiteralLike(nameExpression)) {
25131                         return ts.escapeLeadingUnderscores(nameExpression.text);
25132                     }
25133                     if (ts.isSignedNumericLiteral(nameExpression)) {
25134                         return ts.tokenToString(nameExpression.operator) + nameExpression.operand.text;
25135                     }
25136                     ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression));
25137                     return ts.getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name));
25138                 }
25139                 if (ts.isWellKnownSymbolSyntactically(name)) {
25140                     return ts.getPropertyNameForKnownSymbolName(ts.idText(name.name));
25141                 }
25142                 if (ts.isPrivateIdentifier(name)) {
25143                     var containingClass = ts.getContainingClass(node);
25144                     if (!containingClass) {
25145                         return undefined;
25146                     }
25147                     var containingClassSymbol = containingClass.symbol;
25148                     return ts.getSymbolNameForPrivateIdentifier(containingClassSymbol, name.escapedText);
25149                 }
25150                 return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined;
25151             }
25152             switch (node.kind) {
25153                 case 162:
25154                     return "__constructor";
25155                 case 170:
25156                 case 165:
25157                 case 305:
25158                     return "__call";
25159                 case 171:
25160                 case 166:
25161                     return "__new";
25162                 case 167:
25163                     return "__index";
25164                 case 260:
25165                     return "__export";
25166                 case 290:
25167                     return "export=";
25168                 case 209:
25169                     if (ts.getAssignmentDeclarationKind(node) === 2) {
25170                         return "export=";
25171                     }
25172                     ts.Debug.fail("Unknown binary declaration kind");
25173                     break;
25174                 case 300:
25175                     return (ts.isJSDocConstructSignature(node) ? "__new" : "__call");
25176                 case 156:
25177                     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"; });
25178                     var functionType = node.parent;
25179                     var index = functionType.parameters.indexOf(node);
25180                     return "arg" + index;
25181             }
25182         }
25183         function getDisplayName(node) {
25184             return ts.isNamedDeclaration(node) ? ts.declarationNameToString(node.name) : ts.unescapeLeadingUnderscores(ts.Debug.checkDefined(getDeclarationName(node)));
25185         }
25186         function declareSymbol(symbolTable, parent, node, includes, excludes, isReplaceableByMethod) {
25187             ts.Debug.assert(!ts.hasDynamicName(node));
25188             var isDefaultExport = ts.hasModifier(node, 512) || ts.isExportSpecifier(node) && node.name.escapedText === "default";
25189             var name = isDefaultExport && parent ? "default" : getDeclarationName(node);
25190             var symbol;
25191             if (name === undefined) {
25192                 symbol = createSymbol(0, "__missing");
25193             }
25194             else {
25195                 symbol = symbolTable.get(name);
25196                 if (includes & 2885600) {
25197                     classifiableNames.set(name, true);
25198                 }
25199                 if (!symbol) {
25200                     symbolTable.set(name, symbol = createSymbol(0, name));
25201                     if (isReplaceableByMethod)
25202                         symbol.isReplaceableByMethod = true;
25203                 }
25204                 else if (isReplaceableByMethod && !symbol.isReplaceableByMethod) {
25205                     return symbol;
25206                 }
25207                 else if (symbol.flags & excludes) {
25208                     if (symbol.isReplaceableByMethod) {
25209                         symbolTable.set(name, symbol = createSymbol(0, name));
25210                     }
25211                     else if (!(includes & 3 && symbol.flags & 67108864)) {
25212                         if (ts.isNamedDeclaration(node)) {
25213                             node.name.parent = node;
25214                         }
25215                         var message_1 = symbol.flags & 2
25216                             ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0
25217                             : ts.Diagnostics.Duplicate_identifier_0;
25218                         var messageNeedsName_1 = true;
25219                         if (symbol.flags & 384 || includes & 384) {
25220                             message_1 = ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations;
25221                             messageNeedsName_1 = false;
25222                         }
25223                         var multipleDefaultExports_1 = false;
25224                         if (ts.length(symbol.declarations)) {
25225                             if (isDefaultExport) {
25226                                 message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports;
25227                                 messageNeedsName_1 = false;
25228                                 multipleDefaultExports_1 = true;
25229                             }
25230                             else {
25231                                 if (symbol.declarations && symbol.declarations.length &&
25232                                     (node.kind === 259 && !node.isExportEquals)) {
25233                                     message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports;
25234                                     messageNeedsName_1 = false;
25235                                     multipleDefaultExports_1 = true;
25236                                 }
25237                             }
25238                         }
25239                         var relatedInformation_1 = [];
25240                         if (ts.isTypeAliasDeclaration(node) && ts.nodeIsMissing(node.type) && ts.hasModifier(node, 1) && symbol.flags & (2097152 | 788968 | 1920)) {
25241                             relatedInformation_1.push(createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_0, "export type { " + ts.unescapeLeadingUnderscores(node.name.escapedText) + " }"));
25242                         }
25243                         var declarationName_1 = ts.getNameOfDeclaration(node) || node;
25244                         ts.forEach(symbol.declarations, function (declaration, index) {
25245                             var decl = ts.getNameOfDeclaration(declaration) || declaration;
25246                             var diag = createDiagnosticForNode(decl, message_1, messageNeedsName_1 ? getDisplayName(declaration) : undefined);
25247                             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);
25248                             if (multipleDefaultExports_1) {
25249                                 relatedInformation_1.push(createDiagnosticForNode(decl, ts.Diagnostics.The_first_export_default_is_here));
25250                             }
25251                         });
25252                         var diag = createDiagnosticForNode(declarationName_1, message_1, messageNeedsName_1 ? getDisplayName(node) : undefined);
25253                         file.bindDiagnostics.push(ts.addRelatedInfo.apply(void 0, __spreadArrays([diag], relatedInformation_1)));
25254                         symbol = createSymbol(0, name);
25255                     }
25256                 }
25257             }
25258             addDeclarationToSymbol(symbol, node, includes);
25259             if (symbol.parent) {
25260                 ts.Debug.assert(symbol.parent === parent, "Existing symbol parent should match new one");
25261             }
25262             else {
25263                 symbol.parent = parent;
25264             }
25265             return symbol;
25266         }
25267         function declareModuleMember(node, symbolFlags, symbolExcludes) {
25268             var hasExportModifier = ts.getCombinedModifierFlags(node) & 1;
25269             if (symbolFlags & 2097152) {
25270                 if (node.kind === 263 || (node.kind === 253 && hasExportModifier)) {
25271                     return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
25272                 }
25273                 else {
25274                     return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes);
25275                 }
25276             }
25277             else {
25278                 if (ts.isJSDocTypeAlias(node))
25279                     ts.Debug.assert(ts.isInJSFile(node));
25280                 if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64)) || ts.isJSDocTypeAlias(node)) {
25281                     if (!container.locals || (ts.hasModifier(node, 512) && !getDeclarationName(node))) {
25282                         return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
25283                     }
25284                     var exportKind = symbolFlags & 111551 ? 1048576 : 0;
25285                     var local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes);
25286                     local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
25287                     node.localSymbol = local;
25288                     return local;
25289                 }
25290                 else {
25291                     return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes);
25292                 }
25293             }
25294         }
25295         function bindContainer(node, containerFlags) {
25296             var saveContainer = container;
25297             var saveThisParentContainer = thisParentContainer;
25298             var savedBlockScopeContainer = blockScopeContainer;
25299             if (containerFlags & 1) {
25300                 if (node.kind !== 202) {
25301                     thisParentContainer = container;
25302                 }
25303                 container = blockScopeContainer = node;
25304                 if (containerFlags & 32) {
25305                     container.locals = ts.createSymbolTable();
25306                 }
25307                 addToContainerChain(container);
25308             }
25309             else if (containerFlags & 2) {
25310                 blockScopeContainer = node;
25311                 blockScopeContainer.locals = undefined;
25312             }
25313             if (containerFlags & 4) {
25314                 var saveCurrentFlow = currentFlow;
25315                 var saveBreakTarget = currentBreakTarget;
25316                 var saveContinueTarget = currentContinueTarget;
25317                 var saveReturnTarget = currentReturnTarget;
25318                 var saveExceptionTarget = currentExceptionTarget;
25319                 var saveActiveLabelList = activeLabelList;
25320                 var saveHasExplicitReturn = hasExplicitReturn;
25321                 var isIIFE = containerFlags & 16 && !ts.hasModifier(node, 256) &&
25322                     !node.asteriskToken && !!ts.getImmediatelyInvokedFunctionExpression(node);
25323                 if (!isIIFE) {
25324                     currentFlow = initFlowNode({ flags: 2 });
25325                     if (containerFlags & (16 | 128)) {
25326                         currentFlow.node = node;
25327                     }
25328                 }
25329                 currentReturnTarget = isIIFE || node.kind === 162 ? createBranchLabel() : undefined;
25330                 currentExceptionTarget = undefined;
25331                 currentBreakTarget = undefined;
25332                 currentContinueTarget = undefined;
25333                 activeLabelList = undefined;
25334                 hasExplicitReturn = false;
25335                 bindChildren(node);
25336                 node.flags &= ~2816;
25337                 if (!(currentFlow.flags & 1) && containerFlags & 8 && ts.nodeIsPresent(node.body)) {
25338                     node.flags |= 256;
25339                     if (hasExplicitReturn)
25340                         node.flags |= 512;
25341                     node.endFlowNode = currentFlow;
25342                 }
25343                 if (node.kind === 290) {
25344                     node.flags |= emitFlags;
25345                 }
25346                 if (currentReturnTarget) {
25347                     addAntecedent(currentReturnTarget, currentFlow);
25348                     currentFlow = finishFlowLabel(currentReturnTarget);
25349                     if (node.kind === 162) {
25350                         node.returnFlowNode = currentFlow;
25351                     }
25352                 }
25353                 if (!isIIFE) {
25354                     currentFlow = saveCurrentFlow;
25355                 }
25356                 currentBreakTarget = saveBreakTarget;
25357                 currentContinueTarget = saveContinueTarget;
25358                 currentReturnTarget = saveReturnTarget;
25359                 currentExceptionTarget = saveExceptionTarget;
25360                 activeLabelList = saveActiveLabelList;
25361                 hasExplicitReturn = saveHasExplicitReturn;
25362             }
25363             else if (containerFlags & 64) {
25364                 seenThisKeyword = false;
25365                 bindChildren(node);
25366                 node.flags = seenThisKeyword ? node.flags | 128 : node.flags & ~128;
25367             }
25368             else {
25369                 bindChildren(node);
25370             }
25371             container = saveContainer;
25372             thisParentContainer = saveThisParentContainer;
25373             blockScopeContainer = savedBlockScopeContainer;
25374         }
25375         function bindChildren(node) {
25376             if (skipTransformFlagAggregation) {
25377                 bindChildrenWorker(node);
25378             }
25379             else if (node.transformFlags & 536870912) {
25380                 skipTransformFlagAggregation = true;
25381                 bindChildrenWorker(node);
25382                 skipTransformFlagAggregation = false;
25383                 subtreeTransformFlags |= node.transformFlags & ~getTransformFlagsSubtreeExclusions(node.kind);
25384             }
25385             else {
25386                 var savedSubtreeTransformFlags = subtreeTransformFlags;
25387                 subtreeTransformFlags = 0;
25388                 bindChildrenWorker(node);
25389                 subtreeTransformFlags = savedSubtreeTransformFlags | computeTransformFlagsForNode(node, subtreeTransformFlags);
25390             }
25391         }
25392         function bindEachFunctionsFirst(nodes) {
25393             bindEach(nodes, function (n) { return n.kind === 244 ? bind(n) : undefined; });
25394             bindEach(nodes, function (n) { return n.kind !== 244 ? bind(n) : undefined; });
25395         }
25396         function bindEach(nodes, bindFunction) {
25397             if (bindFunction === void 0) { bindFunction = bind; }
25398             if (nodes === undefined) {
25399                 return;
25400             }
25401             if (skipTransformFlagAggregation) {
25402                 ts.forEach(nodes, bindFunction);
25403             }
25404             else {
25405                 var savedSubtreeTransformFlags = subtreeTransformFlags;
25406                 subtreeTransformFlags = 0;
25407                 var nodeArrayFlags = 0;
25408                 for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) {
25409                     var node = nodes_2[_i];
25410                     bindFunction(node);
25411                     nodeArrayFlags |= node.transformFlags & ~536870912;
25412                 }
25413                 nodes.transformFlags = nodeArrayFlags | 536870912;
25414                 subtreeTransformFlags |= savedSubtreeTransformFlags;
25415             }
25416         }
25417         function bindEachChild(node) {
25418             ts.forEachChild(node, bind, bindEach);
25419         }
25420         function bindChildrenWorker(node) {
25421             if (checkUnreachable(node)) {
25422                 bindEachChild(node);
25423                 bindJSDoc(node);
25424                 return;
25425             }
25426             if (node.kind >= 225 && node.kind <= 241 && !options.allowUnreachableCode) {
25427                 node.flowNode = currentFlow;
25428             }
25429             switch (node.kind) {
25430                 case 229:
25431                     bindWhileStatement(node);
25432                     break;
25433                 case 228:
25434                     bindDoStatement(node);
25435                     break;
25436                 case 230:
25437                     bindForStatement(node);
25438                     break;
25439                 case 231:
25440                 case 232:
25441                     bindForInOrForOfStatement(node);
25442                     break;
25443                 case 227:
25444                     bindIfStatement(node);
25445                     break;
25446                 case 235:
25447                 case 239:
25448                     bindReturnOrThrow(node);
25449                     break;
25450                 case 234:
25451                 case 233:
25452                     bindBreakOrContinueStatement(node);
25453                     break;
25454                 case 240:
25455                     bindTryStatement(node);
25456                     break;
25457                 case 237:
25458                     bindSwitchStatement(node);
25459                     break;
25460                 case 251:
25461                     bindCaseBlock(node);
25462                     break;
25463                 case 277:
25464                     bindCaseClause(node);
25465                     break;
25466                 case 226:
25467                     bindExpressionStatement(node);
25468                     break;
25469                 case 238:
25470                     bindLabeledStatement(node);
25471                     break;
25472                 case 207:
25473                     bindPrefixUnaryExpressionFlow(node);
25474                     break;
25475                 case 208:
25476                     bindPostfixUnaryExpressionFlow(node);
25477                     break;
25478                 case 209:
25479                     bindBinaryExpressionFlow(node);
25480                     break;
25481                 case 203:
25482                     bindDeleteExpressionFlow(node);
25483                     break;
25484                 case 210:
25485                     bindConditionalExpressionFlow(node);
25486                     break;
25487                 case 242:
25488                     bindVariableDeclarationFlow(node);
25489                     break;
25490                 case 194:
25491                 case 195:
25492                     bindAccessExpressionFlow(node);
25493                     break;
25494                 case 196:
25495                     bindCallExpressionFlow(node);
25496                     break;
25497                 case 218:
25498                     bindNonNullExpressionFlow(node);
25499                     break;
25500                 case 322:
25501                 case 315:
25502                 case 316:
25503                     bindJSDocTypeAlias(node);
25504                     break;
25505                 case 290: {
25506                     bindEachFunctionsFirst(node.statements);
25507                     bind(node.endOfFileToken);
25508                     break;
25509                 }
25510                 case 223:
25511                 case 250:
25512                     bindEachFunctionsFirst(node.statements);
25513                     break;
25514                 default:
25515                     bindEachChild(node);
25516                     break;
25517             }
25518             bindJSDoc(node);
25519         }
25520         function isNarrowingExpression(expr) {
25521             switch (expr.kind) {
25522                 case 75:
25523                 case 104:
25524                 case 194:
25525                 case 195:
25526                     return containsNarrowableReference(expr);
25527                 case 196:
25528                     return hasNarrowableArgument(expr);
25529                 case 200:
25530                     return isNarrowingExpression(expr.expression);
25531                 case 209:
25532                     return isNarrowingBinaryExpression(expr);
25533                 case 207:
25534                     return expr.operator === 53 && isNarrowingExpression(expr.operand);
25535                 case 204:
25536                     return isNarrowingExpression(expr.expression);
25537             }
25538             return false;
25539         }
25540         function isNarrowableReference(expr) {
25541             return expr.kind === 75 || expr.kind === 104 || expr.kind === 102 ||
25542                 (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) ||
25543                 ts.isElementAccessExpression(expr) && ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression);
25544         }
25545         function containsNarrowableReference(expr) {
25546             return isNarrowableReference(expr) || ts.isOptionalChain(expr) && containsNarrowableReference(expr.expression);
25547         }
25548         function hasNarrowableArgument(expr) {
25549             if (expr.arguments) {
25550                 for (var _i = 0, _a = expr.arguments; _i < _a.length; _i++) {
25551                     var argument = _a[_i];
25552                     if (containsNarrowableReference(argument)) {
25553                         return true;
25554                     }
25555                 }
25556             }
25557             if (expr.expression.kind === 194 &&
25558                 containsNarrowableReference(expr.expression.expression)) {
25559                 return true;
25560             }
25561             return false;
25562         }
25563         function isNarrowingTypeofOperands(expr1, expr2) {
25564             return ts.isTypeOfExpression(expr1) && isNarrowableOperand(expr1.expression) && ts.isStringLiteralLike(expr2);
25565         }
25566         function isNarrowableInOperands(left, right) {
25567             return ts.isStringLiteralLike(left) && isNarrowingExpression(right);
25568         }
25569         function isNarrowingBinaryExpression(expr) {
25570             switch (expr.operatorToken.kind) {
25571                 case 62:
25572                     return containsNarrowableReference(expr.left);
25573                 case 34:
25574                 case 35:
25575                 case 36:
25576                 case 37:
25577                     return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) ||
25578                         isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right);
25579                 case 98:
25580                     return isNarrowableOperand(expr.left);
25581                 case 97:
25582                     return isNarrowableInOperands(expr.left, expr.right);
25583                 case 27:
25584                     return isNarrowingExpression(expr.right);
25585             }
25586             return false;
25587         }
25588         function isNarrowableOperand(expr) {
25589             switch (expr.kind) {
25590                 case 200:
25591                     return isNarrowableOperand(expr.expression);
25592                 case 209:
25593                     switch (expr.operatorToken.kind) {
25594                         case 62:
25595                             return isNarrowableOperand(expr.left);
25596                         case 27:
25597                             return isNarrowableOperand(expr.right);
25598                     }
25599             }
25600             return containsNarrowableReference(expr);
25601         }
25602         function createBranchLabel() {
25603             return initFlowNode({ flags: 4, antecedents: undefined });
25604         }
25605         function createLoopLabel() {
25606             return initFlowNode({ flags: 8, antecedents: undefined });
25607         }
25608         function createReduceLabel(target, antecedents, antecedent) {
25609             return initFlowNode({ flags: 1024, target: target, antecedents: antecedents, antecedent: antecedent });
25610         }
25611         function setFlowNodeReferenced(flow) {
25612             flow.flags |= flow.flags & 2048 ? 4096 : 2048;
25613         }
25614         function addAntecedent(label, antecedent) {
25615             if (!(antecedent.flags & 1) && !ts.contains(label.antecedents, antecedent)) {
25616                 (label.antecedents || (label.antecedents = [])).push(antecedent);
25617                 setFlowNodeReferenced(antecedent);
25618             }
25619         }
25620         function createFlowCondition(flags, antecedent, expression) {
25621             if (antecedent.flags & 1) {
25622                 return antecedent;
25623             }
25624             if (!expression) {
25625                 return flags & 32 ? antecedent : unreachableFlow;
25626             }
25627             if ((expression.kind === 106 && flags & 64 ||
25628                 expression.kind === 91 && flags & 32) &&
25629                 !ts.isExpressionOfOptionalChainRoot(expression) && !ts.isNullishCoalesce(expression.parent)) {
25630                 return unreachableFlow;
25631             }
25632             if (!isNarrowingExpression(expression)) {
25633                 return antecedent;
25634             }
25635             setFlowNodeReferenced(antecedent);
25636             return initFlowNode({ flags: flags, antecedent: antecedent, node: expression });
25637         }
25638         function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) {
25639             setFlowNodeReferenced(antecedent);
25640             return initFlowNode({ flags: 128, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd });
25641         }
25642         function createFlowMutation(flags, antecedent, node) {
25643             setFlowNodeReferenced(antecedent);
25644             var result = initFlowNode({ flags: flags, antecedent: antecedent, node: node });
25645             if (currentExceptionTarget) {
25646                 addAntecedent(currentExceptionTarget, result);
25647             }
25648             return result;
25649         }
25650         function createFlowCall(antecedent, node) {
25651             setFlowNodeReferenced(antecedent);
25652             return initFlowNode({ flags: 512, antecedent: antecedent, node: node });
25653         }
25654         function finishFlowLabel(flow) {
25655             var antecedents = flow.antecedents;
25656             if (!antecedents) {
25657                 return unreachableFlow;
25658             }
25659             if (antecedents.length === 1) {
25660                 return antecedents[0];
25661             }
25662             return flow;
25663         }
25664         function isStatementCondition(node) {
25665             var parent = node.parent;
25666             switch (parent.kind) {
25667                 case 227:
25668                 case 229:
25669                 case 228:
25670                     return parent.expression === node;
25671                 case 230:
25672                 case 210:
25673                     return parent.condition === node;
25674             }
25675             return false;
25676         }
25677         function isLogicalExpression(node) {
25678             while (true) {
25679                 if (node.kind === 200) {
25680                     node = node.expression;
25681                 }
25682                 else if (node.kind === 207 && node.operator === 53) {
25683                     node = node.operand;
25684                 }
25685                 else {
25686                     return node.kind === 209 && (node.operatorToken.kind === 55 ||
25687                         node.operatorToken.kind === 56 ||
25688                         node.operatorToken.kind === 60);
25689                 }
25690             }
25691         }
25692         function isTopLevelLogicalExpression(node) {
25693             while (ts.isParenthesizedExpression(node.parent) ||
25694                 ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53) {
25695                 node = node.parent;
25696             }
25697             return !isStatementCondition(node) &&
25698                 !isLogicalExpression(node.parent) &&
25699                 !(ts.isOptionalChain(node.parent) && node.parent.expression === node);
25700         }
25701         function doWithConditionalBranches(action, value, trueTarget, falseTarget) {
25702             var savedTrueTarget = currentTrueTarget;
25703             var savedFalseTarget = currentFalseTarget;
25704             currentTrueTarget = trueTarget;
25705             currentFalseTarget = falseTarget;
25706             action(value);
25707             currentTrueTarget = savedTrueTarget;
25708             currentFalseTarget = savedFalseTarget;
25709         }
25710         function bindCondition(node, trueTarget, falseTarget) {
25711             doWithConditionalBranches(bind, node, trueTarget, falseTarget);
25712             if (!node || !isLogicalExpression(node) && !(ts.isOptionalChain(node) && ts.isOutermostOptionalChain(node))) {
25713                 addAntecedent(trueTarget, createFlowCondition(32, currentFlow, node));
25714                 addAntecedent(falseTarget, createFlowCondition(64, currentFlow, node));
25715             }
25716         }
25717         function bindIterativeStatement(node, breakTarget, continueTarget) {
25718             var saveBreakTarget = currentBreakTarget;
25719             var saveContinueTarget = currentContinueTarget;
25720             currentBreakTarget = breakTarget;
25721             currentContinueTarget = continueTarget;
25722             bind(node);
25723             currentBreakTarget = saveBreakTarget;
25724             currentContinueTarget = saveContinueTarget;
25725         }
25726         function setContinueTarget(node, target) {
25727             var label = activeLabelList;
25728             while (label && node.parent.kind === 238) {
25729                 label.continueTarget = target;
25730                 label = label.next;
25731                 node = node.parent;
25732             }
25733             return target;
25734         }
25735         function bindWhileStatement(node) {
25736             var preWhileLabel = setContinueTarget(node, createLoopLabel());
25737             var preBodyLabel = createBranchLabel();
25738             var postWhileLabel = createBranchLabel();
25739             addAntecedent(preWhileLabel, currentFlow);
25740             currentFlow = preWhileLabel;
25741             bindCondition(node.expression, preBodyLabel, postWhileLabel);
25742             currentFlow = finishFlowLabel(preBodyLabel);
25743             bindIterativeStatement(node.statement, postWhileLabel, preWhileLabel);
25744             addAntecedent(preWhileLabel, currentFlow);
25745             currentFlow = finishFlowLabel(postWhileLabel);
25746         }
25747         function bindDoStatement(node) {
25748             var preDoLabel = createLoopLabel();
25749             var preConditionLabel = setContinueTarget(node, createBranchLabel());
25750             var postDoLabel = createBranchLabel();
25751             addAntecedent(preDoLabel, currentFlow);
25752             currentFlow = preDoLabel;
25753             bindIterativeStatement(node.statement, postDoLabel, preConditionLabel);
25754             addAntecedent(preConditionLabel, currentFlow);
25755             currentFlow = finishFlowLabel(preConditionLabel);
25756             bindCondition(node.expression, preDoLabel, postDoLabel);
25757             currentFlow = finishFlowLabel(postDoLabel);
25758         }
25759         function bindForStatement(node) {
25760             var preLoopLabel = setContinueTarget(node, createLoopLabel());
25761             var preBodyLabel = createBranchLabel();
25762             var postLoopLabel = createBranchLabel();
25763             bind(node.initializer);
25764             addAntecedent(preLoopLabel, currentFlow);
25765             currentFlow = preLoopLabel;
25766             bindCondition(node.condition, preBodyLabel, postLoopLabel);
25767             currentFlow = finishFlowLabel(preBodyLabel);
25768             bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel);
25769             bind(node.incrementor);
25770             addAntecedent(preLoopLabel, currentFlow);
25771             currentFlow = finishFlowLabel(postLoopLabel);
25772         }
25773         function bindForInOrForOfStatement(node) {
25774             var preLoopLabel = setContinueTarget(node, createLoopLabel());
25775             var postLoopLabel = createBranchLabel();
25776             bind(node.expression);
25777             addAntecedent(preLoopLabel, currentFlow);
25778             currentFlow = preLoopLabel;
25779             if (node.kind === 232) {
25780                 bind(node.awaitModifier);
25781             }
25782             addAntecedent(postLoopLabel, currentFlow);
25783             bind(node.initializer);
25784             if (node.initializer.kind !== 243) {
25785                 bindAssignmentTargetFlow(node.initializer);
25786             }
25787             bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel);
25788             addAntecedent(preLoopLabel, currentFlow);
25789             currentFlow = finishFlowLabel(postLoopLabel);
25790         }
25791         function bindIfStatement(node) {
25792             var thenLabel = createBranchLabel();
25793             var elseLabel = createBranchLabel();
25794             var postIfLabel = createBranchLabel();
25795             bindCondition(node.expression, thenLabel, elseLabel);
25796             currentFlow = finishFlowLabel(thenLabel);
25797             bind(node.thenStatement);
25798             addAntecedent(postIfLabel, currentFlow);
25799             currentFlow = finishFlowLabel(elseLabel);
25800             bind(node.elseStatement);
25801             addAntecedent(postIfLabel, currentFlow);
25802             currentFlow = finishFlowLabel(postIfLabel);
25803         }
25804         function bindReturnOrThrow(node) {
25805             bind(node.expression);
25806             if (node.kind === 235) {
25807                 hasExplicitReturn = true;
25808                 if (currentReturnTarget) {
25809                     addAntecedent(currentReturnTarget, currentFlow);
25810                 }
25811             }
25812             currentFlow = unreachableFlow;
25813         }
25814         function findActiveLabel(name) {
25815             for (var label = activeLabelList; label; label = label.next) {
25816                 if (label.name === name) {
25817                     return label;
25818                 }
25819             }
25820             return undefined;
25821         }
25822         function bindBreakOrContinueFlow(node, breakTarget, continueTarget) {
25823             var flowLabel = node.kind === 234 ? breakTarget : continueTarget;
25824             if (flowLabel) {
25825                 addAntecedent(flowLabel, currentFlow);
25826                 currentFlow = unreachableFlow;
25827             }
25828         }
25829         function bindBreakOrContinueStatement(node) {
25830             bind(node.label);
25831             if (node.label) {
25832                 var activeLabel = findActiveLabel(node.label.escapedText);
25833                 if (activeLabel) {
25834                     activeLabel.referenced = true;
25835                     bindBreakOrContinueFlow(node, activeLabel.breakTarget, activeLabel.continueTarget);
25836                 }
25837             }
25838             else {
25839                 bindBreakOrContinueFlow(node, currentBreakTarget, currentContinueTarget);
25840             }
25841         }
25842         function bindTryStatement(node) {
25843             var saveReturnTarget = currentReturnTarget;
25844             var saveExceptionTarget = currentExceptionTarget;
25845             var normalExitLabel = createBranchLabel();
25846             var returnLabel = createBranchLabel();
25847             var exceptionLabel = createBranchLabel();
25848             if (node.finallyBlock) {
25849                 currentReturnTarget = returnLabel;
25850             }
25851             addAntecedent(exceptionLabel, currentFlow);
25852             currentExceptionTarget = exceptionLabel;
25853             bind(node.tryBlock);
25854             addAntecedent(normalExitLabel, currentFlow);
25855             if (node.catchClause) {
25856                 currentFlow = finishFlowLabel(exceptionLabel);
25857                 exceptionLabel = createBranchLabel();
25858                 addAntecedent(exceptionLabel, currentFlow);
25859                 currentExceptionTarget = exceptionLabel;
25860                 bind(node.catchClause);
25861                 addAntecedent(normalExitLabel, currentFlow);
25862             }
25863             currentReturnTarget = saveReturnTarget;
25864             currentExceptionTarget = saveExceptionTarget;
25865             if (node.finallyBlock) {
25866                 var finallyLabel = createBranchLabel();
25867                 finallyLabel.antecedents = ts.concatenate(ts.concatenate(normalExitLabel.antecedents, exceptionLabel.antecedents), returnLabel.antecedents);
25868                 currentFlow = finallyLabel;
25869                 bind(node.finallyBlock);
25870                 if (currentFlow.flags & 1) {
25871                     currentFlow = unreachableFlow;
25872                 }
25873                 else {
25874                     if (currentReturnTarget && returnLabel.antecedents) {
25875                         addAntecedent(currentReturnTarget, createReduceLabel(finallyLabel, returnLabel.antecedents, currentFlow));
25876                     }
25877                     currentFlow = normalExitLabel.antecedents ? createReduceLabel(finallyLabel, normalExitLabel.antecedents, currentFlow) : unreachableFlow;
25878                 }
25879             }
25880             else {
25881                 currentFlow = finishFlowLabel(normalExitLabel);
25882             }
25883         }
25884         function bindSwitchStatement(node) {
25885             var postSwitchLabel = createBranchLabel();
25886             bind(node.expression);
25887             var saveBreakTarget = currentBreakTarget;
25888             var savePreSwitchCaseFlow = preSwitchCaseFlow;
25889             currentBreakTarget = postSwitchLabel;
25890             preSwitchCaseFlow = currentFlow;
25891             bind(node.caseBlock);
25892             addAntecedent(postSwitchLabel, currentFlow);
25893             var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 278; });
25894             node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents;
25895             if (!hasDefault) {
25896                 addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0));
25897             }
25898             currentBreakTarget = saveBreakTarget;
25899             preSwitchCaseFlow = savePreSwitchCaseFlow;
25900             currentFlow = finishFlowLabel(postSwitchLabel);
25901         }
25902         function bindCaseBlock(node) {
25903             var savedSubtreeTransformFlags = subtreeTransformFlags;
25904             subtreeTransformFlags = 0;
25905             var clauses = node.clauses;
25906             var isNarrowingSwitch = isNarrowingExpression(node.parent.expression);
25907             var fallthroughFlow = unreachableFlow;
25908             for (var i = 0; i < clauses.length; i++) {
25909                 var clauseStart = i;
25910                 while (!clauses[i].statements.length && i + 1 < clauses.length) {
25911                     bind(clauses[i]);
25912                     i++;
25913                 }
25914                 var preCaseLabel = createBranchLabel();
25915                 addAntecedent(preCaseLabel, isNarrowingSwitch ? createFlowSwitchClause(preSwitchCaseFlow, node.parent, clauseStart, i + 1) : preSwitchCaseFlow);
25916                 addAntecedent(preCaseLabel, fallthroughFlow);
25917                 currentFlow = finishFlowLabel(preCaseLabel);
25918                 var clause = clauses[i];
25919                 bind(clause);
25920                 fallthroughFlow = currentFlow;
25921                 if (!(currentFlow.flags & 1) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) {
25922                     clause.fallthroughFlowNode = currentFlow;
25923                 }
25924             }
25925             clauses.transformFlags = subtreeTransformFlags | 536870912;
25926             subtreeTransformFlags |= savedSubtreeTransformFlags;
25927         }
25928         function bindCaseClause(node) {
25929             var saveCurrentFlow = currentFlow;
25930             currentFlow = preSwitchCaseFlow;
25931             bind(node.expression);
25932             currentFlow = saveCurrentFlow;
25933             bindEach(node.statements);
25934         }
25935         function bindExpressionStatement(node) {
25936             bind(node.expression);
25937             if (node.expression.kind === 196) {
25938                 var call = node.expression;
25939                 if (ts.isDottedName(call.expression)) {
25940                     currentFlow = createFlowCall(currentFlow, call);
25941                 }
25942             }
25943         }
25944         function bindLabeledStatement(node) {
25945             var postStatementLabel = createBranchLabel();
25946             activeLabelList = {
25947                 next: activeLabelList,
25948                 name: node.label.escapedText,
25949                 breakTarget: postStatementLabel,
25950                 continueTarget: undefined,
25951                 referenced: false
25952             };
25953             bind(node.label);
25954             bind(node.statement);
25955             if (!activeLabelList.referenced && !options.allowUnusedLabels) {
25956                 errorOrSuggestionOnNode(ts.unusedLabelIsError(options), node.label, ts.Diagnostics.Unused_label);
25957             }
25958             activeLabelList = activeLabelList.next;
25959             addAntecedent(postStatementLabel, currentFlow);
25960             currentFlow = finishFlowLabel(postStatementLabel);
25961         }
25962         function bindDestructuringTargetFlow(node) {
25963             if (node.kind === 209 && node.operatorToken.kind === 62) {
25964                 bindAssignmentTargetFlow(node.left);
25965             }
25966             else {
25967                 bindAssignmentTargetFlow(node);
25968             }
25969         }
25970         function bindAssignmentTargetFlow(node) {
25971             if (isNarrowableReference(node)) {
25972                 currentFlow = createFlowMutation(16, currentFlow, node);
25973             }
25974             else if (node.kind === 192) {
25975                 for (var _i = 0, _a = node.elements; _i < _a.length; _i++) {
25976                     var e = _a[_i];
25977                     if (e.kind === 213) {
25978                         bindAssignmentTargetFlow(e.expression);
25979                     }
25980                     else {
25981                         bindDestructuringTargetFlow(e);
25982                     }
25983                 }
25984             }
25985             else if (node.kind === 193) {
25986                 for (var _b = 0, _c = node.properties; _b < _c.length; _b++) {
25987                     var p = _c[_b];
25988                     if (p.kind === 281) {
25989                         bindDestructuringTargetFlow(p.initializer);
25990                     }
25991                     else if (p.kind === 282) {
25992                         bindAssignmentTargetFlow(p.name);
25993                     }
25994                     else if (p.kind === 283) {
25995                         bindAssignmentTargetFlow(p.expression);
25996                     }
25997                 }
25998             }
25999         }
26000         function bindLogicalExpression(node, trueTarget, falseTarget) {
26001             var preRightLabel = createBranchLabel();
26002             if (node.operatorToken.kind === 55) {
26003                 bindCondition(node.left, preRightLabel, falseTarget);
26004             }
26005             else {
26006                 bindCondition(node.left, trueTarget, preRightLabel);
26007             }
26008             currentFlow = finishFlowLabel(preRightLabel);
26009             bind(node.operatorToken);
26010             bindCondition(node.right, trueTarget, falseTarget);
26011         }
26012         function bindPrefixUnaryExpressionFlow(node) {
26013             if (node.operator === 53) {
26014                 var saveTrueTarget = currentTrueTarget;
26015                 currentTrueTarget = currentFalseTarget;
26016                 currentFalseTarget = saveTrueTarget;
26017                 bindEachChild(node);
26018                 currentFalseTarget = currentTrueTarget;
26019                 currentTrueTarget = saveTrueTarget;
26020             }
26021             else {
26022                 bindEachChild(node);
26023                 if (node.operator === 45 || node.operator === 46) {
26024                     bindAssignmentTargetFlow(node.operand);
26025                 }
26026             }
26027         }
26028         function bindPostfixUnaryExpressionFlow(node) {
26029             bindEachChild(node);
26030             if (node.operator === 45 || node.operator === 46) {
26031                 bindAssignmentTargetFlow(node.operand);
26032             }
26033         }
26034         function bindBinaryExpressionFlow(node) {
26035             var workStacks = {
26036                 expr: [node],
26037                 state: [1],
26038                 inStrictMode: [undefined],
26039                 parent: [undefined],
26040                 subtreeFlags: [undefined]
26041             };
26042             var stackIndex = 0;
26043             while (stackIndex >= 0) {
26044                 node = workStacks.expr[stackIndex];
26045                 switch (workStacks.state[stackIndex]) {
26046                     case 0: {
26047                         node.parent = parent;
26048                         var saveInStrictMode = inStrictMode;
26049                         bindWorker(node);
26050                         var saveParent = parent;
26051                         parent = node;
26052                         var subtreeFlagsState = void 0;
26053                         if (skipTransformFlagAggregation) {
26054                         }
26055                         else if (node.transformFlags & 536870912) {
26056                             skipTransformFlagAggregation = true;
26057                             subtreeFlagsState = -1;
26058                         }
26059                         else {
26060                             var savedSubtreeTransformFlags = subtreeTransformFlags;
26061                             subtreeTransformFlags = 0;
26062                             subtreeFlagsState = savedSubtreeTransformFlags;
26063                         }
26064                         advanceState(1, saveInStrictMode, saveParent, subtreeFlagsState);
26065                         break;
26066                     }
26067                     case 1: {
26068                         var operator = node.operatorToken.kind;
26069                         if (operator === 55 || operator === 56 || operator === 60) {
26070                             if (isTopLevelLogicalExpression(node)) {
26071                                 var postExpressionLabel = createBranchLabel();
26072                                 bindLogicalExpression(node, postExpressionLabel, postExpressionLabel);
26073                                 currentFlow = finishFlowLabel(postExpressionLabel);
26074                             }
26075                             else {
26076                                 bindLogicalExpression(node, currentTrueTarget, currentFalseTarget);
26077                             }
26078                             completeNode();
26079                         }
26080                         else {
26081                             advanceState(2);
26082                             maybeBind(node.left);
26083                         }
26084                         break;
26085                     }
26086                     case 2: {
26087                         advanceState(3);
26088                         maybeBind(node.operatorToken);
26089                         break;
26090                     }
26091                     case 3: {
26092                         advanceState(4);
26093                         maybeBind(node.right);
26094                         break;
26095                     }
26096                     case 4: {
26097                         var operator = node.operatorToken.kind;
26098                         if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) {
26099                             bindAssignmentTargetFlow(node.left);
26100                             if (operator === 62 && node.left.kind === 195) {
26101                                 var elementAccess = node.left;
26102                                 if (isNarrowableOperand(elementAccess.expression)) {
26103                                     currentFlow = createFlowMutation(256, currentFlow, node);
26104                                 }
26105                             }
26106                         }
26107                         completeNode();
26108                         break;
26109                     }
26110                     default: return ts.Debug.fail("Invalid state " + workStacks.state[stackIndex] + " for bindBinaryExpressionFlow");
26111                 }
26112             }
26113             function advanceState(state, isInStrictMode, parent, subtreeFlags) {
26114                 workStacks.state[stackIndex] = state;
26115                 if (isInStrictMode !== undefined) {
26116                     workStacks.inStrictMode[stackIndex] = isInStrictMode;
26117                 }
26118                 if (parent !== undefined) {
26119                     workStacks.parent[stackIndex] = parent;
26120                 }
26121                 if (subtreeFlags !== undefined) {
26122                     workStacks.subtreeFlags[stackIndex] = subtreeFlags;
26123                 }
26124             }
26125             function completeNode() {
26126                 if (workStacks.inStrictMode[stackIndex] !== undefined) {
26127                     if (workStacks.subtreeFlags[stackIndex] === -1) {
26128                         skipTransformFlagAggregation = false;
26129                         subtreeTransformFlags |= node.transformFlags & ~getTransformFlagsSubtreeExclusions(node.kind);
26130                     }
26131                     else if (workStacks.subtreeFlags[stackIndex] !== undefined) {
26132                         subtreeTransformFlags = workStacks.subtreeFlags[stackIndex] | computeTransformFlagsForNode(node, subtreeTransformFlags);
26133                     }
26134                     inStrictMode = workStacks.inStrictMode[stackIndex];
26135                     parent = workStacks.parent[stackIndex];
26136                 }
26137                 stackIndex--;
26138             }
26139             function maybeBind(node) {
26140                 if (node && ts.isBinaryExpression(node)) {
26141                     stackIndex++;
26142                     workStacks.expr[stackIndex] = node;
26143                     workStacks.state[stackIndex] = 0;
26144                     workStacks.inStrictMode[stackIndex] = undefined;
26145                     workStacks.parent[stackIndex] = undefined;
26146                     workStacks.subtreeFlags[stackIndex] = undefined;
26147                 }
26148                 else {
26149                     bind(node);
26150                 }
26151             }
26152         }
26153         function bindDeleteExpressionFlow(node) {
26154             bindEachChild(node);
26155             if (node.expression.kind === 194) {
26156                 bindAssignmentTargetFlow(node.expression);
26157             }
26158         }
26159         function bindConditionalExpressionFlow(node) {
26160             var trueLabel = createBranchLabel();
26161             var falseLabel = createBranchLabel();
26162             var postExpressionLabel = createBranchLabel();
26163             bindCondition(node.condition, trueLabel, falseLabel);
26164             currentFlow = finishFlowLabel(trueLabel);
26165             bind(node.questionToken);
26166             bind(node.whenTrue);
26167             addAntecedent(postExpressionLabel, currentFlow);
26168             currentFlow = finishFlowLabel(falseLabel);
26169             bind(node.colonToken);
26170             bind(node.whenFalse);
26171             addAntecedent(postExpressionLabel, currentFlow);
26172             currentFlow = finishFlowLabel(postExpressionLabel);
26173         }
26174         function bindInitializedVariableFlow(node) {
26175             var name = !ts.isOmittedExpression(node) ? node.name : undefined;
26176             if (ts.isBindingPattern(name)) {
26177                 for (var _i = 0, _a = name.elements; _i < _a.length; _i++) {
26178                     var child = _a[_i];
26179                     bindInitializedVariableFlow(child);
26180                 }
26181             }
26182             else {
26183                 currentFlow = createFlowMutation(16, currentFlow, node);
26184             }
26185         }
26186         function bindVariableDeclarationFlow(node) {
26187             bindEachChild(node);
26188             if (node.initializer || ts.isForInOrOfStatement(node.parent.parent)) {
26189                 bindInitializedVariableFlow(node);
26190             }
26191         }
26192         function bindJSDocTypeAlias(node) {
26193             node.tagName.parent = node;
26194             if (node.kind !== 316 && node.fullName) {
26195                 setParentPointers(node, node.fullName);
26196             }
26197         }
26198         function bindJSDocClassTag(node) {
26199             bindEachChild(node);
26200             var host = ts.getHostSignatureFromJSDoc(node);
26201             if (host && host.kind !== 161) {
26202                 addDeclarationToSymbol(host.symbol, host, 32);
26203             }
26204         }
26205         function bindOptionalExpression(node, trueTarget, falseTarget) {
26206             doWithConditionalBranches(bind, node, trueTarget, falseTarget);
26207             if (!ts.isOptionalChain(node) || ts.isOutermostOptionalChain(node)) {
26208                 addAntecedent(trueTarget, createFlowCondition(32, currentFlow, node));
26209                 addAntecedent(falseTarget, createFlowCondition(64, currentFlow, node));
26210             }
26211         }
26212         function bindOptionalChainRest(node) {
26213             switch (node.kind) {
26214                 case 194:
26215                     bind(node.questionDotToken);
26216                     bind(node.name);
26217                     break;
26218                 case 195:
26219                     bind(node.questionDotToken);
26220                     bind(node.argumentExpression);
26221                     break;
26222                 case 196:
26223                     bind(node.questionDotToken);
26224                     bindEach(node.typeArguments);
26225                     bindEach(node.arguments);
26226                     break;
26227             }
26228         }
26229         function bindOptionalChain(node, trueTarget, falseTarget) {
26230             var preChainLabel = ts.isOptionalChainRoot(node) ? createBranchLabel() : undefined;
26231             bindOptionalExpression(node.expression, preChainLabel || trueTarget, falseTarget);
26232             if (preChainLabel) {
26233                 currentFlow = finishFlowLabel(preChainLabel);
26234             }
26235             doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget);
26236             if (ts.isOutermostOptionalChain(node)) {
26237                 addAntecedent(trueTarget, createFlowCondition(32, currentFlow, node));
26238                 addAntecedent(falseTarget, createFlowCondition(64, currentFlow, node));
26239             }
26240         }
26241         function bindOptionalChainFlow(node) {
26242             if (isTopLevelLogicalExpression(node)) {
26243                 var postExpressionLabel = createBranchLabel();
26244                 bindOptionalChain(node, postExpressionLabel, postExpressionLabel);
26245                 currentFlow = finishFlowLabel(postExpressionLabel);
26246             }
26247             else {
26248                 bindOptionalChain(node, currentTrueTarget, currentFalseTarget);
26249             }
26250         }
26251         function bindNonNullExpressionFlow(node) {
26252             if (ts.isOptionalChain(node)) {
26253                 bindOptionalChainFlow(node);
26254             }
26255             else {
26256                 bindEachChild(node);
26257             }
26258         }
26259         function bindAccessExpressionFlow(node) {
26260             if (ts.isOptionalChain(node)) {
26261                 bindOptionalChainFlow(node);
26262             }
26263             else {
26264                 bindEachChild(node);
26265             }
26266         }
26267         function bindCallExpressionFlow(node) {
26268             if (ts.isOptionalChain(node)) {
26269                 bindOptionalChainFlow(node);
26270             }
26271             else {
26272                 var expr = ts.skipParentheses(node.expression);
26273                 if (expr.kind === 201 || expr.kind === 202) {
26274                     bindEach(node.typeArguments);
26275                     bindEach(node.arguments);
26276                     bind(node.expression);
26277                 }
26278                 else {
26279                     bindEachChild(node);
26280                 }
26281             }
26282             if (node.expression.kind === 194) {
26283                 var propertyAccess = node.expression;
26284                 if (ts.isIdentifier(propertyAccess.name) && isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) {
26285                     currentFlow = createFlowMutation(256, currentFlow, node);
26286                 }
26287             }
26288         }
26289         function getContainerFlags(node) {
26290             switch (node.kind) {
26291                 case 214:
26292                 case 245:
26293                 case 248:
26294                 case 193:
26295                 case 173:
26296                 case 304:
26297                 case 274:
26298                     return 1;
26299                 case 246:
26300                     return 1 | 64;
26301                 case 249:
26302                 case 247:
26303                 case 186:
26304                     return 1 | 32;
26305                 case 290:
26306                     return 1 | 4 | 32;
26307                 case 161:
26308                     if (ts.isObjectLiteralOrClassExpressionMethod(node)) {
26309                         return 1 | 4 | 32 | 8 | 128;
26310                     }
26311                 case 162:
26312                 case 244:
26313                 case 160:
26314                 case 163:
26315                 case 164:
26316                 case 165:
26317                 case 305:
26318                 case 300:
26319                 case 170:
26320                 case 166:
26321                 case 167:
26322                 case 171:
26323                     return 1 | 4 | 32 | 8;
26324                 case 201:
26325                 case 202:
26326                     return 1 | 4 | 32 | 8 | 16;
26327                 case 250:
26328                     return 4;
26329                 case 159:
26330                     return node.initializer ? 4 : 0;
26331                 case 280:
26332                 case 230:
26333                 case 231:
26334                 case 232:
26335                 case 251:
26336                     return 2;
26337                 case 223:
26338                     return ts.isFunctionLike(node.parent) ? 0 : 2;
26339             }
26340             return 0;
26341         }
26342         function addToContainerChain(next) {
26343             if (lastContainer) {
26344                 lastContainer.nextContainer = next;
26345             }
26346             lastContainer = next;
26347         }
26348         function declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes) {
26349             switch (container.kind) {
26350                 case 249:
26351                     return declareModuleMember(node, symbolFlags, symbolExcludes);
26352                 case 290:
26353                     return declareSourceFileMember(node, symbolFlags, symbolExcludes);
26354                 case 214:
26355                 case 245:
26356                     return declareClassMember(node, symbolFlags, symbolExcludes);
26357                 case 248:
26358                     return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
26359                 case 173:
26360                 case 304:
26361                 case 193:
26362                 case 246:
26363                 case 274:
26364                     return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes);
26365                 case 170:
26366                 case 171:
26367                 case 165:
26368                 case 166:
26369                 case 305:
26370                 case 167:
26371                 case 161:
26372                 case 160:
26373                 case 162:
26374                 case 163:
26375                 case 164:
26376                 case 244:
26377                 case 201:
26378                 case 202:
26379                 case 300:
26380                 case 322:
26381                 case 315:
26382                 case 247:
26383                 case 186:
26384                     return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes);
26385             }
26386         }
26387         function declareClassMember(node, symbolFlags, symbolExcludes) {
26388             return ts.hasModifier(node, 32)
26389                 ? declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes)
26390                 : declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes);
26391         }
26392         function declareSourceFileMember(node, symbolFlags, symbolExcludes) {
26393             return ts.isExternalModule(file)
26394                 ? declareModuleMember(node, symbolFlags, symbolExcludes)
26395                 : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes);
26396         }
26397         function hasExportDeclarations(node) {
26398             var body = ts.isSourceFile(node) ? node : ts.tryCast(node.body, ts.isModuleBlock);
26399             return !!body && body.statements.some(function (s) { return ts.isExportDeclaration(s) || ts.isExportAssignment(s); });
26400         }
26401         function setExportContextFlag(node) {
26402             if (node.flags & 8388608 && !hasExportDeclarations(node)) {
26403                 node.flags |= 64;
26404             }
26405             else {
26406                 node.flags &= ~64;
26407             }
26408         }
26409         function bindModuleDeclaration(node) {
26410             setExportContextFlag(node);
26411             if (ts.isAmbientModule(node)) {
26412                 if (ts.hasModifier(node, 1)) {
26413                     errorOnFirstToken(node, ts.Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible);
26414                 }
26415                 if (ts.isModuleAugmentationExternal(node)) {
26416                     declareModuleSymbol(node);
26417                 }
26418                 else {
26419                     var pattern = void 0;
26420                     if (node.name.kind === 10) {
26421                         var text = node.name.text;
26422                         if (ts.hasZeroOrOneAsteriskCharacter(text)) {
26423                             pattern = ts.tryParsePattern(text);
26424                         }
26425                         else {
26426                             errorOnFirstToken(node.name, ts.Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, text);
26427                         }
26428                     }
26429                     var symbol = declareSymbolAndAddToSymbolTable(node, 512, 110735);
26430                     file.patternAmbientModules = ts.append(file.patternAmbientModules, pattern && { pattern: pattern, symbol: symbol });
26431                 }
26432             }
26433             else {
26434                 var state = declareModuleSymbol(node);
26435                 if (state !== 0) {
26436                     var symbol = node.symbol;
26437                     symbol.constEnumOnlyModule = (!(symbol.flags & (16 | 32 | 256)))
26438                         && state === 2
26439                         && symbol.constEnumOnlyModule !== false;
26440                 }
26441             }
26442         }
26443         function declareModuleSymbol(node) {
26444             var state = getModuleInstanceState(node);
26445             var instantiated = state !== 0;
26446             declareSymbolAndAddToSymbolTable(node, instantiated ? 512 : 1024, instantiated ? 110735 : 0);
26447             return state;
26448         }
26449         function bindFunctionOrConstructorType(node) {
26450             var symbol = createSymbol(131072, getDeclarationName(node));
26451             addDeclarationToSymbol(symbol, node, 131072);
26452             var typeLiteralSymbol = createSymbol(2048, "__type");
26453             addDeclarationToSymbol(typeLiteralSymbol, node, 2048);
26454             typeLiteralSymbol.members = ts.createSymbolTable();
26455             typeLiteralSymbol.members.set(symbol.escapedName, symbol);
26456         }
26457         function bindObjectLiteralExpression(node) {
26458             if (inStrictMode && !ts.isAssignmentTarget(node)) {
26459                 var seen = ts.createUnderscoreEscapedMap();
26460                 for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
26461                     var prop = _a[_i];
26462                     if (prop.kind === 283 || prop.name.kind !== 75) {
26463                         continue;
26464                     }
26465                     var identifier = prop.name;
26466                     var currentKind = prop.kind === 281 || prop.kind === 282 || prop.kind === 161
26467                         ? 1
26468                         : 2;
26469                     var existingKind = seen.get(identifier.escapedText);
26470                     if (!existingKind) {
26471                         seen.set(identifier.escapedText, currentKind);
26472                         continue;
26473                     }
26474                     if (currentKind === 1 && existingKind === 1) {
26475                         var span = ts.getErrorSpanForNode(file, identifier);
26476                         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));
26477                     }
26478                 }
26479             }
26480             return bindAnonymousDeclaration(node, 4096, "__object");
26481         }
26482         function bindJsxAttributes(node) {
26483             return bindAnonymousDeclaration(node, 4096, "__jsxAttributes");
26484         }
26485         function bindJsxAttribute(node, symbolFlags, symbolExcludes) {
26486             return declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes);
26487         }
26488         function bindAnonymousDeclaration(node, symbolFlags, name) {
26489             var symbol = createSymbol(symbolFlags, name);
26490             if (symbolFlags & (8 | 106500)) {
26491                 symbol.parent = container.symbol;
26492             }
26493             addDeclarationToSymbol(symbol, node, symbolFlags);
26494             return symbol;
26495         }
26496         function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) {
26497             switch (blockScopeContainer.kind) {
26498                 case 249:
26499                     declareModuleMember(node, symbolFlags, symbolExcludes);
26500                     break;
26501                 case 290:
26502                     if (ts.isExternalOrCommonJsModule(container)) {
26503                         declareModuleMember(node, symbolFlags, symbolExcludes);
26504                         break;
26505                     }
26506                 default:
26507                     if (!blockScopeContainer.locals) {
26508                         blockScopeContainer.locals = ts.createSymbolTable();
26509                         addToContainerChain(blockScopeContainer);
26510                     }
26511                     declareSymbol(blockScopeContainer.locals, undefined, node, symbolFlags, symbolExcludes);
26512             }
26513         }
26514         function delayedBindJSDocTypedefTag() {
26515             if (!delayedTypeAliases) {
26516                 return;
26517             }
26518             var saveContainer = container;
26519             var saveLastContainer = lastContainer;
26520             var saveBlockScopeContainer = blockScopeContainer;
26521             var saveParent = parent;
26522             var saveCurrentFlow = currentFlow;
26523             for (var _i = 0, delayedTypeAliases_1 = delayedTypeAliases; _i < delayedTypeAliases_1.length; _i++) {
26524                 var typeAlias = delayedTypeAliases_1[_i];
26525                 var host = ts.getJSDocHost(typeAlias);
26526                 container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1); }) || file;
26527                 blockScopeContainer = ts.getEnclosingBlockScopeContainer(host) || file;
26528                 currentFlow = initFlowNode({ flags: 2 });
26529                 parent = typeAlias;
26530                 bind(typeAlias.typeExpression);
26531                 var declName = ts.getNameOfDeclaration(typeAlias);
26532                 if ((ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName) && declName && ts.isPropertyAccessEntityNameExpression(declName.parent)) {
26533                     var isTopLevel = isTopLevelNamespaceAssignment(declName.parent);
26534                     if (isTopLevel) {
26535                         bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; }), false);
26536                         var oldContainer = container;
26537                         switch (ts.getAssignmentDeclarationPropertyAccessKind(declName.parent)) {
26538                             case 1:
26539                             case 2:
26540                                 if (!ts.isExternalOrCommonJsModule(file)) {
26541                                     container = undefined;
26542                                 }
26543                                 else {
26544                                     container = file;
26545                                 }
26546                                 break;
26547                             case 4:
26548                                 container = declName.parent.expression;
26549                                 break;
26550                             case 3:
26551                                 container = declName.parent.expression.name;
26552                                 break;
26553                             case 5:
26554                                 container = isExportsOrModuleExportsOrAlias(file, declName.parent.expression) ? file
26555                                     : ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name
26556                                         : declName.parent.expression;
26557                                 break;
26558                             case 0:
26559                                 return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration");
26560                         }
26561                         if (container) {
26562                             declareModuleMember(typeAlias, 524288, 788968);
26563                         }
26564                         container = oldContainer;
26565                     }
26566                 }
26567                 else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 75) {
26568                     parent = typeAlias.parent;
26569                     bindBlockScopedDeclaration(typeAlias, 524288, 788968);
26570                 }
26571                 else {
26572                     bind(typeAlias.fullName);
26573                 }
26574             }
26575             container = saveContainer;
26576             lastContainer = saveLastContainer;
26577             blockScopeContainer = saveBlockScopeContainer;
26578             parent = saveParent;
26579             currentFlow = saveCurrentFlow;
26580         }
26581         function checkStrictModeIdentifier(node) {
26582             if (inStrictMode &&
26583                 node.originalKeywordKind >= 113 &&
26584                 node.originalKeywordKind <= 121 &&
26585                 !ts.isIdentifierName(node) &&
26586                 !(node.flags & 8388608) &&
26587                 !(node.flags & 4194304)) {
26588                 if (!file.parseDiagnostics.length) {
26589                     file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node)));
26590                 }
26591             }
26592         }
26593         function getStrictModeIdentifierMessage(node) {
26594             if (ts.getContainingClass(node)) {
26595                 return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode;
26596             }
26597             if (file.externalModuleIndicator) {
26598                 return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode;
26599             }
26600             return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode;
26601         }
26602         function checkPrivateIdentifier(node) {
26603             if (node.escapedText === "#constructor") {
26604                 if (!file.parseDiagnostics.length) {
26605                     file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.constructor_is_a_reserved_word, ts.declarationNameToString(node)));
26606                 }
26607             }
26608         }
26609         function checkStrictModeBinaryExpression(node) {
26610             if (inStrictMode && ts.isLeftHandSideExpression(node.left) && ts.isAssignmentOperator(node.operatorToken.kind)) {
26611                 checkStrictModeEvalOrArguments(node, node.left);
26612             }
26613         }
26614         function checkStrictModeCatchClause(node) {
26615             if (inStrictMode && node.variableDeclaration) {
26616                 checkStrictModeEvalOrArguments(node, node.variableDeclaration.name);
26617             }
26618         }
26619         function checkStrictModeDeleteExpression(node) {
26620             if (inStrictMode && node.expression.kind === 75) {
26621                 var span = ts.getErrorSpanForNode(file, node.expression);
26622                 file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode));
26623             }
26624         }
26625         function isEvalOrArgumentsIdentifier(node) {
26626             return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments");
26627         }
26628         function checkStrictModeEvalOrArguments(contextNode, name) {
26629             if (name && name.kind === 75) {
26630                 var identifier = name;
26631                 if (isEvalOrArgumentsIdentifier(identifier)) {
26632                     var span = ts.getErrorSpanForNode(file, name);
26633                     file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, getStrictModeEvalOrArgumentsMessage(contextNode), ts.idText(identifier)));
26634                 }
26635             }
26636         }
26637         function getStrictModeEvalOrArgumentsMessage(node) {
26638             if (ts.getContainingClass(node)) {
26639                 return ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode;
26640             }
26641             if (file.externalModuleIndicator) {
26642                 return ts.Diagnostics.Invalid_use_of_0_Modules_are_automatically_in_strict_mode;
26643             }
26644             return ts.Diagnostics.Invalid_use_of_0_in_strict_mode;
26645         }
26646         function checkStrictModeFunctionName(node) {
26647             if (inStrictMode) {
26648                 checkStrictModeEvalOrArguments(node, node.name);
26649             }
26650         }
26651         function getStrictModeBlockScopeFunctionDeclarationMessage(node) {
26652             if (ts.getContainingClass(node)) {
26653                 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;
26654             }
26655             if (file.externalModuleIndicator) {
26656                 return ts.Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_are_automatically_in_strict_mode;
26657             }
26658             return ts.Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5;
26659         }
26660         function checkStrictModeFunctionDeclaration(node) {
26661             if (languageVersion < 2) {
26662                 if (blockScopeContainer.kind !== 290 &&
26663                     blockScopeContainer.kind !== 249 &&
26664                     !ts.isFunctionLike(blockScopeContainer)) {
26665                     var errorSpan = ts.getErrorSpanForNode(file, node);
26666                     file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node)));
26667                 }
26668             }
26669         }
26670         function checkStrictModeNumericLiteral(node) {
26671             if (inStrictMode && node.numericLiteralFlags & 32) {
26672                 file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode));
26673             }
26674         }
26675         function checkStrictModePostfixUnaryExpression(node) {
26676             if (inStrictMode) {
26677                 checkStrictModeEvalOrArguments(node, node.operand);
26678             }
26679         }
26680         function checkStrictModePrefixUnaryExpression(node) {
26681             if (inStrictMode) {
26682                 if (node.operator === 45 || node.operator === 46) {
26683                     checkStrictModeEvalOrArguments(node, node.operand);
26684                 }
26685             }
26686         }
26687         function checkStrictModeWithStatement(node) {
26688             if (inStrictMode) {
26689                 errorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode);
26690             }
26691         }
26692         function checkStrictModeLabeledStatement(node) {
26693             if (inStrictMode && options.target >= 2) {
26694                 if (ts.isDeclarationStatement(node.statement) || ts.isVariableStatement(node.statement)) {
26695                     errorOnFirstToken(node.label, ts.Diagnostics.A_label_is_not_allowed_here);
26696                 }
26697             }
26698         }
26699         function errorOnFirstToken(node, message, arg0, arg1, arg2) {
26700             var span = ts.getSpanOfTokenAtPosition(file, node.pos);
26701             file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2));
26702         }
26703         function errorOrSuggestionOnNode(isError, node, message) {
26704             errorOrSuggestionOnRange(isError, node, node, message);
26705         }
26706         function errorOrSuggestionOnRange(isError, startNode, endNode, message) {
26707             addErrorOrSuggestionDiagnostic(isError, { pos: ts.getTokenPosOfNode(startNode, file), end: endNode.end }, message);
26708         }
26709         function addErrorOrSuggestionDiagnostic(isError, range, message) {
26710             var diag = ts.createFileDiagnostic(file, range.pos, range.end - range.pos, message);
26711             if (isError) {
26712                 file.bindDiagnostics.push(diag);
26713             }
26714             else {
26715                 file.bindSuggestionDiagnostics = ts.append(file.bindSuggestionDiagnostics, __assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion }));
26716             }
26717         }
26718         function bind(node) {
26719             if (!node) {
26720                 return;
26721             }
26722             node.parent = parent;
26723             var saveInStrictMode = inStrictMode;
26724             bindWorker(node);
26725             if (node.kind > 152) {
26726                 var saveParent = parent;
26727                 parent = node;
26728                 var containerFlags = getContainerFlags(node);
26729                 if (containerFlags === 0) {
26730                     bindChildren(node);
26731                 }
26732                 else {
26733                     bindContainer(node, containerFlags);
26734                 }
26735                 parent = saveParent;
26736             }
26737             else if (!skipTransformFlagAggregation && (node.transformFlags & 536870912) === 0) {
26738                 subtreeTransformFlags |= computeTransformFlagsForNode(node, 0);
26739                 var saveParent = parent;
26740                 if (node.kind === 1)
26741                     parent = node;
26742                 bindJSDoc(node);
26743                 parent = saveParent;
26744             }
26745             inStrictMode = saveInStrictMode;
26746         }
26747         function bindJSDoc(node) {
26748             if (ts.hasJSDocNodes(node)) {
26749                 if (ts.isInJSFile(node)) {
26750                     for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) {
26751                         var j = _a[_i];
26752                         bind(j);
26753                     }
26754                 }
26755                 else {
26756                     for (var _b = 0, _c = node.jsDoc; _b < _c.length; _b++) {
26757                         var j = _c[_b];
26758                         setParentPointers(node, j);
26759                     }
26760                 }
26761             }
26762         }
26763         function updateStrictModeStatementList(statements) {
26764             if (!inStrictMode) {
26765                 for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) {
26766                     var statement = statements_2[_i];
26767                     if (!ts.isPrologueDirective(statement)) {
26768                         return;
26769                     }
26770                     if (isUseStrictPrologueDirective(statement)) {
26771                         inStrictMode = true;
26772                         return;
26773                     }
26774                 }
26775             }
26776         }
26777         function isUseStrictPrologueDirective(node) {
26778             var nodeText = ts.getSourceTextOfNodeFromSourceFile(file, node.expression);
26779             return nodeText === '"use strict"' || nodeText === "'use strict'";
26780         }
26781         function bindWorker(node) {
26782             switch (node.kind) {
26783                 case 75:
26784                     if (node.isInJSDocNamespace) {
26785                         var parentNode = node.parent;
26786                         while (parentNode && !ts.isJSDocTypeAlias(parentNode)) {
26787                             parentNode = parentNode.parent;
26788                         }
26789                         bindBlockScopedDeclaration(parentNode, 524288, 788968);
26790                         break;
26791                     }
26792                 case 104:
26793                     if (currentFlow && (ts.isExpression(node) || parent.kind === 282)) {
26794                         node.flowNode = currentFlow;
26795                     }
26796                     return checkStrictModeIdentifier(node);
26797                 case 76:
26798                     return checkPrivateIdentifier(node);
26799                 case 194:
26800                 case 195:
26801                     var expr = node;
26802                     if (currentFlow && isNarrowableReference(expr)) {
26803                         expr.flowNode = currentFlow;
26804                     }
26805                     if (ts.isSpecialPropertyDeclaration(expr)) {
26806                         bindSpecialPropertyDeclaration(expr);
26807                     }
26808                     if (ts.isInJSFile(expr) &&
26809                         file.commonJsModuleIndicator &&
26810                         ts.isModuleExportsAccessExpression(expr) &&
26811                         !lookupSymbolForNameWorker(blockScopeContainer, "module")) {
26812                         declareSymbol(file.locals, undefined, expr.expression, 1 | 134217728, 111550);
26813                     }
26814                     break;
26815                 case 209:
26816                     var specialKind = ts.getAssignmentDeclarationKind(node);
26817                     switch (specialKind) {
26818                         case 1:
26819                             bindExportsPropertyAssignment(node);
26820                             break;
26821                         case 2:
26822                             bindModuleExportsAssignment(node);
26823                             break;
26824                         case 3:
26825                             bindPrototypePropertyAssignment(node.left, node);
26826                             break;
26827                         case 6:
26828                             bindPrototypeAssignment(node);
26829                             break;
26830                         case 4:
26831                             bindThisPropertyAssignment(node);
26832                             break;
26833                         case 5:
26834                             bindSpecialPropertyAssignment(node);
26835                             break;
26836                         case 0:
26837                             break;
26838                         default:
26839                             ts.Debug.fail("Unknown binary expression special property assignment kind");
26840                     }
26841                     return checkStrictModeBinaryExpression(node);
26842                 case 280:
26843                     return checkStrictModeCatchClause(node);
26844                 case 203:
26845                     return checkStrictModeDeleteExpression(node);
26846                 case 8:
26847                     return checkStrictModeNumericLiteral(node);
26848                 case 208:
26849                     return checkStrictModePostfixUnaryExpression(node);
26850                 case 207:
26851                     return checkStrictModePrefixUnaryExpression(node);
26852                 case 236:
26853                     return checkStrictModeWithStatement(node);
26854                 case 238:
26855                     return checkStrictModeLabeledStatement(node);
26856                 case 183:
26857                     seenThisKeyword = true;
26858                     return;
26859                 case 168:
26860                     break;
26861                 case 155:
26862                     return bindTypeParameter(node);
26863                 case 156:
26864                     return bindParameter(node);
26865                 case 242:
26866                     return bindVariableDeclarationOrBindingElement(node);
26867                 case 191:
26868                     node.flowNode = currentFlow;
26869                     return bindVariableDeclarationOrBindingElement(node);
26870                 case 159:
26871                 case 158:
26872                     return bindPropertyWorker(node);
26873                 case 281:
26874                 case 282:
26875                     return bindPropertyOrMethodOrAccessor(node, 4, 0);
26876                 case 284:
26877                     return bindPropertyOrMethodOrAccessor(node, 8, 900095);
26878                 case 165:
26879                 case 166:
26880                 case 167:
26881                     return declareSymbolAndAddToSymbolTable(node, 131072, 0);
26882                 case 161:
26883                 case 160:
26884                     return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 16777216 : 0), ts.isObjectLiteralMethod(node) ? 0 : 103359);
26885                 case 244:
26886                     return bindFunctionDeclaration(node);
26887                 case 162:
26888                     return declareSymbolAndAddToSymbolTable(node, 16384, 0);
26889                 case 163:
26890                     return bindPropertyOrMethodOrAccessor(node, 32768, 46015);
26891                 case 164:
26892                     return bindPropertyOrMethodOrAccessor(node, 65536, 78783);
26893                 case 170:
26894                 case 300:
26895                 case 305:
26896                 case 171:
26897                     return bindFunctionOrConstructorType(node);
26898                 case 173:
26899                 case 304:
26900                 case 186:
26901                     return bindAnonymousTypeWorker(node);
26902                 case 310:
26903                     return bindJSDocClassTag(node);
26904                 case 193:
26905                     return bindObjectLiteralExpression(node);
26906                 case 201:
26907                 case 202:
26908                     return bindFunctionExpression(node);
26909                 case 196:
26910                     var assignmentKind = ts.getAssignmentDeclarationKind(node);
26911                     switch (assignmentKind) {
26912                         case 7:
26913                             return bindObjectDefinePropertyAssignment(node);
26914                         case 8:
26915                             return bindObjectDefinePropertyExport(node);
26916                         case 9:
26917                             return bindObjectDefinePrototypeProperty(node);
26918                         case 0:
26919                             break;
26920                         default:
26921                             return ts.Debug.fail("Unknown call expression assignment declaration kind");
26922                     }
26923                     if (ts.isInJSFile(node)) {
26924                         bindCallExpression(node);
26925                     }
26926                     break;
26927                 case 214:
26928                 case 245:
26929                     inStrictMode = true;
26930                     return bindClassLikeDeclaration(node);
26931                 case 246:
26932                     return bindBlockScopedDeclaration(node, 64, 788872);
26933                 case 247:
26934                     return bindBlockScopedDeclaration(node, 524288, 788968);
26935                 case 248:
26936                     return bindEnumDeclaration(node);
26937                 case 249:
26938                     return bindModuleDeclaration(node);
26939                 case 274:
26940                     return bindJsxAttributes(node);
26941                 case 273:
26942                     return bindJsxAttribute(node, 4, 0);
26943                 case 253:
26944                 case 256:
26945                 case 258:
26946                 case 263:
26947                     return declareSymbolAndAddToSymbolTable(node, 2097152, 2097152);
26948                 case 252:
26949                     return bindNamespaceExportDeclaration(node);
26950                 case 255:
26951                     return bindImportClause(node);
26952                 case 260:
26953                     return bindExportDeclaration(node);
26954                 case 259:
26955                     return bindExportAssignment(node);
26956                 case 290:
26957                     updateStrictModeStatementList(node.statements);
26958                     return bindSourceFileIfExternalModule();
26959                 case 223:
26960                     if (!ts.isFunctionLike(node.parent)) {
26961                         return;
26962                     }
26963                 case 250:
26964                     return updateStrictModeStatementList(node.statements);
26965                 case 317:
26966                     if (node.parent.kind === 305) {
26967                         return bindParameter(node);
26968                     }
26969                     if (node.parent.kind !== 304) {
26970                         break;
26971                     }
26972                 case 323:
26973                     var propTag = node;
26974                     var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 299 ?
26975                         4 | 16777216 :
26976                         4;
26977                     return declareSymbolAndAddToSymbolTable(propTag, flags, 0);
26978                 case 322:
26979                 case 315:
26980                 case 316:
26981                     return (delayedTypeAliases || (delayedTypeAliases = [])).push(node);
26982             }
26983         }
26984         function bindPropertyWorker(node) {
26985             return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 16777216 : 0), 0);
26986         }
26987         function bindAnonymousTypeWorker(node) {
26988             return bindAnonymousDeclaration(node, 2048, "__type");
26989         }
26990         function bindSourceFileIfExternalModule() {
26991             setExportContextFlag(file);
26992             if (ts.isExternalModule(file)) {
26993                 bindSourceFileAsExternalModule();
26994             }
26995             else if (ts.isJsonSourceFile(file)) {
26996                 bindSourceFileAsExternalModule();
26997                 var originalSymbol = file.symbol;
26998                 declareSymbol(file.symbol.exports, file.symbol, file, 4, 67108863);
26999                 file.symbol = originalSymbol;
27000             }
27001         }
27002         function bindSourceFileAsExternalModule() {
27003             bindAnonymousDeclaration(file, 512, "\"" + ts.removeFileExtension(file.fileName) + "\"");
27004         }
27005         function bindExportAssignment(node) {
27006             if (!container.symbol || !container.symbol.exports) {
27007                 bindAnonymousDeclaration(node, 2097152, getDeclarationName(node));
27008             }
27009             else {
27010                 var flags = ts.exportAssignmentIsAlias(node)
27011                     ? 2097152
27012                     : 4;
27013                 var symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863);
27014                 if (node.isExportEquals) {
27015                     ts.setValueDeclaration(symbol, node);
27016                 }
27017             }
27018         }
27019         function bindNamespaceExportDeclaration(node) {
27020             if (node.modifiers && node.modifiers.length) {
27021                 file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here));
27022             }
27023             var diag = !ts.isSourceFile(node.parent) ? ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level
27024                 : !ts.isExternalModule(node.parent) ? ts.Diagnostics.Global_module_exports_may_only_appear_in_module_files
27025                     : !node.parent.isDeclarationFile ? ts.Diagnostics.Global_module_exports_may_only_appear_in_declaration_files
27026                         : undefined;
27027             if (diag) {
27028                 file.bindDiagnostics.push(createDiagnosticForNode(node, diag));
27029             }
27030             else {
27031                 file.symbol.globalExports = file.symbol.globalExports || ts.createSymbolTable();
27032                 declareSymbol(file.symbol.globalExports, file.symbol, node, 2097152, 2097152);
27033             }
27034         }
27035         function bindExportDeclaration(node) {
27036             if (!container.symbol || !container.symbol.exports) {
27037                 bindAnonymousDeclaration(node, 8388608, getDeclarationName(node));
27038             }
27039             else if (!node.exportClause) {
27040                 declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 0);
27041             }
27042             else if (ts.isNamespaceExport(node.exportClause)) {
27043                 node.exportClause.parent = node;
27044                 declareSymbol(container.symbol.exports, container.symbol, node.exportClause, 2097152, 2097152);
27045             }
27046         }
27047         function bindImportClause(node) {
27048             if (node.name) {
27049                 declareSymbolAndAddToSymbolTable(node, 2097152, 2097152);
27050             }
27051         }
27052         function setCommonJsModuleIndicator(node) {
27053             if (file.externalModuleIndicator) {
27054                 return false;
27055             }
27056             if (!file.commonJsModuleIndicator) {
27057                 file.commonJsModuleIndicator = node;
27058                 bindSourceFileAsExternalModule();
27059             }
27060             return true;
27061         }
27062         function bindObjectDefinePropertyExport(node) {
27063             if (!setCommonJsModuleIndicator(node)) {
27064                 return;
27065             }
27066             var symbol = forEachIdentifierInEntityName(node.arguments[0], undefined, function (id, symbol) {
27067                 if (symbol) {
27068                     addDeclarationToSymbol(symbol, id, 1536 | 67108864);
27069                 }
27070                 return symbol;
27071             });
27072             if (symbol) {
27073                 var flags = 4 | 1048576;
27074                 declareSymbol(symbol.exports, symbol, node, flags, 0);
27075             }
27076         }
27077         function bindExportsPropertyAssignment(node) {
27078             if (!setCommonJsModuleIndicator(node)) {
27079                 return;
27080             }
27081             var symbol = forEachIdentifierInEntityName(node.left.expression, undefined, function (id, symbol) {
27082                 if (symbol) {
27083                     addDeclarationToSymbol(symbol, id, 1536 | 67108864);
27084                 }
27085                 return symbol;
27086             });
27087             if (symbol) {
27088                 var flags = ts.isClassExpression(node.right) ?
27089                     4 | 1048576 | 32 :
27090                     4 | 1048576;
27091                 declareSymbol(symbol.exports, symbol, node.left, flags, 0);
27092             }
27093         }
27094         function bindModuleExportsAssignment(node) {
27095             if (!setCommonJsModuleIndicator(node)) {
27096                 return;
27097             }
27098             var assignedExpression = ts.getRightMostAssignedExpression(node.right);
27099             if (ts.isEmptyObjectLiteral(assignedExpression) || container === file && isExportsOrModuleExportsOrAlias(file, assignedExpression)) {
27100                 return;
27101             }
27102             var flags = ts.exportAssignmentIsAlias(node)
27103                 ? 2097152
27104                 : 4 | 1048576 | 512;
27105             var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864, 0);
27106             ts.setValueDeclaration(symbol, node);
27107         }
27108         function bindThisPropertyAssignment(node) {
27109             ts.Debug.assert(ts.isInJSFile(node));
27110             var hasPrivateIdentifier = (ts.isBinaryExpression(node) && ts.isPropertyAccessExpression(node.left) && ts.isPrivateIdentifier(node.left.name))
27111                 || (ts.isPropertyAccessExpression(node) && ts.isPrivateIdentifier(node.name));
27112             if (hasPrivateIdentifier) {
27113                 return;
27114             }
27115             var thisContainer = ts.getThisContainer(node, false);
27116             switch (thisContainer.kind) {
27117                 case 244:
27118                 case 201:
27119                     var constructorSymbol = thisContainer.symbol;
27120                     if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 62) {
27121                         var l = thisContainer.parent.left;
27122                         if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) {
27123                             constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer);
27124                         }
27125                     }
27126                     if (constructorSymbol && constructorSymbol.valueDeclaration) {
27127                         constructorSymbol.members = constructorSymbol.members || ts.createSymbolTable();
27128                         if (ts.hasDynamicName(node)) {
27129                             bindDynamicallyNamedThisPropertyAssignment(node, constructorSymbol);
27130                         }
27131                         else {
27132                             declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 | 67108864, 0 & ~4);
27133                         }
27134                         addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32);
27135                     }
27136                     break;
27137                 case 162:
27138                 case 159:
27139                 case 161:
27140                 case 163:
27141                 case 164:
27142                     var containingClass = thisContainer.parent;
27143                     var symbolTable = ts.hasModifier(thisContainer, 32) ? containingClass.symbol.exports : containingClass.symbol.members;
27144                     if (ts.hasDynamicName(node)) {
27145                         bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol);
27146                     }
27147                     else {
27148                         declareSymbol(symbolTable, containingClass.symbol, node, 4 | 67108864, 0, true);
27149                     }
27150                     break;
27151                 case 290:
27152                     if (ts.hasDynamicName(node)) {
27153                         break;
27154                     }
27155                     else if (thisContainer.commonJsModuleIndicator) {
27156                         declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 | 1048576, 0);
27157                     }
27158                     else {
27159                         declareSymbolAndAddToSymbolTable(node, 1, 111550);
27160                     }
27161                     break;
27162                 default:
27163                     ts.Debug.failBadSyntaxKind(thisContainer);
27164             }
27165         }
27166         function bindDynamicallyNamedThisPropertyAssignment(node, symbol) {
27167             bindAnonymousDeclaration(node, 4, "__computed");
27168             addLateBoundAssignmentDeclarationToSymbol(node, symbol);
27169         }
27170         function addLateBoundAssignmentDeclarationToSymbol(node, symbol) {
27171             if (symbol) {
27172                 var members = symbol.assignmentDeclarationMembers || (symbol.assignmentDeclarationMembers = ts.createMap());
27173                 members.set("" + ts.getNodeId(node), node);
27174             }
27175         }
27176         function bindSpecialPropertyDeclaration(node) {
27177             if (node.expression.kind === 104) {
27178                 bindThisPropertyAssignment(node);
27179             }
27180             else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 290) {
27181                 if (ts.isPrototypeAccess(node.expression)) {
27182                     bindPrototypePropertyAssignment(node, node.parent);
27183                 }
27184                 else {
27185                     bindStaticPropertyAssignment(node);
27186                 }
27187             }
27188         }
27189         function bindPrototypeAssignment(node) {
27190             node.left.parent = node;
27191             node.right.parent = node;
27192             bindPropertyAssignment(node.left.expression, node.left, false, true);
27193         }
27194         function bindObjectDefinePrototypeProperty(node) {
27195             var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression);
27196             if (namespaceSymbol && namespaceSymbol.valueDeclaration) {
27197                 addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32);
27198             }
27199             bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, true);
27200         }
27201         function bindPrototypePropertyAssignment(lhs, parent) {
27202             var classPrototype = lhs.expression;
27203             var constructorFunction = classPrototype.expression;
27204             lhs.parent = parent;
27205             constructorFunction.parent = classPrototype;
27206             classPrototype.parent = lhs;
27207             bindPropertyAssignment(constructorFunction, lhs, true, true);
27208         }
27209         function bindObjectDefinePropertyAssignment(node) {
27210             var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]);
27211             var isToplevel = node.parent.parent.kind === 290;
27212             namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, false, false);
27213             bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, false);
27214         }
27215         function bindSpecialPropertyAssignment(node) {
27216             var parentSymbol = lookupSymbolForPropertyAccess(node.left.expression);
27217             if (!ts.isInJSFile(node) && !ts.isFunctionSymbol(parentSymbol)) {
27218                 return;
27219             }
27220             node.left.parent = node;
27221             node.right.parent = node;
27222             if (ts.isIdentifier(node.left.expression) && container === file && isExportsOrModuleExportsOrAlias(file, node.left.expression)) {
27223                 bindExportsPropertyAssignment(node);
27224             }
27225             else if (ts.hasDynamicName(node)) {
27226                 bindAnonymousDeclaration(node, 4 | 67108864, "__computed");
27227                 var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), false, false);
27228                 addLateBoundAssignmentDeclarationToSymbol(node, sym);
27229             }
27230             else {
27231                 bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticNameExpression));
27232             }
27233         }
27234         function bindStaticPropertyAssignment(node) {
27235             ts.Debug.assert(!ts.isIdentifier(node));
27236             node.expression.parent = node;
27237             bindPropertyAssignment(node.expression, node, false, false);
27238         }
27239         function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty, containerIsClass) {
27240             if (isToplevel && !isPrototypeProperty) {
27241                 var flags_1 = 1536 | 67108864;
27242                 var excludeFlags_1 = 110735 & ~67108864;
27243                 namespaceSymbol = forEachIdentifierInEntityName(entityName, namespaceSymbol, function (id, symbol, parent) {
27244                     if (symbol) {
27245                         addDeclarationToSymbol(symbol, id, flags_1);
27246                         return symbol;
27247                     }
27248                     else {
27249                         var table = parent ? parent.exports :
27250                             file.jsGlobalAugmentations || (file.jsGlobalAugmentations = ts.createSymbolTable());
27251                         return declareSymbol(table, parent, id, flags_1, excludeFlags_1);
27252                     }
27253                 });
27254             }
27255             if (containerIsClass && namespaceSymbol && namespaceSymbol.valueDeclaration) {
27256                 addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32);
27257             }
27258             return namespaceSymbol;
27259         }
27260         function bindPotentiallyNewExpandoMemberToNamespace(declaration, namespaceSymbol, isPrototypeProperty) {
27261             if (!namespaceSymbol || !isExpandoSymbol(namespaceSymbol)) {
27262                 return;
27263             }
27264             var symbolTable = isPrototypeProperty ?
27265                 (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) :
27266                 (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable()));
27267             var includes = 0;
27268             var excludes = 0;
27269             if (ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration))) {
27270                 includes = 8192;
27271                 excludes = 103359;
27272             }
27273             else if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) {
27274                 if (ts.some(declaration.arguments[2].properties, function (p) {
27275                     var id = ts.getNameOfDeclaration(p);
27276                     return !!id && ts.isIdentifier(id) && ts.idText(id) === "set";
27277                 })) {
27278                     includes |= 65536 | 4;
27279                     excludes |= 78783;
27280                 }
27281                 if (ts.some(declaration.arguments[2].properties, function (p) {
27282                     var id = ts.getNameOfDeclaration(p);
27283                     return !!id && ts.isIdentifier(id) && ts.idText(id) === "get";
27284                 })) {
27285                     includes |= 32768 | 4;
27286                     excludes |= 46015;
27287                 }
27288             }
27289             if (includes === 0) {
27290                 includes = 4;
27291                 excludes = 0;
27292             }
27293             declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864, excludes & ~67108864);
27294         }
27295         function isTopLevelNamespaceAssignment(propertyAccess) {
27296             return ts.isBinaryExpression(propertyAccess.parent)
27297                 ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 290
27298                 : propertyAccess.parent.parent.kind === 290;
27299         }
27300         function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) {
27301             var namespaceSymbol = lookupSymbolForPropertyAccess(name);
27302             var isToplevel = isTopLevelNamespaceAssignment(propertyAccess);
27303             namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty, containerIsClass);
27304             bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty);
27305         }
27306         function isExpandoSymbol(symbol) {
27307             if (symbol.flags & (16 | 32 | 1024)) {
27308                 return true;
27309             }
27310             var node = symbol.valueDeclaration;
27311             if (node && ts.isCallExpression(node)) {
27312                 return !!ts.getAssignedExpandoInitializer(node);
27313             }
27314             var init = !node ? undefined :
27315                 ts.isVariableDeclaration(node) ? node.initializer :
27316                     ts.isBinaryExpression(node) ? node.right :
27317                         ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) ? node.parent.right :
27318                             undefined;
27319             init = init && ts.getRightMostAssignedExpression(init);
27320             if (init) {
27321                 var isPrototypeAssignment = ts.isPrototypeAccess(ts.isVariableDeclaration(node) ? node.name : ts.isBinaryExpression(node) ? node.left : node);
27322                 return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 || init.operatorToken.kind === 60) ? init.right : init, isPrototypeAssignment);
27323             }
27324             return false;
27325         }
27326         function getParentOfBinaryExpression(expr) {
27327             while (ts.isBinaryExpression(expr.parent)) {
27328                 expr = expr.parent;
27329             }
27330             return expr.parent;
27331         }
27332         function lookupSymbolForPropertyAccess(node, lookupContainer) {
27333             if (lookupContainer === void 0) { lookupContainer = container; }
27334             if (ts.isIdentifier(node)) {
27335                 return lookupSymbolForNameWorker(lookupContainer, node.escapedText);
27336             }
27337             else {
27338                 var symbol = lookupSymbolForPropertyAccess(node.expression);
27339                 return symbol && symbol.exports && symbol.exports.get(ts.getElementOrPropertyAccessName(node));
27340             }
27341         }
27342         function forEachIdentifierInEntityName(e, parent, action) {
27343             if (isExportsOrModuleExportsOrAlias(file, e)) {
27344                 return file.symbol;
27345             }
27346             else if (ts.isIdentifier(e)) {
27347                 return action(e, lookupSymbolForPropertyAccess(e), parent);
27348             }
27349             else {
27350                 var s = forEachIdentifierInEntityName(e.expression, parent, action);
27351                 var name = ts.getNameOrArgument(e);
27352                 if (ts.isPrivateIdentifier(name)) {
27353                     ts.Debug.fail("unexpected PrivateIdentifier");
27354                 }
27355                 return action(name, s && s.exports && s.exports.get(ts.getElementOrPropertyAccessName(e)), s);
27356             }
27357         }
27358         function bindCallExpression(node) {
27359             if (!file.commonJsModuleIndicator && ts.isRequireCall(node, false)) {
27360                 setCommonJsModuleIndicator(node);
27361             }
27362         }
27363         function bindClassLikeDeclaration(node) {
27364             if (node.kind === 245) {
27365                 bindBlockScopedDeclaration(node, 32, 899503);
27366             }
27367             else {
27368                 var bindingName = node.name ? node.name.escapedText : "__class";
27369                 bindAnonymousDeclaration(node, 32, bindingName);
27370                 if (node.name) {
27371                     classifiableNames.set(node.name.escapedText, true);
27372                 }
27373             }
27374             var symbol = node.symbol;
27375             var prototypeSymbol = createSymbol(4 | 4194304, "prototype");
27376             var symbolExport = symbol.exports.get(prototypeSymbol.escapedName);
27377             if (symbolExport) {
27378                 if (node.name) {
27379                     node.name.parent = node;
27380                 }
27381                 file.bindDiagnostics.push(createDiagnosticForNode(symbolExport.declarations[0], ts.Diagnostics.Duplicate_identifier_0, ts.symbolName(prototypeSymbol)));
27382             }
27383             symbol.exports.set(prototypeSymbol.escapedName, prototypeSymbol);
27384             prototypeSymbol.parent = symbol;
27385         }
27386         function bindEnumDeclaration(node) {
27387             return ts.isEnumConst(node)
27388                 ? bindBlockScopedDeclaration(node, 128, 899967)
27389                 : bindBlockScopedDeclaration(node, 256, 899327);
27390         }
27391         function bindVariableDeclarationOrBindingElement(node) {
27392             if (inStrictMode) {
27393                 checkStrictModeEvalOrArguments(node, node.name);
27394             }
27395             if (!ts.isBindingPattern(node.name)) {
27396                 if (ts.isBlockOrCatchScoped(node)) {
27397                     bindBlockScopedDeclaration(node, 2, 111551);
27398                 }
27399                 else if (ts.isParameterDeclaration(node)) {
27400                     declareSymbolAndAddToSymbolTable(node, 1, 111551);
27401                 }
27402                 else {
27403                     declareSymbolAndAddToSymbolTable(node, 1, 111550);
27404                 }
27405             }
27406         }
27407         function bindParameter(node) {
27408             if (node.kind === 317 && container.kind !== 305) {
27409                 return;
27410             }
27411             if (inStrictMode && !(node.flags & 8388608)) {
27412                 checkStrictModeEvalOrArguments(node, node.name);
27413             }
27414             if (ts.isBindingPattern(node.name)) {
27415                 bindAnonymousDeclaration(node, 1, "__" + node.parent.parameters.indexOf(node));
27416             }
27417             else {
27418                 declareSymbolAndAddToSymbolTable(node, 1, 111551);
27419             }
27420             if (ts.isParameterPropertyDeclaration(node, node.parent)) {
27421                 var classDeclaration = node.parent.parent;
27422                 declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 | (node.questionToken ? 16777216 : 0), 0);
27423             }
27424         }
27425         function bindFunctionDeclaration(node) {
27426             if (!file.isDeclarationFile && !(node.flags & 8388608)) {
27427                 if (ts.isAsyncFunction(node)) {
27428                     emitFlags |= 2048;
27429                 }
27430             }
27431             checkStrictModeFunctionName(node);
27432             if (inStrictMode) {
27433                 checkStrictModeFunctionDeclaration(node);
27434                 bindBlockScopedDeclaration(node, 16, 110991);
27435             }
27436             else {
27437                 declareSymbolAndAddToSymbolTable(node, 16, 110991);
27438             }
27439         }
27440         function bindFunctionExpression(node) {
27441             if (!file.isDeclarationFile && !(node.flags & 8388608)) {
27442                 if (ts.isAsyncFunction(node)) {
27443                     emitFlags |= 2048;
27444                 }
27445             }
27446             if (currentFlow) {
27447                 node.flowNode = currentFlow;
27448             }
27449             checkStrictModeFunctionName(node);
27450             var bindingName = node.name ? node.name.escapedText : "__function";
27451             return bindAnonymousDeclaration(node, 16, bindingName);
27452         }
27453         function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) {
27454             if (!file.isDeclarationFile && !(node.flags & 8388608) && ts.isAsyncFunction(node)) {
27455                 emitFlags |= 2048;
27456             }
27457             if (currentFlow && ts.isObjectLiteralOrClassExpressionMethod(node)) {
27458                 node.flowNode = currentFlow;
27459             }
27460             return ts.hasDynamicName(node)
27461                 ? bindAnonymousDeclaration(node, symbolFlags, "__computed")
27462                 : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes);
27463         }
27464         function getInferTypeContainer(node) {
27465             var extendsType = ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && n.parent.extendsType === n; });
27466             return extendsType && extendsType.parent;
27467         }
27468         function bindTypeParameter(node) {
27469             if (ts.isJSDocTemplateTag(node.parent)) {
27470                 var container_1 = ts.find(node.parent.parent.tags, ts.isJSDocTypeAlias) || ts.getHostSignatureFromJSDoc(node.parent);
27471                 if (container_1) {
27472                     if (!container_1.locals) {
27473                         container_1.locals = ts.createSymbolTable();
27474                     }
27475                     declareSymbol(container_1.locals, undefined, node, 262144, 526824);
27476                 }
27477                 else {
27478                     declareSymbolAndAddToSymbolTable(node, 262144, 526824);
27479                 }
27480             }
27481             else if (node.parent.kind === 181) {
27482                 var container_2 = getInferTypeContainer(node.parent);
27483                 if (container_2) {
27484                     if (!container_2.locals) {
27485                         container_2.locals = ts.createSymbolTable();
27486                     }
27487                     declareSymbol(container_2.locals, undefined, node, 262144, 526824);
27488                 }
27489                 else {
27490                     bindAnonymousDeclaration(node, 262144, getDeclarationName(node));
27491                 }
27492             }
27493             else {
27494                 declareSymbolAndAddToSymbolTable(node, 262144, 526824);
27495             }
27496         }
27497         function shouldReportErrorOnModuleDeclaration(node) {
27498             var instanceState = getModuleInstanceState(node);
27499             return instanceState === 1 || (instanceState === 2 && !!options.preserveConstEnums);
27500         }
27501         function checkUnreachable(node) {
27502             if (!(currentFlow.flags & 1)) {
27503                 return false;
27504             }
27505             if (currentFlow === unreachableFlow) {
27506                 var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 224) ||
27507                     node.kind === 245 ||
27508                     (node.kind === 249 && shouldReportErrorOnModuleDeclaration(node));
27509                 if (reportError) {
27510                     currentFlow = reportedUnreachableFlow;
27511                     if (!options.allowUnreachableCode) {
27512                         var isError_1 = ts.unreachableCodeIsError(options) &&
27513                             !(node.flags & 8388608) &&
27514                             (!ts.isVariableStatement(node) ||
27515                                 !!(ts.getCombinedNodeFlags(node.declarationList) & 3) ||
27516                                 node.declarationList.declarations.some(function (d) { return !!d.initializer; }));
27517                         eachUnreachableRange(node, function (start, end) { return errorOrSuggestionOnRange(isError_1, start, end, ts.Diagnostics.Unreachable_code_detected); });
27518                     }
27519                 }
27520             }
27521             return true;
27522         }
27523     }
27524     function eachUnreachableRange(node, cb) {
27525         if (ts.isStatement(node) && isExecutableStatement(node) && ts.isBlock(node.parent)) {
27526             var statements = node.parent.statements;
27527             var slice_1 = ts.sliceAfter(statements, node);
27528             ts.getRangesWhere(slice_1, isExecutableStatement, function (start, afterEnd) { return cb(slice_1[start], slice_1[afterEnd - 1]); });
27529         }
27530         else {
27531             cb(node, node);
27532         }
27533     }
27534     function isExecutableStatement(s) {
27535         return !ts.isFunctionDeclaration(s) && !isPurelyTypeDeclaration(s) && !ts.isEnumDeclaration(s) &&
27536             !(ts.isVariableStatement(s) && !(ts.getCombinedNodeFlags(s) & (1 | 2)) && s.declarationList.declarations.some(function (d) { return !d.initializer; }));
27537     }
27538     function isPurelyTypeDeclaration(s) {
27539         switch (s.kind) {
27540             case 246:
27541             case 247:
27542                 return true;
27543             case 249:
27544                 return getModuleInstanceState(s) !== 1;
27545             case 248:
27546                 return ts.hasModifier(s, 2048);
27547             default:
27548                 return false;
27549         }
27550     }
27551     function isExportsOrModuleExportsOrAlias(sourceFile, node) {
27552         var i = 0;
27553         var q = [node];
27554         while (q.length && i < 100) {
27555             i++;
27556             node = q.shift();
27557             if (ts.isExportsIdentifier(node) || ts.isModuleExportsAccessExpression(node)) {
27558                 return true;
27559             }
27560             else if (ts.isIdentifier(node)) {
27561                 var symbol = lookupSymbolForNameWorker(sourceFile, node.escapedText);
27562                 if (!!symbol && !!symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && !!symbol.valueDeclaration.initializer) {
27563                     var init = symbol.valueDeclaration.initializer;
27564                     q.push(init);
27565                     if (ts.isAssignmentExpression(init, true)) {
27566                         q.push(init.left);
27567                         q.push(init.right);
27568                     }
27569                 }
27570             }
27571         }
27572         return false;
27573     }
27574     ts.isExportsOrModuleExportsOrAlias = isExportsOrModuleExportsOrAlias;
27575     function lookupSymbolForNameWorker(container, name) {
27576         var local = container.locals && container.locals.get(name);
27577         if (local) {
27578             return local.exportSymbol || local;
27579         }
27580         if (ts.isSourceFile(container) && container.jsGlobalAugmentations && container.jsGlobalAugmentations.has(name)) {
27581             return container.jsGlobalAugmentations.get(name);
27582         }
27583         return container.symbol && container.symbol.exports && container.symbol.exports.get(name);
27584     }
27585     function computeTransformFlagsForNode(node, subtreeFlags) {
27586         var kind = node.kind;
27587         switch (kind) {
27588             case 196:
27589                 return computeCallExpression(node, subtreeFlags);
27590             case 197:
27591                 return computeNewExpression(node, subtreeFlags);
27592             case 249:
27593                 return computeModuleDeclaration(node, subtreeFlags);
27594             case 200:
27595                 return computeParenthesizedExpression(node, subtreeFlags);
27596             case 209:
27597                 return computeBinaryExpression(node, subtreeFlags);
27598             case 226:
27599                 return computeExpressionStatement(node, subtreeFlags);
27600             case 156:
27601                 return computeParameter(node, subtreeFlags);
27602             case 202:
27603                 return computeArrowFunction(node, subtreeFlags);
27604             case 201:
27605                 return computeFunctionExpression(node, subtreeFlags);
27606             case 244:
27607                 return computeFunctionDeclaration(node, subtreeFlags);
27608             case 242:
27609                 return computeVariableDeclaration(node, subtreeFlags);
27610             case 243:
27611                 return computeVariableDeclarationList(node, subtreeFlags);
27612             case 225:
27613                 return computeVariableStatement(node, subtreeFlags);
27614             case 238:
27615                 return computeLabeledStatement(node, subtreeFlags);
27616             case 245:
27617                 return computeClassDeclaration(node, subtreeFlags);
27618             case 214:
27619                 return computeClassExpression(node, subtreeFlags);
27620             case 279:
27621                 return computeHeritageClause(node, subtreeFlags);
27622             case 280:
27623                 return computeCatchClause(node, subtreeFlags);
27624             case 216:
27625                 return computeExpressionWithTypeArguments(node, subtreeFlags);
27626             case 162:
27627                 return computeConstructor(node, subtreeFlags);
27628             case 159:
27629                 return computePropertyDeclaration(node, subtreeFlags);
27630             case 161:
27631                 return computeMethod(node, subtreeFlags);
27632             case 163:
27633             case 164:
27634                 return computeAccessor(node, subtreeFlags);
27635             case 253:
27636                 return computeImportEquals(node, subtreeFlags);
27637             case 194:
27638                 return computePropertyAccess(node, subtreeFlags);
27639             case 195:
27640                 return computeElementAccess(node, subtreeFlags);
27641             case 267:
27642             case 268:
27643                 return computeJsxOpeningLikeElement(node, subtreeFlags);
27644             default:
27645                 return computeOther(node, kind, subtreeFlags);
27646         }
27647     }
27648     ts.computeTransformFlagsForNode = computeTransformFlagsForNode;
27649     function computeCallExpression(node, subtreeFlags) {
27650         var transformFlags = subtreeFlags;
27651         var callee = ts.skipOuterExpressions(node.expression);
27652         var expression = node.expression;
27653         if (node.flags & 32) {
27654             transformFlags |= 8;
27655         }
27656         if (node.typeArguments) {
27657             transformFlags |= 1;
27658         }
27659         if (subtreeFlags & 8192 || ts.isSuperOrSuperProperty(callee)) {
27660             transformFlags |= 256;
27661             if (ts.isSuperProperty(callee)) {
27662                 transformFlags |= 4096;
27663             }
27664         }
27665         if (expression.kind === 96) {
27666             transformFlags |= 2097152;
27667         }
27668         node.transformFlags = transformFlags | 536870912;
27669         return transformFlags & ~536879104;
27670     }
27671     function computeNewExpression(node, subtreeFlags) {
27672         var transformFlags = subtreeFlags;
27673         if (node.typeArguments) {
27674             transformFlags |= 1;
27675         }
27676         if (subtreeFlags & 8192) {
27677             transformFlags |= 256;
27678         }
27679         node.transformFlags = transformFlags | 536870912;
27680         return transformFlags & ~536879104;
27681     }
27682     function computeJsxOpeningLikeElement(node, subtreeFlags) {
27683         var transformFlags = subtreeFlags | 2;
27684         if (node.typeArguments) {
27685             transformFlags |= 1;
27686         }
27687         node.transformFlags = transformFlags | 536870912;
27688         return transformFlags & ~536870912;
27689     }
27690     function computeBinaryExpression(node, subtreeFlags) {
27691         var transformFlags = subtreeFlags;
27692         var operatorTokenKind = node.operatorToken.kind;
27693         var leftKind = node.left.kind;
27694         if (operatorTokenKind === 60) {
27695             transformFlags |= 8;
27696         }
27697         else if (operatorTokenKind === 62 && leftKind === 193) {
27698             transformFlags |= 32 | 256 | 1024;
27699         }
27700         else if (operatorTokenKind === 62 && leftKind === 192) {
27701             transformFlags |= 256 | 1024;
27702         }
27703         else if (operatorTokenKind === 42
27704             || operatorTokenKind === 66) {
27705             transformFlags |= 128;
27706         }
27707         node.transformFlags = transformFlags | 536870912;
27708         return transformFlags & ~536870912;
27709     }
27710     function computeParameter(node, subtreeFlags) {
27711         var transformFlags = subtreeFlags;
27712         var name = node.name;
27713         var initializer = node.initializer;
27714         var dotDotDotToken = node.dotDotDotToken;
27715         if (node.questionToken
27716             || node.type
27717             || (subtreeFlags & 2048 && ts.some(node.decorators))
27718             || ts.isThisIdentifier(name)) {
27719             transformFlags |= 1;
27720         }
27721         if (ts.hasModifier(node, 92)) {
27722             transformFlags |= 1 | 2048;
27723         }
27724         if (subtreeFlags & 16384) {
27725             transformFlags |= 32;
27726         }
27727         if (subtreeFlags & 131072 || initializer || dotDotDotToken) {
27728             transformFlags |= 256;
27729         }
27730         node.transformFlags = transformFlags | 536870912;
27731         return transformFlags & ~536870912;
27732     }
27733     function computeParenthesizedExpression(node, subtreeFlags) {
27734         var transformFlags = subtreeFlags;
27735         var expression = node.expression;
27736         var expressionKind = expression.kind;
27737         if (expressionKind === 217
27738             || expressionKind === 199) {
27739             transformFlags |= 1;
27740         }
27741         node.transformFlags = transformFlags | 536870912;
27742         return transformFlags & ~536870912;
27743     }
27744     function computeClassDeclaration(node, subtreeFlags) {
27745         var transformFlags;
27746         if (ts.hasModifier(node, 2)) {
27747             transformFlags = 1;
27748         }
27749         else {
27750             transformFlags = subtreeFlags | 256;
27751             if ((subtreeFlags & 2048)
27752                 || node.typeParameters) {
27753                 transformFlags |= 1;
27754             }
27755         }
27756         node.transformFlags = transformFlags | 536870912;
27757         return transformFlags & ~536905728;
27758     }
27759     function computeClassExpression(node, subtreeFlags) {
27760         var transformFlags = subtreeFlags | 256;
27761         if (subtreeFlags & 2048
27762             || node.typeParameters) {
27763             transformFlags |= 1;
27764         }
27765         node.transformFlags = transformFlags | 536870912;
27766         return transformFlags & ~536905728;
27767     }
27768     function computeHeritageClause(node, subtreeFlags) {
27769         var transformFlags = subtreeFlags;
27770         switch (node.token) {
27771             case 90:
27772                 transformFlags |= 256;
27773                 break;
27774             case 113:
27775                 transformFlags |= 1;
27776                 break;
27777             default:
27778                 ts.Debug.fail("Unexpected token for heritage clause");
27779                 break;
27780         }
27781         node.transformFlags = transformFlags | 536870912;
27782         return transformFlags & ~536870912;
27783     }
27784     function computeCatchClause(node, subtreeFlags) {
27785         var transformFlags = subtreeFlags;
27786         if (!node.variableDeclaration) {
27787             transformFlags |= 16;
27788         }
27789         else if (ts.isBindingPattern(node.variableDeclaration.name)) {
27790             transformFlags |= 256;
27791         }
27792         node.transformFlags = transformFlags | 536870912;
27793         return transformFlags & ~536887296;
27794     }
27795     function computeExpressionWithTypeArguments(node, subtreeFlags) {
27796         var transformFlags = subtreeFlags | 256;
27797         if (node.typeArguments) {
27798             transformFlags |= 1;
27799         }
27800         node.transformFlags = transformFlags | 536870912;
27801         return transformFlags & ~536870912;
27802     }
27803     function computeConstructor(node, subtreeFlags) {
27804         var transformFlags = subtreeFlags;
27805         if (ts.hasModifier(node, 2270)
27806             || !node.body) {
27807             transformFlags |= 1;
27808         }
27809         if (subtreeFlags & 16384) {
27810             transformFlags |= 32;
27811         }
27812         node.transformFlags = transformFlags | 536870912;
27813         return transformFlags & ~538923008;
27814     }
27815     function computeMethod(node, subtreeFlags) {
27816         var transformFlags = subtreeFlags | 256;
27817         if (node.decorators
27818             || ts.hasModifier(node, 2270)
27819             || node.typeParameters
27820             || node.type
27821             || !node.body
27822             || node.questionToken) {
27823             transformFlags |= 1;
27824         }
27825         if (subtreeFlags & 16384) {
27826             transformFlags |= 32;
27827         }
27828         if (ts.hasModifier(node, 256)) {
27829             transformFlags |= node.asteriskToken ? 32 : 64;
27830         }
27831         if (node.asteriskToken) {
27832             transformFlags |= 512;
27833         }
27834         node.transformFlags = transformFlags | 536870912;
27835         return propagatePropertyNameFlags(node.name, transformFlags & ~538923008);
27836     }
27837     function computeAccessor(node, subtreeFlags) {
27838         var transformFlags = subtreeFlags;
27839         if (node.decorators
27840             || ts.hasModifier(node, 2270)
27841             || node.type
27842             || !node.body) {
27843             transformFlags |= 1;
27844         }
27845         if (subtreeFlags & 16384) {
27846             transformFlags |= 32;
27847         }
27848         node.transformFlags = transformFlags | 536870912;
27849         return propagatePropertyNameFlags(node.name, transformFlags & ~538923008);
27850     }
27851     function computePropertyDeclaration(node, subtreeFlags) {
27852         var transformFlags = subtreeFlags | 4194304;
27853         if (ts.some(node.decorators) || ts.hasModifier(node, 2270) || node.type || node.questionToken || node.exclamationToken) {
27854             transformFlags |= 1;
27855         }
27856         if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) {
27857             transformFlags |= 2048;
27858         }
27859         node.transformFlags = transformFlags | 536870912;
27860         return propagatePropertyNameFlags(node.name, transformFlags & ~536875008);
27861     }
27862     function computeFunctionDeclaration(node, subtreeFlags) {
27863         var transformFlags;
27864         var modifierFlags = ts.getModifierFlags(node);
27865         var body = node.body;
27866         if (!body || (modifierFlags & 2)) {
27867             transformFlags = 1;
27868         }
27869         else {
27870             transformFlags = subtreeFlags | 1048576;
27871             if (modifierFlags & 2270
27872                 || node.typeParameters
27873                 || node.type) {
27874                 transformFlags |= 1;
27875             }
27876             if (modifierFlags & 256) {
27877                 transformFlags |= node.asteriskToken ? 32 : 64;
27878             }
27879             if (subtreeFlags & 16384) {
27880                 transformFlags |= 32;
27881             }
27882             if (node.asteriskToken) {
27883                 transformFlags |= 512;
27884             }
27885         }
27886         node.transformFlags = transformFlags | 536870912;
27887         return transformFlags & ~538925056;
27888     }
27889     function computeFunctionExpression(node, subtreeFlags) {
27890         var transformFlags = subtreeFlags;
27891         if (ts.hasModifier(node, 2270)
27892             || node.typeParameters
27893             || node.type) {
27894             transformFlags |= 1;
27895         }
27896         if (ts.hasModifier(node, 256)) {
27897             transformFlags |= node.asteriskToken ? 32 : 64;
27898         }
27899         if (subtreeFlags & 16384) {
27900             transformFlags |= 32;
27901         }
27902         if (node.asteriskToken) {
27903             transformFlags |= 512;
27904         }
27905         node.transformFlags = transformFlags | 536870912;
27906         return transformFlags & ~538925056;
27907     }
27908     function computeArrowFunction(node, subtreeFlags) {
27909         var transformFlags = subtreeFlags | 256;
27910         if (ts.hasModifier(node, 2270)
27911             || node.typeParameters
27912             || node.type) {
27913             transformFlags |= 1;
27914         }
27915         if (ts.hasModifier(node, 256)) {
27916             transformFlags |= 64;
27917         }
27918         if (subtreeFlags & 16384) {
27919             transformFlags |= 32;
27920         }
27921         node.transformFlags = transformFlags | 536870912;
27922         return transformFlags & ~538920960;
27923     }
27924     function computePropertyAccess(node, subtreeFlags) {
27925         var transformFlags = subtreeFlags;
27926         if (node.flags & 32) {
27927             transformFlags |= 8;
27928         }
27929         if (node.expression.kind === 102) {
27930             transformFlags |= 64 | 32;
27931         }
27932         node.transformFlags = transformFlags | 536870912;
27933         return transformFlags & ~536870912;
27934     }
27935     function computeElementAccess(node, subtreeFlags) {
27936         var transformFlags = subtreeFlags;
27937         if (node.flags & 32) {
27938             transformFlags |= 8;
27939         }
27940         if (node.expression.kind === 102) {
27941             transformFlags |= 64 | 32;
27942         }
27943         node.transformFlags = transformFlags | 536870912;
27944         return transformFlags & ~536870912;
27945     }
27946     function computeVariableDeclaration(node, subtreeFlags) {
27947         var transformFlags = subtreeFlags;
27948         transformFlags |= 256 | 131072;
27949         if (subtreeFlags & 16384) {
27950             transformFlags |= 32;
27951         }
27952         if (node.type || node.exclamationToken) {
27953             transformFlags |= 1;
27954         }
27955         node.transformFlags = transformFlags | 536870912;
27956         return transformFlags & ~536870912;
27957     }
27958     function computeVariableStatement(node, subtreeFlags) {
27959         var transformFlags;
27960         var declarationListTransformFlags = node.declarationList.transformFlags;
27961         if (ts.hasModifier(node, 2)) {
27962             transformFlags = 1;
27963         }
27964         else {
27965             transformFlags = subtreeFlags;
27966             if (declarationListTransformFlags & 131072) {
27967                 transformFlags |= 256;
27968             }
27969         }
27970         node.transformFlags = transformFlags | 536870912;
27971         return transformFlags & ~536870912;
27972     }
27973     function computeLabeledStatement(node, subtreeFlags) {
27974         var transformFlags = subtreeFlags;
27975         if (subtreeFlags & 65536
27976             && ts.isIterationStatement(node, true)) {
27977             transformFlags |= 256;
27978         }
27979         node.transformFlags = transformFlags | 536870912;
27980         return transformFlags & ~536870912;
27981     }
27982     function computeImportEquals(node, subtreeFlags) {
27983         var transformFlags = subtreeFlags;
27984         if (!ts.isExternalModuleImportEqualsDeclaration(node)) {
27985             transformFlags |= 1;
27986         }
27987         node.transformFlags = transformFlags | 536870912;
27988         return transformFlags & ~536870912;
27989     }
27990     function computeExpressionStatement(node, subtreeFlags) {
27991         var transformFlags = subtreeFlags;
27992         node.transformFlags = transformFlags | 536870912;
27993         return transformFlags & ~536870912;
27994     }
27995     function computeModuleDeclaration(node, subtreeFlags) {
27996         var transformFlags = 1;
27997         var modifierFlags = ts.getModifierFlags(node);
27998         if ((modifierFlags & 2) === 0) {
27999             transformFlags |= subtreeFlags;
28000         }
28001         node.transformFlags = transformFlags | 536870912;
28002         return transformFlags & ~537991168;
28003     }
28004     function computeVariableDeclarationList(node, subtreeFlags) {
28005         var transformFlags = subtreeFlags | 1048576;
28006         if (subtreeFlags & 131072) {
28007             transformFlags |= 256;
28008         }
28009         if (node.flags & 3) {
28010             transformFlags |= 256 | 65536;
28011         }
28012         node.transformFlags = transformFlags | 536870912;
28013         return transformFlags & ~537018368;
28014     }
28015     function computeOther(node, kind, subtreeFlags) {
28016         var transformFlags = subtreeFlags;
28017         var excludeFlags = 536870912;
28018         switch (kind) {
28019             case 126:
28020                 transformFlags |= 32 | 64;
28021                 break;
28022             case 206:
28023                 transformFlags |= 32 | 64 | 524288;
28024                 break;
28025             case 199:
28026             case 217:
28027             case 326:
28028                 transformFlags |= 1;
28029                 excludeFlags = 536870912;
28030                 break;
28031             case 119:
28032             case 117:
28033             case 118:
28034             case 122:
28035             case 130:
28036             case 81:
28037             case 248:
28038             case 284:
28039             case 218:
28040             case 138:
28041                 transformFlags |= 1;
28042                 break;
28043             case 266:
28044             case 11:
28045             case 269:
28046             case 270:
28047             case 271:
28048             case 272:
28049             case 273:
28050             case 274:
28051             case 275:
28052             case 276:
28053                 transformFlags |= 2;
28054                 break;
28055             case 14:
28056             case 15:
28057             case 16:
28058             case 17:
28059                 if (node.templateFlags) {
28060                     transformFlags |= 32;
28061                     break;
28062                 }
28063             case 198:
28064                 if (ts.hasInvalidEscape(node.template)) {
28065                     transformFlags |= 32;
28066                     break;
28067                 }
28068             case 211:
28069             case 282:
28070             case 120:
28071             case 219:
28072                 transformFlags |= 256;
28073                 break;
28074             case 10:
28075                 if (node.hasExtendedUnicodeEscape) {
28076                     transformFlags |= 256;
28077                 }
28078                 break;
28079             case 8:
28080                 if (node.numericLiteralFlags & 384) {
28081                     transformFlags |= 256;
28082                 }
28083                 break;
28084             case 9:
28085                 transformFlags |= 4;
28086                 break;
28087             case 232:
28088                 if (node.awaitModifier) {
28089                     transformFlags |= 32;
28090                 }
28091                 transformFlags |= 256;
28092                 break;
28093             case 212:
28094                 transformFlags |= 32 | 256 | 262144;
28095                 break;
28096             case 125:
28097             case 140:
28098             case 151:
28099             case 137:
28100             case 141:
28101             case 143:
28102             case 128:
28103             case 144:
28104             case 110:
28105             case 155:
28106             case 158:
28107             case 160:
28108             case 165:
28109             case 166:
28110             case 167:
28111             case 168:
28112             case 169:
28113             case 170:
28114             case 171:
28115             case 172:
28116             case 173:
28117             case 174:
28118             case 175:
28119             case 176:
28120             case 177:
28121             case 178:
28122             case 179:
28123             case 180:
28124             case 181:
28125             case 182:
28126             case 246:
28127             case 247:
28128             case 183:
28129             case 184:
28130             case 185:
28131             case 186:
28132             case 187:
28133             case 252:
28134                 transformFlags = 1;
28135                 excludeFlags = -2;
28136                 break;
28137             case 154:
28138                 transformFlags |= 32768;
28139                 break;
28140             case 213:
28141                 transformFlags |= 256 | 8192;
28142                 break;
28143             case 283:
28144                 transformFlags |= 32 | 16384;
28145                 break;
28146             case 102:
28147                 transformFlags |= 256;
28148                 excludeFlags = 536870912;
28149                 break;
28150             case 104:
28151                 transformFlags |= 4096;
28152                 break;
28153             case 189:
28154                 transformFlags |= 256 | 131072;
28155                 if (subtreeFlags & 8192) {
28156                     transformFlags |= 32 | 16384;
28157                 }
28158                 excludeFlags = 536879104;
28159                 break;
28160             case 190:
28161                 transformFlags |= 256 | 131072;
28162                 excludeFlags = 536879104;
28163                 break;
28164             case 191:
28165                 transformFlags |= 256;
28166                 if (node.dotDotDotToken) {
28167                     transformFlags |= 8192;
28168                 }
28169                 break;
28170             case 157:
28171                 transformFlags |= 1 | 2048;
28172                 break;
28173             case 193:
28174                 excludeFlags = 536922112;
28175                 if (subtreeFlags & 32768) {
28176                     transformFlags |= 256;
28177                 }
28178                 if (subtreeFlags & 16384) {
28179                     transformFlags |= 32;
28180                 }
28181                 break;
28182             case 192:
28183                 excludeFlags = 536879104;
28184                 break;
28185             case 228:
28186             case 229:
28187             case 230:
28188             case 231:
28189                 if (subtreeFlags & 65536) {
28190                     transformFlags |= 256;
28191                 }
28192                 break;
28193             case 290:
28194                 break;
28195             case 262:
28196                 transformFlags |= 4;
28197                 break;
28198             case 235:
28199                 transformFlags |= 1048576 | 32;
28200                 break;
28201             case 233:
28202             case 234:
28203                 transformFlags |= 1048576;
28204                 break;
28205             case 76:
28206                 transformFlags |= 4194304;
28207                 break;
28208         }
28209         node.transformFlags = transformFlags | 536870912;
28210         return transformFlags & ~excludeFlags;
28211     }
28212     function propagatePropertyNameFlags(node, transformFlags) {
28213         return transformFlags | (node.transformFlags & 4096);
28214     }
28215     function getTransformFlagsSubtreeExclusions(kind) {
28216         if (kind >= 168 && kind <= 188) {
28217             return -2;
28218         }
28219         switch (kind) {
28220             case 196:
28221             case 197:
28222             case 192:
28223                 return 536879104;
28224             case 249:
28225                 return 537991168;
28226             case 156:
28227                 return 536870912;
28228             case 202:
28229                 return 538920960;
28230             case 201:
28231             case 244:
28232                 return 538925056;
28233             case 243:
28234                 return 537018368;
28235             case 245:
28236             case 214:
28237                 return 536905728;
28238             case 162:
28239                 return 538923008;
28240             case 161:
28241             case 163:
28242             case 164:
28243                 return 538923008;
28244             case 125:
28245             case 140:
28246             case 151:
28247             case 137:
28248             case 143:
28249             case 141:
28250             case 128:
28251             case 144:
28252             case 110:
28253             case 155:
28254             case 158:
28255             case 160:
28256             case 165:
28257             case 166:
28258             case 167:
28259             case 246:
28260             case 247:
28261                 return -2;
28262             case 193:
28263                 return 536922112;
28264             case 280:
28265                 return 536887296;
28266             case 189:
28267             case 190:
28268                 return 536879104;
28269             case 199:
28270             case 217:
28271             case 326:
28272             case 200:
28273             case 102:
28274                 return 536870912;
28275             case 194:
28276             case 195:
28277                 return 536870912;
28278             default:
28279                 return 536870912;
28280         }
28281     }
28282     ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions;
28283     function setParentPointers(parent, child) {
28284         child.parent = parent;
28285         ts.forEachChild(child, function (grandchild) { return setParentPointers(child, grandchild); });
28286     }
28287 })(ts || (ts = {}));
28288 var ts;
28289 (function (ts) {
28290     function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier, getTypeArguments) {
28291         return getSymbolWalker;
28292         function getSymbolWalker(accept) {
28293             if (accept === void 0) { accept = function () { return true; }; }
28294             var visitedTypes = [];
28295             var visitedSymbols = [];
28296             return {
28297                 walkType: function (type) {
28298                     try {
28299                         visitType(type);
28300                         return { visitedTypes: ts.getOwnValues(visitedTypes), visitedSymbols: ts.getOwnValues(visitedSymbols) };
28301                     }
28302                     finally {
28303                         ts.clear(visitedTypes);
28304                         ts.clear(visitedSymbols);
28305                     }
28306                 },
28307                 walkSymbol: function (symbol) {
28308                     try {
28309                         visitSymbol(symbol);
28310                         return { visitedTypes: ts.getOwnValues(visitedTypes), visitedSymbols: ts.getOwnValues(visitedSymbols) };
28311                     }
28312                     finally {
28313                         ts.clear(visitedTypes);
28314                         ts.clear(visitedSymbols);
28315                     }
28316                 },
28317             };
28318             function visitType(type) {
28319                 if (!type) {
28320                     return;
28321                 }
28322                 if (visitedTypes[type.id]) {
28323                     return;
28324                 }
28325                 visitedTypes[type.id] = type;
28326                 var shouldBail = visitSymbol(type.symbol);
28327                 if (shouldBail)
28328                     return;
28329                 if (type.flags & 524288) {
28330                     var objectType = type;
28331                     var objectFlags = objectType.objectFlags;
28332                     if (objectFlags & 4) {
28333                         visitTypeReference(type);
28334                     }
28335                     if (objectFlags & 32) {
28336                         visitMappedType(type);
28337                     }
28338                     if (objectFlags & (1 | 2)) {
28339                         visitInterfaceType(type);
28340                     }
28341                     if (objectFlags & (8 | 16)) {
28342                         visitObjectType(objectType);
28343                     }
28344                 }
28345                 if (type.flags & 262144) {
28346                     visitTypeParameter(type);
28347                 }
28348                 if (type.flags & 3145728) {
28349                     visitUnionOrIntersectionType(type);
28350                 }
28351                 if (type.flags & 4194304) {
28352                     visitIndexType(type);
28353                 }
28354                 if (type.flags & 8388608) {
28355                     visitIndexedAccessType(type);
28356                 }
28357             }
28358             function visitTypeReference(type) {
28359                 visitType(type.target);
28360                 ts.forEach(getTypeArguments(type), visitType);
28361             }
28362             function visitTypeParameter(type) {
28363                 visitType(getConstraintOfTypeParameter(type));
28364             }
28365             function visitUnionOrIntersectionType(type) {
28366                 ts.forEach(type.types, visitType);
28367             }
28368             function visitIndexType(type) {
28369                 visitType(type.type);
28370             }
28371             function visitIndexedAccessType(type) {
28372                 visitType(type.objectType);
28373                 visitType(type.indexType);
28374                 visitType(type.constraint);
28375             }
28376             function visitMappedType(type) {
28377                 visitType(type.typeParameter);
28378                 visitType(type.constraintType);
28379                 visitType(type.templateType);
28380                 visitType(type.modifiersType);
28381             }
28382             function visitSignature(signature) {
28383                 var typePredicate = getTypePredicateOfSignature(signature);
28384                 if (typePredicate) {
28385                     visitType(typePredicate.type);
28386                 }
28387                 ts.forEach(signature.typeParameters, visitType);
28388                 for (var _i = 0, _a = signature.parameters; _i < _a.length; _i++) {
28389                     var parameter = _a[_i];
28390                     visitSymbol(parameter);
28391                 }
28392                 visitType(getRestTypeOfSignature(signature));
28393                 visitType(getReturnTypeOfSignature(signature));
28394             }
28395             function visitInterfaceType(interfaceT) {
28396                 visitObjectType(interfaceT);
28397                 ts.forEach(interfaceT.typeParameters, visitType);
28398                 ts.forEach(getBaseTypes(interfaceT), visitType);
28399                 visitType(interfaceT.thisType);
28400             }
28401             function visitObjectType(type) {
28402                 var stringIndexType = getIndexTypeOfStructuredType(type, 0);
28403                 visitType(stringIndexType);
28404                 var numberIndexType = getIndexTypeOfStructuredType(type, 1);
28405                 visitType(numberIndexType);
28406                 var resolved = resolveStructuredTypeMembers(type);
28407                 for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) {
28408                     var signature = _a[_i];
28409                     visitSignature(signature);
28410                 }
28411                 for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) {
28412                     var signature = _c[_b];
28413                     visitSignature(signature);
28414                 }
28415                 for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) {
28416                     var p = _e[_d];
28417                     visitSymbol(p);
28418                 }
28419             }
28420             function visitSymbol(symbol) {
28421                 if (!symbol) {
28422                     return false;
28423                 }
28424                 var symbolId = ts.getSymbolId(symbol);
28425                 if (visitedSymbols[symbolId]) {
28426                     return false;
28427                 }
28428                 visitedSymbols[symbolId] = symbol;
28429                 if (!accept(symbol)) {
28430                     return true;
28431                 }
28432                 var t = getTypeOfSymbol(symbol);
28433                 visitType(t);
28434                 if (symbol.exports) {
28435                     symbol.exports.forEach(visitSymbol);
28436                 }
28437                 ts.forEach(symbol.declarations, function (d) {
28438                     if (d.type && d.type.kind === 172) {
28439                         var query = d.type;
28440                         var entity = getResolvedSymbol(getFirstIdentifier(query.exprName));
28441                         visitSymbol(entity);
28442                     }
28443                 });
28444                 return false;
28445             }
28446         }
28447     }
28448     ts.createGetSymbolWalker = createGetSymbolWalker;
28449 })(ts || (ts = {}));
28450 var ts;
28451 (function (ts) {
28452     var ambientModuleSymbolRegex = /^".+"$/;
28453     var anon = "(anonymous)";
28454     var nextSymbolId = 1;
28455     var nextNodeId = 1;
28456     var nextMergeId = 1;
28457     var nextFlowId = 1;
28458     var typeofEQFacts = ts.createMapFromTemplate({
28459         string: 1,
28460         number: 2,
28461         bigint: 4,
28462         boolean: 8,
28463         symbol: 16,
28464         undefined: 65536,
28465         object: 32,
28466         function: 64
28467     });
28468     var typeofNEFacts = ts.createMapFromTemplate({
28469         string: 256,
28470         number: 512,
28471         bigint: 1024,
28472         boolean: 2048,
28473         symbol: 4096,
28474         undefined: 524288,
28475         object: 8192,
28476         function: 16384
28477     });
28478     var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor);
28479     function SymbolLinks() {
28480     }
28481     function NodeLinks() {
28482         this.flags = 0;
28483     }
28484     function getNodeId(node) {
28485         if (!node.id) {
28486             node.id = nextNodeId;
28487             nextNodeId++;
28488         }
28489         return node.id;
28490     }
28491     ts.getNodeId = getNodeId;
28492     function getSymbolId(symbol) {
28493         if (!symbol.id) {
28494             symbol.id = nextSymbolId;
28495             nextSymbolId++;
28496         }
28497         return symbol.id;
28498     }
28499     ts.getSymbolId = getSymbolId;
28500     function isInstantiatedModule(node, preserveConstEnums) {
28501         var moduleState = ts.getModuleInstanceState(node);
28502         return moduleState === 1 ||
28503             (preserveConstEnums && moduleState === 2);
28504     }
28505     ts.isInstantiatedModule = isInstantiatedModule;
28506     function createTypeChecker(host, produceDiagnostics) {
28507         var getPackagesSet = ts.memoize(function () {
28508             var set = ts.createMap();
28509             host.getSourceFiles().forEach(function (sf) {
28510                 if (!sf.resolvedModules)
28511                     return;
28512                 ts.forEachEntry(sf.resolvedModules, function (r) {
28513                     if (r && r.packageId)
28514                         set.set(r.packageId.name, true);
28515                 });
28516             });
28517             return set;
28518         });
28519         var cancellationToken;
28520         var requestedExternalEmitHelpers;
28521         var externalHelpersModule;
28522         var Symbol = ts.objectAllocator.getSymbolConstructor();
28523         var Type = ts.objectAllocator.getTypeConstructor();
28524         var Signature = ts.objectAllocator.getSignatureConstructor();
28525         var typeCount = 0;
28526         var symbolCount = 0;
28527         var enumCount = 0;
28528         var totalInstantiationCount = 0;
28529         var instantiationCount = 0;
28530         var instantiationDepth = 0;
28531         var constraintDepth = 0;
28532         var currentNode;
28533         var emptySymbols = ts.createSymbolTable();
28534         var arrayVariances = [1];
28535         var compilerOptions = host.getCompilerOptions();
28536         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
28537         var moduleKind = ts.getEmitModuleKind(compilerOptions);
28538         var allowSyntheticDefaultImports = ts.getAllowSyntheticDefaultImports(compilerOptions);
28539         var strictNullChecks = ts.getStrictOptionValue(compilerOptions, "strictNullChecks");
28540         var strictFunctionTypes = ts.getStrictOptionValue(compilerOptions, "strictFunctionTypes");
28541         var strictBindCallApply = ts.getStrictOptionValue(compilerOptions, "strictBindCallApply");
28542         var strictPropertyInitialization = ts.getStrictOptionValue(compilerOptions, "strictPropertyInitialization");
28543         var noImplicitAny = ts.getStrictOptionValue(compilerOptions, "noImplicitAny");
28544         var noImplicitThis = ts.getStrictOptionValue(compilerOptions, "noImplicitThis");
28545         var keyofStringsOnly = !!compilerOptions.keyofStringsOnly;
28546         var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 32768;
28547         var emitResolver = createResolver();
28548         var nodeBuilder = createNodeBuilder();
28549         var globals = ts.createSymbolTable();
28550         var undefinedSymbol = createSymbol(4, "undefined");
28551         undefinedSymbol.declarations = [];
28552         var globalThisSymbol = createSymbol(1536, "globalThis", 8);
28553         globalThisSymbol.exports = globals;
28554         globalThisSymbol.declarations = [];
28555         globals.set(globalThisSymbol.escapedName, globalThisSymbol);
28556         var argumentsSymbol = createSymbol(4, "arguments");
28557         var requireSymbol = createSymbol(4, "require");
28558         var apparentArgumentCount;
28559         var checker = {
28560             getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); },
28561             getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); },
28562             getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; },
28563             getTypeCount: function () { return typeCount; },
28564             getInstantiationCount: function () { return totalInstantiationCount; },
28565             getRelationCacheSizes: function () { return ({
28566                 assignable: assignableRelation.size,
28567                 identity: identityRelation.size,
28568                 subtype: subtypeRelation.size,
28569                 strictSubtype: strictSubtypeRelation.size,
28570             }); },
28571             isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; },
28572             isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; },
28573             isUnknownSymbol: function (symbol) { return symbol === unknownSymbol; },
28574             getMergedSymbol: getMergedSymbol,
28575             getDiagnostics: getDiagnostics,
28576             getGlobalDiagnostics: getGlobalDiagnostics,
28577             getTypeOfSymbolAtLocation: function (symbol, location) {
28578                 location = ts.getParseTreeNode(location);
28579                 return location ? getTypeOfSymbolAtLocation(symbol, location) : errorType;
28580             },
28581             getSymbolsOfParameterPropertyDeclaration: function (parameterIn, parameterName) {
28582                 var parameter = ts.getParseTreeNode(parameterIn, ts.isParameter);
28583                 if (parameter === undefined)
28584                     return ts.Debug.fail("Cannot get symbols of a synthetic parameter that cannot be resolved to a parse-tree node.");
28585                 return getSymbolsOfParameterPropertyDeclaration(parameter, ts.escapeLeadingUnderscores(parameterName));
28586             },
28587             getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol,
28588             getPropertiesOfType: getPropertiesOfType,
28589             getPropertyOfType: function (type, name) { return getPropertyOfType(type, ts.escapeLeadingUnderscores(name)); },
28590             getPrivateIdentifierPropertyOfType: function (leftType, name, location) {
28591                 var node = ts.getParseTreeNode(location);
28592                 if (!node) {
28593                     return undefined;
28594                 }
28595                 var propName = ts.escapeLeadingUnderscores(name);
28596                 var lexicallyScopedIdentifier = lookupSymbolForPrivateIdentifierDeclaration(propName, node);
28597                 return lexicallyScopedIdentifier ? getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedIdentifier) : undefined;
28598             },
28599             getTypeOfPropertyOfType: function (type, name) { return getTypeOfPropertyOfType(type, ts.escapeLeadingUnderscores(name)); },
28600             getIndexInfoOfType: getIndexInfoOfType,
28601             getSignaturesOfType: getSignaturesOfType,
28602             getIndexTypeOfType: getIndexTypeOfType,
28603             getBaseTypes: getBaseTypes,
28604             getBaseTypeOfLiteralType: getBaseTypeOfLiteralType,
28605             getWidenedType: getWidenedType,
28606             getTypeFromTypeNode: function (nodeIn) {
28607                 var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode);
28608                 return node ? getTypeFromTypeNode(node) : errorType;
28609             },
28610             getParameterType: getTypeAtPosition,
28611             getPromisedTypeOfPromise: getPromisedTypeOfPromise,
28612             getReturnTypeOfSignature: getReturnTypeOfSignature,
28613             isNullableType: isNullableType,
28614             getNullableType: getNullableType,
28615             getNonNullableType: getNonNullableType,
28616             getNonOptionalType: removeOptionalTypeMarker,
28617             getTypeArguments: getTypeArguments,
28618             typeToTypeNode: nodeBuilder.typeToTypeNode,
28619             indexInfoToIndexSignatureDeclaration: nodeBuilder.indexInfoToIndexSignatureDeclaration,
28620             signatureToSignatureDeclaration: nodeBuilder.signatureToSignatureDeclaration,
28621             symbolToEntityName: nodeBuilder.symbolToEntityName,
28622             symbolToExpression: nodeBuilder.symbolToExpression,
28623             symbolToTypeParameterDeclarations: nodeBuilder.symbolToTypeParameterDeclarations,
28624             symbolToParameterDeclaration: nodeBuilder.symbolToParameterDeclaration,
28625             typeParameterToDeclaration: nodeBuilder.typeParameterToDeclaration,
28626             getSymbolsInScope: function (location, meaning) {
28627                 location = ts.getParseTreeNode(location);
28628                 return location ? getSymbolsInScope(location, meaning) : [];
28629             },
28630             getSymbolAtLocation: function (node) {
28631                 node = ts.getParseTreeNode(node);
28632                 return node ? getSymbolAtLocation(node, true) : undefined;
28633             },
28634             getShorthandAssignmentValueSymbol: function (node) {
28635                 node = ts.getParseTreeNode(node);
28636                 return node ? getShorthandAssignmentValueSymbol(node) : undefined;
28637             },
28638             getExportSpecifierLocalTargetSymbol: function (nodeIn) {
28639                 var node = ts.getParseTreeNode(nodeIn, ts.isExportSpecifier);
28640                 return node ? getExportSpecifierLocalTargetSymbol(node) : undefined;
28641             },
28642             getExportSymbolOfSymbol: function (symbol) {
28643                 return getMergedSymbol(symbol.exportSymbol || symbol);
28644             },
28645             getTypeAtLocation: function (node) {
28646                 node = ts.getParseTreeNode(node);
28647                 return node ? getTypeOfNode(node) : errorType;
28648             },
28649             getTypeOfAssignmentPattern: function (nodeIn) {
28650                 var node = ts.getParseTreeNode(nodeIn, ts.isAssignmentPattern);
28651                 return node && getTypeOfAssignmentPattern(node) || errorType;
28652             },
28653             getPropertySymbolOfDestructuringAssignment: function (locationIn) {
28654                 var location = ts.getParseTreeNode(locationIn, ts.isIdentifier);
28655                 return location ? getPropertySymbolOfDestructuringAssignment(location) : undefined;
28656             },
28657             signatureToString: function (signature, enclosingDeclaration, flags, kind) {
28658                 return signatureToString(signature, ts.getParseTreeNode(enclosingDeclaration), flags, kind);
28659             },
28660             typeToString: function (type, enclosingDeclaration, flags) {
28661                 return typeToString(type, ts.getParseTreeNode(enclosingDeclaration), flags);
28662             },
28663             symbolToString: function (symbol, enclosingDeclaration, meaning, flags) {
28664                 return symbolToString(symbol, ts.getParseTreeNode(enclosingDeclaration), meaning, flags);
28665             },
28666             typePredicateToString: function (predicate, enclosingDeclaration, flags) {
28667                 return typePredicateToString(predicate, ts.getParseTreeNode(enclosingDeclaration), flags);
28668             },
28669             writeSignature: function (signature, enclosingDeclaration, flags, kind, writer) {
28670                 return signatureToString(signature, ts.getParseTreeNode(enclosingDeclaration), flags, kind, writer);
28671             },
28672             writeType: function (type, enclosingDeclaration, flags, writer) {
28673                 return typeToString(type, ts.getParseTreeNode(enclosingDeclaration), flags, writer);
28674             },
28675             writeSymbol: function (symbol, enclosingDeclaration, meaning, flags, writer) {
28676                 return symbolToString(symbol, ts.getParseTreeNode(enclosingDeclaration), meaning, flags, writer);
28677             },
28678             writeTypePredicate: function (predicate, enclosingDeclaration, flags, writer) {
28679                 return typePredicateToString(predicate, ts.getParseTreeNode(enclosingDeclaration), flags, writer);
28680             },
28681             getAugmentedPropertiesOfType: getAugmentedPropertiesOfType,
28682             getRootSymbols: getRootSymbols,
28683             getContextualType: function (nodeIn, contextFlags) {
28684                 var node = ts.getParseTreeNode(nodeIn, ts.isExpression);
28685                 if (!node) {
28686                     return undefined;
28687                 }
28688                 var containingCall = ts.findAncestor(node, ts.isCallLikeExpression);
28689                 var containingCallResolvedSignature = containingCall && getNodeLinks(containingCall).resolvedSignature;
28690                 if (contextFlags & 4 && containingCall) {
28691                     var toMarkSkip = node;
28692                     do {
28693                         getNodeLinks(toMarkSkip).skipDirectInference = true;
28694                         toMarkSkip = toMarkSkip.parent;
28695                     } while (toMarkSkip && toMarkSkip !== containingCall);
28696                     getNodeLinks(containingCall).resolvedSignature = undefined;
28697                 }
28698                 var result = getContextualType(node, contextFlags);
28699                 if (contextFlags & 4 && containingCall) {
28700                     var toMarkSkip = node;
28701                     do {
28702                         getNodeLinks(toMarkSkip).skipDirectInference = undefined;
28703                         toMarkSkip = toMarkSkip.parent;
28704                     } while (toMarkSkip && toMarkSkip !== containingCall);
28705                     getNodeLinks(containingCall).resolvedSignature = containingCallResolvedSignature;
28706                 }
28707                 return result;
28708             },
28709             getContextualTypeForObjectLiteralElement: function (nodeIn) {
28710                 var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike);
28711                 return node ? getContextualTypeForObjectLiteralElement(node) : undefined;
28712             },
28713             getContextualTypeForArgumentAtIndex: function (nodeIn, argIndex) {
28714                 var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
28715                 return node && getContextualTypeForArgumentAtIndex(node, argIndex);
28716             },
28717             getContextualTypeForJsxAttribute: function (nodeIn) {
28718                 var node = ts.getParseTreeNode(nodeIn, ts.isJsxAttributeLike);
28719                 return node && getContextualTypeForJsxAttribute(node);
28720             },
28721             isContextSensitive: isContextSensitive,
28722             getFullyQualifiedName: getFullyQualifiedName,
28723             getResolvedSignature: function (node, candidatesOutArray, argumentCount) {
28724                 return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0);
28725             },
28726             getResolvedSignatureForSignatureHelp: function (node, candidatesOutArray, argumentCount) {
28727                 return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16);
28728             },
28729             getExpandedParameters: getExpandedParameters,
28730             hasEffectiveRestParameter: hasEffectiveRestParameter,
28731             getConstantValue: function (nodeIn) {
28732                 var node = ts.getParseTreeNode(nodeIn, canHaveConstantValue);
28733                 return node ? getConstantValue(node) : undefined;
28734             },
28735             isValidPropertyAccess: function (nodeIn, propertyName) {
28736                 var node = ts.getParseTreeNode(nodeIn, ts.isPropertyAccessOrQualifiedNameOrImportTypeNode);
28737                 return !!node && isValidPropertyAccess(node, ts.escapeLeadingUnderscores(propertyName));
28738             },
28739             isValidPropertyAccessForCompletions: function (nodeIn, type, property) {
28740                 var node = ts.getParseTreeNode(nodeIn, ts.isPropertyAccessExpression);
28741                 return !!node && isValidPropertyAccessForCompletions(node, type, property);
28742             },
28743             getSignatureFromDeclaration: function (declarationIn) {
28744                 var declaration = ts.getParseTreeNode(declarationIn, ts.isFunctionLike);
28745                 return declaration ? getSignatureFromDeclaration(declaration) : undefined;
28746             },
28747             isImplementationOfOverload: function (node) {
28748                 var parsed = ts.getParseTreeNode(node, ts.isFunctionLike);
28749                 return parsed ? isImplementationOfOverload(parsed) : undefined;
28750             },
28751             getImmediateAliasedSymbol: getImmediateAliasedSymbol,
28752             getAliasedSymbol: resolveAlias,
28753             getEmitResolver: getEmitResolver,
28754             getExportsOfModule: getExportsOfModuleAsArray,
28755             getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule,
28756             getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, ts.getFirstIdentifier, getTypeArguments),
28757             getAmbientModules: getAmbientModules,
28758             getJsxIntrinsicTagNamesAt: getJsxIntrinsicTagNamesAt,
28759             isOptionalParameter: function (nodeIn) {
28760                 var node = ts.getParseTreeNode(nodeIn, ts.isParameter);
28761                 return node ? isOptionalParameter(node) : false;
28762             },
28763             tryGetMemberInModuleExports: function (name, symbol) { return tryGetMemberInModuleExports(ts.escapeLeadingUnderscores(name), symbol); },
28764             tryGetMemberInModuleExportsAndProperties: function (name, symbol) { return tryGetMemberInModuleExportsAndProperties(ts.escapeLeadingUnderscores(name), symbol); },
28765             tryFindAmbientModuleWithoutAugmentations: function (moduleName) {
28766                 return tryFindAmbientModule(moduleName, false);
28767             },
28768             getApparentType: getApparentType,
28769             getUnionType: getUnionType,
28770             isTypeAssignableTo: isTypeAssignableTo,
28771             createAnonymousType: createAnonymousType,
28772             createSignature: createSignature,
28773             createSymbol: createSymbol,
28774             createIndexInfo: createIndexInfo,
28775             getAnyType: function () { return anyType; },
28776             getStringType: function () { return stringType; },
28777             getNumberType: function () { return numberType; },
28778             createPromiseType: createPromiseType,
28779             createArrayType: createArrayType,
28780             getElementTypeOfArrayType: getElementTypeOfArrayType,
28781             getBooleanType: function () { return booleanType; },
28782             getFalseType: function (fresh) { return fresh ? falseType : regularFalseType; },
28783             getTrueType: function (fresh) { return fresh ? trueType : regularTrueType; },
28784             getVoidType: function () { return voidType; },
28785             getUndefinedType: function () { return undefinedType; },
28786             getNullType: function () { return nullType; },
28787             getESSymbolType: function () { return esSymbolType; },
28788             getNeverType: function () { return neverType; },
28789             getOptionalType: function () { return optionalType; },
28790             isSymbolAccessible: isSymbolAccessible,
28791             isArrayType: isArrayType,
28792             isTupleType: isTupleType,
28793             isArrayLikeType: isArrayLikeType,
28794             isTypeInvalidDueToUnionDiscriminant: isTypeInvalidDueToUnionDiscriminant,
28795             getAllPossiblePropertiesOfTypes: getAllPossiblePropertiesOfTypes,
28796             getSuggestedSymbolForNonexistentProperty: getSuggestedSymbolForNonexistentProperty,
28797             getSuggestionForNonexistentProperty: getSuggestionForNonexistentProperty,
28798             getSuggestedSymbolForNonexistentSymbol: function (location, name, meaning) { return getSuggestedSymbolForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning); },
28799             getSuggestionForNonexistentSymbol: function (location, name, meaning) { return getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning); },
28800             getSuggestedSymbolForNonexistentModule: getSuggestedSymbolForNonexistentModule,
28801             getSuggestionForNonexistentExport: getSuggestionForNonexistentExport,
28802             getBaseConstraintOfType: getBaseConstraintOfType,
28803             getDefaultFromTypeParameter: function (type) { return type && type.flags & 262144 ? getDefaultFromTypeParameter(type) : undefined; },
28804             resolveName: function (name, location, meaning, excludeGlobals) {
28805                 return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, undefined, undefined, false, excludeGlobals);
28806             },
28807             getJsxNamespace: function (n) { return ts.unescapeLeadingUnderscores(getJsxNamespace(n)); },
28808             getAccessibleSymbolChain: getAccessibleSymbolChain,
28809             getTypePredicateOfSignature: getTypePredicateOfSignature,
28810             resolveExternalModuleName: function (moduleSpecifier) {
28811                 return resolveExternalModuleName(moduleSpecifier, moduleSpecifier, true);
28812             },
28813             resolveExternalModuleSymbol: resolveExternalModuleSymbol,
28814             tryGetThisTypeAt: function (node, includeGlobalThis) {
28815                 node = ts.getParseTreeNode(node);
28816                 return node && tryGetThisTypeAt(node, includeGlobalThis);
28817             },
28818             getTypeArgumentConstraint: function (nodeIn) {
28819                 var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode);
28820                 return node && getTypeArgumentConstraint(node);
28821             },
28822             getSuggestionDiagnostics: function (file, ct) {
28823                 if (ts.skipTypeChecking(file, compilerOptions, host)) {
28824                     return ts.emptyArray;
28825                 }
28826                 var diagnostics;
28827                 try {
28828                     cancellationToken = ct;
28829                     checkSourceFile(file);
28830                     ts.Debug.assert(!!(getNodeLinks(file).flags & 1));
28831                     diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName));
28832                     checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) {
28833                         if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 8388608))) {
28834                             (diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion }));
28835                         }
28836                     });
28837                     return diagnostics || ts.emptyArray;
28838                 }
28839                 finally {
28840                     cancellationToken = undefined;
28841                 }
28842             },
28843             runWithCancellationToken: function (token, callback) {
28844                 try {
28845                     cancellationToken = token;
28846                     return callback(checker);
28847                 }
28848                 finally {
28849                     cancellationToken = undefined;
28850                 }
28851             },
28852             getLocalTypeParametersOfClassOrInterfaceOrTypeAlias: getLocalTypeParametersOfClassOrInterfaceOrTypeAlias,
28853             isDeclarationVisible: isDeclarationVisible,
28854         };
28855         function getResolvedSignatureWorker(nodeIn, candidatesOutArray, argumentCount, checkMode) {
28856             var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
28857             apparentArgumentCount = argumentCount;
28858             var res = node ? getResolvedSignature(node, candidatesOutArray, checkMode) : undefined;
28859             apparentArgumentCount = undefined;
28860             return res;
28861         }
28862         var tupleTypes = ts.createMap();
28863         var unionTypes = ts.createMap();
28864         var intersectionTypes = ts.createMap();
28865         var literalTypes = ts.createMap();
28866         var indexedAccessTypes = ts.createMap();
28867         var substitutionTypes = ts.createMap();
28868         var evolvingArrayTypes = [];
28869         var undefinedProperties = ts.createMap();
28870         var unknownSymbol = createSymbol(4, "unknown");
28871         var resolvingSymbol = createSymbol(0, "__resolving__");
28872         var anyType = createIntrinsicType(1, "any");
28873         var autoType = createIntrinsicType(1, "any");
28874         var wildcardType = createIntrinsicType(1, "any");
28875         var errorType = createIntrinsicType(1, "error");
28876         var nonInferrableAnyType = createIntrinsicType(1, "any", 524288);
28877         var unknownType = createIntrinsicType(2, "unknown");
28878         var undefinedType = createIntrinsicType(32768, "undefined");
28879         var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768, "undefined", 524288);
28880         var optionalType = createIntrinsicType(32768, "undefined");
28881         var nullType = createIntrinsicType(65536, "null");
28882         var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536, "null", 524288);
28883         var stringType = createIntrinsicType(4, "string");
28884         var numberType = createIntrinsicType(8, "number");
28885         var bigintType = createIntrinsicType(64, "bigint");
28886         var falseType = createIntrinsicType(512, "false");
28887         var regularFalseType = createIntrinsicType(512, "false");
28888         var trueType = createIntrinsicType(512, "true");
28889         var regularTrueType = createIntrinsicType(512, "true");
28890         trueType.regularType = regularTrueType;
28891         trueType.freshType = trueType;
28892         regularTrueType.regularType = regularTrueType;
28893         regularTrueType.freshType = trueType;
28894         falseType.regularType = regularFalseType;
28895         falseType.freshType = falseType;
28896         regularFalseType.regularType = regularFalseType;
28897         regularFalseType.freshType = falseType;
28898         var booleanType = createBooleanType([regularFalseType, regularTrueType]);
28899         createBooleanType([regularFalseType, trueType]);
28900         createBooleanType([falseType, regularTrueType]);
28901         createBooleanType([falseType, trueType]);
28902         var esSymbolType = createIntrinsicType(4096, "symbol");
28903         var voidType = createIntrinsicType(16384, "void");
28904         var neverType = createIntrinsicType(131072, "never");
28905         var silentNeverType = createIntrinsicType(131072, "never");
28906         var nonInferrableType = createIntrinsicType(131072, "never", 2097152);
28907         var implicitNeverType = createIntrinsicType(131072, "never");
28908         var unreachableNeverType = createIntrinsicType(131072, "never");
28909         var nonPrimitiveType = createIntrinsicType(67108864, "object");
28910         var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]);
28911         var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType;
28912         var numberOrBigIntType = getUnionType([numberType, bigintType]);
28913         var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 ? getRestrictiveTypeParameter(t) : t; });
28914         var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 ? wildcardType : t; });
28915         var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
28916         var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
28917         emptyJsxObjectType.objectFlags |= 4096;
28918         var emptyTypeLiteralSymbol = createSymbol(2048, "__type");
28919         emptyTypeLiteralSymbol.members = ts.createSymbolTable();
28920         var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
28921         var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
28922         emptyGenericType.instantiations = ts.createMap();
28923         var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
28924         anyFunctionType.objectFlags |= 2097152;
28925         var noConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
28926         var circularConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
28927         var resolvingDefaultType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
28928         var markerSuperType = createTypeParameter();
28929         var markerSubType = createTypeParameter();
28930         markerSubType.constraint = markerSuperType;
28931         var markerOtherType = createTypeParameter();
28932         var noTypePredicate = createTypePredicate(1, "<<unresolved>>", 0, anyType);
28933         var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, undefined, 0, 0);
28934         var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, undefined, 0, 0);
28935         var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, undefined, 0, 0);
28936         var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, undefined, 0, 0);
28937         var enumNumberIndexInfo = createIndexInfo(stringType, true);
28938         var iterationTypesCache = ts.createMap();
28939         var noIterationTypes = {
28940             get yieldType() { return ts.Debug.fail("Not supported"); },
28941             get returnType() { return ts.Debug.fail("Not supported"); },
28942             get nextType() { return ts.Debug.fail("Not supported"); },
28943         };
28944         var anyIterationTypes = createIterationTypes(anyType, anyType, anyType);
28945         var anyIterationTypesExceptNext = createIterationTypes(anyType, anyType, unknownType);
28946         var defaultIterationTypes = createIterationTypes(neverType, anyType, undefinedType);
28947         var asyncIterationTypesResolver = {
28948             iterableCacheKey: "iterationTypesOfAsyncIterable",
28949             iteratorCacheKey: "iterationTypesOfAsyncIterator",
28950             iteratorSymbolName: "asyncIterator",
28951             getGlobalIteratorType: getGlobalAsyncIteratorType,
28952             getGlobalIterableType: getGlobalAsyncIterableType,
28953             getGlobalIterableIteratorType: getGlobalAsyncIterableIteratorType,
28954             getGlobalGeneratorType: getGlobalAsyncGeneratorType,
28955             resolveIterationType: getAwaitedType,
28956             mustHaveANextMethodDiagnostic: ts.Diagnostics.An_async_iterator_must_have_a_next_method,
28957             mustBeAMethodDiagnostic: ts.Diagnostics.The_0_property_of_an_async_iterator_must_be_a_method,
28958             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,
28959         };
28960         var syncIterationTypesResolver = {
28961             iterableCacheKey: "iterationTypesOfIterable",
28962             iteratorCacheKey: "iterationTypesOfIterator",
28963             iteratorSymbolName: "iterator",
28964             getGlobalIteratorType: getGlobalIteratorType,
28965             getGlobalIterableType: getGlobalIterableType,
28966             getGlobalIterableIteratorType: getGlobalIterableIteratorType,
28967             getGlobalGeneratorType: getGlobalGeneratorType,
28968             resolveIterationType: function (type, _errorNode) { return type; },
28969             mustHaveANextMethodDiagnostic: ts.Diagnostics.An_iterator_must_have_a_next_method,
28970             mustBeAMethodDiagnostic: ts.Diagnostics.The_0_property_of_an_iterator_must_be_a_method,
28971             mustHaveAValueDiagnostic: ts.Diagnostics.The_type_returned_by_the_0_method_of_an_iterator_must_have_a_value_property,
28972         };
28973         var amalgamatedDuplicates;
28974         var reverseMappedCache = ts.createMap();
28975         var ambientModulesCache;
28976         var patternAmbientModules;
28977         var patternAmbientModuleAugmentations;
28978         var globalObjectType;
28979         var globalFunctionType;
28980         var globalCallableFunctionType;
28981         var globalNewableFunctionType;
28982         var globalArrayType;
28983         var globalReadonlyArrayType;
28984         var globalStringType;
28985         var globalNumberType;
28986         var globalBooleanType;
28987         var globalRegExpType;
28988         var globalThisType;
28989         var anyArrayType;
28990         var autoArrayType;
28991         var anyReadonlyArrayType;
28992         var deferredGlobalNonNullableTypeAlias;
28993         var deferredGlobalESSymbolConstructorSymbol;
28994         var deferredGlobalESSymbolType;
28995         var deferredGlobalTypedPropertyDescriptorType;
28996         var deferredGlobalPromiseType;
28997         var deferredGlobalPromiseLikeType;
28998         var deferredGlobalPromiseConstructorSymbol;
28999         var deferredGlobalPromiseConstructorLikeType;
29000         var deferredGlobalIterableType;
29001         var deferredGlobalIteratorType;
29002         var deferredGlobalIterableIteratorType;
29003         var deferredGlobalGeneratorType;
29004         var deferredGlobalIteratorYieldResultType;
29005         var deferredGlobalIteratorReturnResultType;
29006         var deferredGlobalAsyncIterableType;
29007         var deferredGlobalAsyncIteratorType;
29008         var deferredGlobalAsyncIterableIteratorType;
29009         var deferredGlobalAsyncGeneratorType;
29010         var deferredGlobalTemplateStringsArrayType;
29011         var deferredGlobalImportMetaType;
29012         var deferredGlobalExtractSymbol;
29013         var deferredGlobalOmitSymbol;
29014         var deferredGlobalBigIntType;
29015         var allPotentiallyUnusedIdentifiers = ts.createMap();
29016         var flowLoopStart = 0;
29017         var flowLoopCount = 0;
29018         var sharedFlowCount = 0;
29019         var flowAnalysisDisabled = false;
29020         var flowInvocationCount = 0;
29021         var lastFlowNode;
29022         var lastFlowNodeReachable;
29023         var flowTypeCache;
29024         var emptyStringType = getLiteralType("");
29025         var zeroType = getLiteralType(0);
29026         var zeroBigIntType = getLiteralType({ negative: false, base10Value: "0" });
29027         var resolutionTargets = [];
29028         var resolutionResults = [];
29029         var resolutionPropertyNames = [];
29030         var suggestionCount = 0;
29031         var maximumSuggestionCount = 10;
29032         var mergedSymbols = [];
29033         var symbolLinks = [];
29034         var nodeLinks = [];
29035         var flowLoopCaches = [];
29036         var flowLoopNodes = [];
29037         var flowLoopKeys = [];
29038         var flowLoopTypes = [];
29039         var sharedFlowNodes = [];
29040         var sharedFlowTypes = [];
29041         var flowNodeReachable = [];
29042         var potentialThisCollisions = [];
29043         var potentialNewTargetCollisions = [];
29044         var potentialWeakMapCollisions = [];
29045         var awaitedTypeStack = [];
29046         var diagnostics = ts.createDiagnosticCollection();
29047         var suggestionDiagnostics = ts.createDiagnosticCollection();
29048         var typeofTypesByName = ts.createMapFromTemplate({
29049             string: stringType,
29050             number: numberType,
29051             bigint: bigintType,
29052             boolean: booleanType,
29053             symbol: esSymbolType,
29054             undefined: undefinedType
29055         });
29056         var typeofType = createTypeofType();
29057         var _jsxNamespace;
29058         var _jsxFactoryEntity;
29059         var outofbandVarianceMarkerHandler;
29060         var subtypeRelation = ts.createMap();
29061         var strictSubtypeRelation = ts.createMap();
29062         var assignableRelation = ts.createMap();
29063         var comparableRelation = ts.createMap();
29064         var identityRelation = ts.createMap();
29065         var enumRelation = ts.createMap();
29066         var builtinGlobals = ts.createSymbolTable();
29067         builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol);
29068         initializeTypeChecker();
29069         return checker;
29070         function getJsxNamespace(location) {
29071             if (location) {
29072                 var file = ts.getSourceFileOfNode(location);
29073                 if (file) {
29074                     if (file.localJsxNamespace) {
29075                         return file.localJsxNamespace;
29076                     }
29077                     var jsxPragma = file.pragmas.get("jsx");
29078                     if (jsxPragma) {
29079                         var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma;
29080                         file.localJsxFactory = ts.parseIsolatedEntityName(chosenpragma.arguments.factory, languageVersion);
29081                         ts.visitNode(file.localJsxFactory, markAsSynthetic);
29082                         if (file.localJsxFactory) {
29083                             return file.localJsxNamespace = ts.getFirstIdentifier(file.localJsxFactory).escapedText;
29084                         }
29085                     }
29086                 }
29087             }
29088             if (!_jsxNamespace) {
29089                 _jsxNamespace = "React";
29090                 if (compilerOptions.jsxFactory) {
29091                     _jsxFactoryEntity = ts.parseIsolatedEntityName(compilerOptions.jsxFactory, languageVersion);
29092                     ts.visitNode(_jsxFactoryEntity, markAsSynthetic);
29093                     if (_jsxFactoryEntity) {
29094                         _jsxNamespace = ts.getFirstIdentifier(_jsxFactoryEntity).escapedText;
29095                     }
29096                 }
29097                 else if (compilerOptions.reactNamespace) {
29098                     _jsxNamespace = ts.escapeLeadingUnderscores(compilerOptions.reactNamespace);
29099                 }
29100             }
29101             if (!_jsxFactoryEntity) {
29102                 _jsxFactoryEntity = ts.createQualifiedName(ts.createIdentifier(ts.unescapeLeadingUnderscores(_jsxNamespace)), "createElement");
29103             }
29104             return _jsxNamespace;
29105             function markAsSynthetic(node) {
29106                 node.pos = -1;
29107                 node.end = -1;
29108                 return ts.visitEachChild(node, markAsSynthetic, ts.nullTransformationContext);
29109             }
29110         }
29111         function getEmitResolver(sourceFile, cancellationToken) {
29112             getDiagnostics(sourceFile, cancellationToken);
29113             return emitResolver;
29114         }
29115         function lookupOrIssueError(location, message, arg0, arg1, arg2, arg3) {
29116             var diagnostic = location
29117                 ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3)
29118                 : ts.createCompilerDiagnostic(message, arg0, arg1, arg2, arg3);
29119             var existing = diagnostics.lookup(diagnostic);
29120             if (existing) {
29121                 return existing;
29122             }
29123             else {
29124                 diagnostics.add(diagnostic);
29125                 return diagnostic;
29126             }
29127         }
29128         function error(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             diagnostics.add(diagnostic);
29133             return diagnostic;
29134         }
29135         function addErrorOrSuggestion(isError, diagnostic) {
29136             if (isError) {
29137                 diagnostics.add(diagnostic);
29138             }
29139             else {
29140                 suggestionDiagnostics.add(__assign(__assign({}, diagnostic), { category: ts.DiagnosticCategory.Suggestion }));
29141             }
29142         }
29143         function errorOrSuggestion(isError, location, message, arg0, arg1, arg2, arg3) {
29144             addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message));
29145         }
29146         function errorAndMaybeSuggestAwait(location, maybeMissingAwait, message, arg0, arg1, arg2, arg3) {
29147             var diagnostic = error(location, message, arg0, arg1, arg2, arg3);
29148             if (maybeMissingAwait) {
29149                 var related = ts.createDiagnosticForNode(location, ts.Diagnostics.Did_you_forget_to_use_await);
29150                 ts.addRelatedInfo(diagnostic, related);
29151             }
29152             return diagnostic;
29153         }
29154         function createSymbol(flags, name, checkFlags) {
29155             symbolCount++;
29156             var symbol = (new Symbol(flags | 33554432, name));
29157             symbol.checkFlags = checkFlags || 0;
29158             return symbol;
29159         }
29160         function getExcludedSymbolFlags(flags) {
29161             var result = 0;
29162             if (flags & 2)
29163                 result |= 111551;
29164             if (flags & 1)
29165                 result |= 111550;
29166             if (flags & 4)
29167                 result |= 0;
29168             if (flags & 8)
29169                 result |= 900095;
29170             if (flags & 16)
29171                 result |= 110991;
29172             if (flags & 32)
29173                 result |= 899503;
29174             if (flags & 64)
29175                 result |= 788872;
29176             if (flags & 256)
29177                 result |= 899327;
29178             if (flags & 128)
29179                 result |= 899967;
29180             if (flags & 512)
29181                 result |= 110735;
29182             if (flags & 8192)
29183                 result |= 103359;
29184             if (flags & 32768)
29185                 result |= 46015;
29186             if (flags & 65536)
29187                 result |= 78783;
29188             if (flags & 262144)
29189                 result |= 526824;
29190             if (flags & 524288)
29191                 result |= 788968;
29192             if (flags & 2097152)
29193                 result |= 2097152;
29194             return result;
29195         }
29196         function recordMergedSymbol(target, source) {
29197             if (!source.mergeId) {
29198                 source.mergeId = nextMergeId;
29199                 nextMergeId++;
29200             }
29201             mergedSymbols[source.mergeId] = target;
29202         }
29203         function cloneSymbol(symbol) {
29204             var result = createSymbol(symbol.flags, symbol.escapedName);
29205             result.declarations = symbol.declarations ? symbol.declarations.slice() : [];
29206             result.parent = symbol.parent;
29207             if (symbol.valueDeclaration)
29208                 result.valueDeclaration = symbol.valueDeclaration;
29209             if (symbol.constEnumOnlyModule)
29210                 result.constEnumOnlyModule = true;
29211             if (symbol.members)
29212                 result.members = ts.cloneMap(symbol.members);
29213             if (symbol.exports)
29214                 result.exports = ts.cloneMap(symbol.exports);
29215             recordMergedSymbol(result, symbol);
29216             return result;
29217         }
29218         function mergeSymbol(target, source, unidirectional) {
29219             if (unidirectional === void 0) { unidirectional = false; }
29220             if (!(target.flags & getExcludedSymbolFlags(source.flags)) ||
29221                 (source.flags | target.flags) & 67108864) {
29222                 if (source === target) {
29223                     return target;
29224                 }
29225                 if (!(target.flags & 33554432)) {
29226                     var resolvedTarget = resolveSymbol(target);
29227                     if (resolvedTarget === unknownSymbol) {
29228                         return source;
29229                     }
29230                     target = cloneSymbol(resolvedTarget);
29231                 }
29232                 if (source.flags & 512 && target.flags & 512 && target.constEnumOnlyModule && !source.constEnumOnlyModule) {
29233                     target.constEnumOnlyModule = false;
29234                 }
29235                 target.flags |= source.flags;
29236                 if (source.valueDeclaration) {
29237                     ts.setValueDeclaration(target, source.valueDeclaration);
29238                 }
29239                 ts.addRange(target.declarations, source.declarations);
29240                 if (source.members) {
29241                     if (!target.members)
29242                         target.members = ts.createSymbolTable();
29243                     mergeSymbolTable(target.members, source.members, unidirectional);
29244                 }
29245                 if (source.exports) {
29246                     if (!target.exports)
29247                         target.exports = ts.createSymbolTable();
29248                     mergeSymbolTable(target.exports, source.exports, unidirectional);
29249                 }
29250                 if (!unidirectional) {
29251                     recordMergedSymbol(target, source);
29252                 }
29253             }
29254             else if (target.flags & 1024) {
29255                 if (target !== globalThisSymbol) {
29256                     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));
29257                 }
29258             }
29259             else {
29260                 var isEitherEnum = !!(target.flags & 384 || source.flags & 384);
29261                 var isEitherBlockScoped_1 = !!(target.flags & 2 || source.flags & 2);
29262                 var message = isEitherEnum
29263                     ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations
29264                     : isEitherBlockScoped_1
29265                         ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0
29266                         : ts.Diagnostics.Duplicate_identifier_0;
29267                 var sourceSymbolFile = source.declarations && ts.getSourceFileOfNode(source.declarations[0]);
29268                 var targetSymbolFile = target.declarations && ts.getSourceFileOfNode(target.declarations[0]);
29269                 var symbolName_1 = symbolToString(source);
29270                 if (sourceSymbolFile && targetSymbolFile && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile !== targetSymbolFile) {
29271                     var firstFile_1 = ts.comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === -1 ? sourceSymbolFile : targetSymbolFile;
29272                     var secondFile_1 = firstFile_1 === sourceSymbolFile ? targetSymbolFile : sourceSymbolFile;
29273                     var filesDuplicates = ts.getOrUpdate(amalgamatedDuplicates, firstFile_1.path + "|" + secondFile_1.path, function () {
29274                         return ({ firstFile: firstFile_1, secondFile: secondFile_1, conflictingSymbols: ts.createMap() });
29275                     });
29276                     var conflictingSymbolInfo = ts.getOrUpdate(filesDuplicates.conflictingSymbols, symbolName_1, function () {
29277                         return ({ isBlockScoped: isEitherBlockScoped_1, firstFileLocations: [], secondFileLocations: [] });
29278                     });
29279                     addDuplicateLocations(conflictingSymbolInfo.firstFileLocations, source);
29280                     addDuplicateLocations(conflictingSymbolInfo.secondFileLocations, target);
29281                 }
29282                 else {
29283                     addDuplicateDeclarationErrorsForSymbols(source, message, symbolName_1, target);
29284                     addDuplicateDeclarationErrorsForSymbols(target, message, symbolName_1, source);
29285                 }
29286             }
29287             return target;
29288             function addDuplicateLocations(locs, symbol) {
29289                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
29290                     var decl = _a[_i];
29291                     ts.pushIfUnique(locs, decl);
29292                 }
29293             }
29294         }
29295         function addDuplicateDeclarationErrorsForSymbols(target, message, symbolName, source) {
29296             ts.forEach(target.declarations, function (node) {
29297                 addDuplicateDeclarationError(node, message, symbolName, source.declarations);
29298             });
29299         }
29300         function addDuplicateDeclarationError(node, message, symbolName, relatedNodes) {
29301             var errorNode = (ts.getExpandoInitializer(node, false) ? ts.getNameOfExpando(node) : ts.getNameOfDeclaration(node)) || node;
29302             var err = lookupOrIssueError(errorNode, message, symbolName);
29303             var _loop_6 = function (relatedNode) {
29304                 var adjustedNode = (ts.getExpandoInitializer(relatedNode, false) ? ts.getNameOfExpando(relatedNode) : ts.getNameOfDeclaration(relatedNode)) || relatedNode;
29305                 if (adjustedNode === errorNode)
29306                     return "continue";
29307                 err.relatedInformation = err.relatedInformation || [];
29308                 var leadingMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics._0_was_also_declared_here, symbolName);
29309                 var followOnMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics.and_here);
29310                 if (ts.length(err.relatedInformation) >= 5 || ts.some(err.relatedInformation, function (r) { return ts.compareDiagnostics(r, followOnMessage) === 0 || ts.compareDiagnostics(r, leadingMessage) === 0; }))
29311                     return "continue";
29312                 ts.addRelatedInfo(err, !ts.length(err.relatedInformation) ? leadingMessage : followOnMessage);
29313             };
29314             for (var _i = 0, _a = relatedNodes || ts.emptyArray; _i < _a.length; _i++) {
29315                 var relatedNode = _a[_i];
29316                 _loop_6(relatedNode);
29317             }
29318         }
29319         function combineSymbolTables(first, second) {
29320             if (!ts.hasEntries(first))
29321                 return second;
29322             if (!ts.hasEntries(second))
29323                 return first;
29324             var combined = ts.createSymbolTable();
29325             mergeSymbolTable(combined, first);
29326             mergeSymbolTable(combined, second);
29327             return combined;
29328         }
29329         function mergeSymbolTable(target, source, unidirectional) {
29330             if (unidirectional === void 0) { unidirectional = false; }
29331             source.forEach(function (sourceSymbol, id) {
29332                 var targetSymbol = target.get(id);
29333                 target.set(id, targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol, unidirectional) : sourceSymbol);
29334             });
29335         }
29336         function mergeModuleAugmentation(moduleName) {
29337             var _a, _b;
29338             var moduleAugmentation = moduleName.parent;
29339             if (moduleAugmentation.symbol.declarations[0] !== moduleAugmentation) {
29340                 ts.Debug.assert(moduleAugmentation.symbol.declarations.length > 1);
29341                 return;
29342             }
29343             if (ts.isGlobalScopeAugmentation(moduleAugmentation)) {
29344                 mergeSymbolTable(globals, moduleAugmentation.symbol.exports);
29345             }
29346             else {
29347                 var moduleNotFoundError = !(moduleName.parent.parent.flags & 8388608)
29348                     ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found
29349                     : undefined;
29350                 var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, true);
29351                 if (!mainModule_1) {
29352                     return;
29353                 }
29354                 mainModule_1 = resolveExternalModuleSymbol(mainModule_1);
29355                 if (mainModule_1.flags & 1920) {
29356                     if (ts.some(patternAmbientModules, function (module) { return mainModule_1 === module.symbol; })) {
29357                         var merged = mergeSymbol(moduleAugmentation.symbol, mainModule_1, true);
29358                         if (!patternAmbientModuleAugmentations) {
29359                             patternAmbientModuleAugmentations = ts.createMap();
29360                         }
29361                         patternAmbientModuleAugmentations.set(moduleName.text, merged);
29362                     }
29363                     else {
29364                         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)) {
29365                             var resolvedExports = getResolvedMembersOrExportsOfSymbol(mainModule_1, "resolvedExports");
29366                             for (var _i = 0, _c = ts.arrayFrom(moduleAugmentation.symbol.exports.entries()); _i < _c.length; _i++) {
29367                                 var _d = _c[_i], key = _d[0], value = _d[1];
29368                                 if (resolvedExports.has(key) && !mainModule_1.exports.has(key)) {
29369                                     mergeSymbol(resolvedExports.get(key), value);
29370                                 }
29371                             }
29372                         }
29373                         mergeSymbol(mainModule_1, moduleAugmentation.symbol);
29374                     }
29375                 }
29376                 else {
29377                     error(moduleName, ts.Diagnostics.Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity, moduleName.text);
29378                 }
29379             }
29380         }
29381         function addToSymbolTable(target, source, message) {
29382             source.forEach(function (sourceSymbol, id) {
29383                 var targetSymbol = target.get(id);
29384                 if (targetSymbol) {
29385                     ts.forEach(targetSymbol.declarations, addDeclarationDiagnostic(ts.unescapeLeadingUnderscores(id), message));
29386                 }
29387                 else {
29388                     target.set(id, sourceSymbol);
29389                 }
29390             });
29391             function addDeclarationDiagnostic(id, message) {
29392                 return function (declaration) { return diagnostics.add(ts.createDiagnosticForNode(declaration, message, id)); };
29393             }
29394         }
29395         function getSymbolLinks(symbol) {
29396             if (symbol.flags & 33554432)
29397                 return symbol;
29398             var id = getSymbolId(symbol);
29399             return symbolLinks[id] || (symbolLinks[id] = new SymbolLinks());
29400         }
29401         function getNodeLinks(node) {
29402             var nodeId = getNodeId(node);
29403             return nodeLinks[nodeId] || (nodeLinks[nodeId] = new NodeLinks());
29404         }
29405         function isGlobalSourceFile(node) {
29406             return node.kind === 290 && !ts.isExternalOrCommonJsModule(node);
29407         }
29408         function getSymbol(symbols, name, meaning) {
29409             if (meaning) {
29410                 var symbol = getMergedSymbol(symbols.get(name));
29411                 if (symbol) {
29412                     ts.Debug.assert((ts.getCheckFlags(symbol) & 1) === 0, "Should never get an instantiated symbol here.");
29413                     if (symbol.flags & meaning) {
29414                         return symbol;
29415                     }
29416                     if (symbol.flags & 2097152) {
29417                         var target = resolveAlias(symbol);
29418                         if (target === unknownSymbol || target.flags & meaning) {
29419                             return symbol;
29420                         }
29421                     }
29422                 }
29423             }
29424         }
29425         function getSymbolsOfParameterPropertyDeclaration(parameter, parameterName) {
29426             var constructorDeclaration = parameter.parent;
29427             var classDeclaration = parameter.parent.parent;
29428             var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551);
29429             var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551);
29430             if (parameterSymbol && propertySymbol) {
29431                 return [parameterSymbol, propertySymbol];
29432             }
29433             return ts.Debug.fail("There should exist two symbols, one as property declaration and one as parameter declaration");
29434         }
29435         function isBlockScopedNameDeclaredBeforeUse(declaration, usage) {
29436             var declarationFile = ts.getSourceFileOfNode(declaration);
29437             var useFile = ts.getSourceFileOfNode(usage);
29438             var declContainer = ts.getEnclosingBlockScopeContainer(declaration);
29439             if (declarationFile !== useFile) {
29440                 if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) ||
29441                     (!compilerOptions.outFile && !compilerOptions.out) ||
29442                     isInTypeQuery(usage) ||
29443                     declaration.flags & 8388608) {
29444                     return true;
29445                 }
29446                 if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
29447                     return true;
29448                 }
29449                 var sourceFiles = host.getSourceFiles();
29450                 return sourceFiles.indexOf(declarationFile) <= sourceFiles.indexOf(useFile);
29451             }
29452             if (declaration.pos <= usage.pos) {
29453                 if (declaration.kind === 191) {
29454                     var errorBindingElement = ts.getAncestor(usage, 191);
29455                     if (errorBindingElement) {
29456                         return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) ||
29457                             declaration.pos < errorBindingElement.pos;
29458                     }
29459                     return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 242), usage);
29460                 }
29461                 else if (declaration.kind === 242) {
29462                     return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage);
29463                 }
29464                 else if (ts.isClassDeclaration(declaration)) {
29465                     return !ts.findAncestor(usage, function (n) { return ts.isComputedPropertyName(n) && n.parent.parent === declaration; });
29466                 }
29467                 else if (ts.isPropertyDeclaration(declaration)) {
29468                     return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, false);
29469                 }
29470                 else if (ts.isParameterPropertyDeclaration(declaration, declaration.parent)) {
29471                     return !(compilerOptions.target === 99 && !!compilerOptions.useDefineForClassFields
29472                         && ts.getContainingClass(declaration) === ts.getContainingClass(usage)
29473                         && isUsedInFunctionOrInstanceProperty(usage, declaration));
29474                 }
29475                 return true;
29476             }
29477             if (usage.parent.kind === 263 || (usage.parent.kind === 259 && usage.parent.isExportEquals)) {
29478                 return true;
29479             }
29480             if (usage.kind === 259 && usage.isExportEquals) {
29481                 return true;
29482             }
29483             if (!!(usage.flags & 4194304) || isInTypeQuery(usage) || usageInTypeDeclaration()) {
29484                 return true;
29485             }
29486             if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
29487                 if (compilerOptions.target === 99 && !!compilerOptions.useDefineForClassFields
29488                     && ts.getContainingClass(declaration)
29489                     && (ts.isPropertyDeclaration(declaration) || ts.isParameterPropertyDeclaration(declaration, declaration.parent))) {
29490                     return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, true);
29491                 }
29492                 else {
29493                     return true;
29494                 }
29495             }
29496             return false;
29497             function usageInTypeDeclaration() {
29498                 return !!ts.findAncestor(usage, function (node) { return ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node); });
29499             }
29500             function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) {
29501                 switch (declaration.parent.parent.kind) {
29502                     case 225:
29503                     case 230:
29504                     case 232:
29505                         if (isSameScopeDescendentOf(usage, declaration, declContainer)) {
29506                             return true;
29507                         }
29508                         break;
29509                 }
29510                 var grandparent = declaration.parent.parent;
29511                 return ts.isForInOrOfStatement(grandparent) && isSameScopeDescendentOf(usage, grandparent.expression, declContainer);
29512             }
29513             function isUsedInFunctionOrInstanceProperty(usage, declaration) {
29514                 return !!ts.findAncestor(usage, function (current) {
29515                     if (current === declContainer) {
29516                         return "quit";
29517                     }
29518                     if (ts.isFunctionLike(current)) {
29519                         return true;
29520                     }
29521                     var initializerOfProperty = current.parent &&
29522                         current.parent.kind === 159 &&
29523                         current.parent.initializer === current;
29524                     if (initializerOfProperty) {
29525                         if (ts.hasModifier(current.parent, 32)) {
29526                             if (declaration.kind === 161) {
29527                                 return true;
29528                             }
29529                         }
29530                         else {
29531                             var isDeclarationInstanceProperty = declaration.kind === 159 && !ts.hasModifier(declaration, 32);
29532                             if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) {
29533                                 return true;
29534                             }
29535                         }
29536                     }
29537                     return false;
29538                 });
29539             }
29540             function isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, stopAtAnyPropertyDeclaration) {
29541                 if (usage.end > declaration.end) {
29542                     return false;
29543                 }
29544                 var ancestorChangingReferenceScope = ts.findAncestor(usage, function (node) {
29545                     if (node === declaration) {
29546                         return "quit";
29547                     }
29548                     switch (node.kind) {
29549                         case 202:
29550                             return true;
29551                         case 159:
29552                             return stopAtAnyPropertyDeclaration &&
29553                                 (ts.isPropertyDeclaration(declaration) && node.parent === declaration.parent
29554                                     || ts.isParameterPropertyDeclaration(declaration, declaration.parent) && node.parent === declaration.parent.parent)
29555                                 ? "quit" : true;
29556                         case 223:
29557                             switch (node.parent.kind) {
29558                                 case 163:
29559                                 case 161:
29560                                 case 164:
29561                                     return true;
29562                                 default:
29563                                     return false;
29564                             }
29565                         default:
29566                             return false;
29567                     }
29568                 });
29569                 return ancestorChangingReferenceScope === undefined;
29570             }
29571         }
29572         function useOuterVariableScopeInParameter(result, location, lastLocation) {
29573             var target = ts.getEmitScriptTarget(compilerOptions);
29574             var functionLocation = location;
29575             if (ts.isParameter(lastLocation) && functionLocation.body && result.valueDeclaration.pos >= functionLocation.body.pos && result.valueDeclaration.end <= functionLocation.body.end) {
29576                 if (target >= 2) {
29577                     var links = getNodeLinks(functionLocation);
29578                     if (links.declarationRequiresScopeChange === undefined) {
29579                         links.declarationRequiresScopeChange = ts.forEach(functionLocation.parameters, requiresScopeChange) || false;
29580                     }
29581                     return !links.declarationRequiresScopeChange;
29582                 }
29583             }
29584             return false;
29585             function requiresScopeChange(node) {
29586                 return requiresScopeChangeWorker(node.name)
29587                     || !!node.initializer && requiresScopeChangeWorker(node.initializer);
29588             }
29589             function requiresScopeChangeWorker(node) {
29590                 switch (node.kind) {
29591                     case 202:
29592                     case 201:
29593                     case 244:
29594                     case 162:
29595                         return false;
29596                     case 161:
29597                     case 163:
29598                     case 164:
29599                     case 281:
29600                         return requiresScopeChangeWorker(node.name);
29601                     case 159:
29602                         if (ts.hasStaticModifier(node)) {
29603                             return target < 99 || !compilerOptions.useDefineForClassFields;
29604                         }
29605                         return requiresScopeChangeWorker(node.name);
29606                     default:
29607                         if (ts.isNullishCoalesce(node) || ts.isOptionalChain(node)) {
29608                             return target < 7;
29609                         }
29610                         if (ts.isBindingElement(node) && node.dotDotDotToken && ts.isObjectBindingPattern(node.parent)) {
29611                             return target < 4;
29612                         }
29613                         if (ts.isTypeNode(node))
29614                             return false;
29615                         return ts.forEachChild(node, requiresScopeChangeWorker) || false;
29616                 }
29617             }
29618         }
29619         function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, suggestedNameNotFoundMessage) {
29620             if (excludeGlobals === void 0) { excludeGlobals = false; }
29621             return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSymbol, suggestedNameNotFoundMessage);
29622         }
29623         function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, lookup, suggestedNameNotFoundMessage) {
29624             var originalLocation = location;
29625             var result;
29626             var lastLocation;
29627             var lastSelfReferenceLocation;
29628             var propertyWithInvalidInitializer;
29629             var associatedDeclarationForContainingInitializerOrBindingName;
29630             var withinDeferredContext = false;
29631             var errorLocation = location;
29632             var grandparent;
29633             var isInExternalModule = false;
29634             loop: while (location) {
29635                 if (location.locals && !isGlobalSourceFile(location)) {
29636                     if (result = lookup(location.locals, name, meaning)) {
29637                         var useResult = true;
29638                         if (ts.isFunctionLike(location) && lastLocation && lastLocation !== location.body) {
29639                             if (meaning & result.flags & 788968 && lastLocation.kind !== 303) {
29640                                 useResult = result.flags & 262144
29641                                     ? lastLocation === location.type ||
29642                                         lastLocation.kind === 156 ||
29643                                         lastLocation.kind === 155
29644                                     : false;
29645                             }
29646                             if (meaning & result.flags & 3) {
29647                                 if (useOuterVariableScopeInParameter(result, location, lastLocation)) {
29648                                     useResult = false;
29649                                 }
29650                                 else if (result.flags & 1) {
29651                                     useResult =
29652                                         lastLocation.kind === 156 ||
29653                                             (lastLocation === location.type &&
29654                                                 !!ts.findAncestor(result.valueDeclaration, ts.isParameter));
29655                                 }
29656                             }
29657                         }
29658                         else if (location.kind === 180) {
29659                             useResult = lastLocation === location.trueType;
29660                         }
29661                         if (useResult) {
29662                             break loop;
29663                         }
29664                         else {
29665                             result = undefined;
29666                         }
29667                     }
29668                 }
29669                 withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation);
29670                 switch (location.kind) {
29671                     case 290:
29672                         if (!ts.isExternalOrCommonJsModule(location))
29673                             break;
29674                         isInExternalModule = true;
29675                     case 249:
29676                         var moduleExports = getSymbolOfNode(location).exports || emptySymbols;
29677                         if (location.kind === 290 || (ts.isModuleDeclaration(location) && location.flags & 8388608 && !ts.isGlobalScopeAugmentation(location))) {
29678                             if (result = moduleExports.get("default")) {
29679                                 var localSymbol = ts.getLocalSymbolForExportDefault(result);
29680                                 if (localSymbol && (result.flags & meaning) && localSymbol.escapedName === name) {
29681                                     break loop;
29682                                 }
29683                                 result = undefined;
29684                             }
29685                             var moduleExport = moduleExports.get(name);
29686                             if (moduleExport &&
29687                                 moduleExport.flags === 2097152 &&
29688                                 (ts.getDeclarationOfKind(moduleExport, 263) || ts.getDeclarationOfKind(moduleExport, 262))) {
29689                                 break;
29690                             }
29691                         }
29692                         if (name !== "default" && (result = lookup(moduleExports, name, meaning & 2623475))) {
29693                             if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !result.declarations.some(ts.isJSDocTypeAlias)) {
29694                                 result = undefined;
29695                             }
29696                             else {
29697                                 break loop;
29698                             }
29699                         }
29700                         break;
29701                     case 248:
29702                         if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8)) {
29703                             break loop;
29704                         }
29705                         break;
29706                     case 159:
29707                         if (!ts.hasModifier(location, 32)) {
29708                             var ctor = findConstructorDeclaration(location.parent);
29709                             if (ctor && ctor.locals) {
29710                                 if (lookup(ctor.locals, name, meaning & 111551)) {
29711                                     propertyWithInvalidInitializer = location;
29712                                 }
29713                             }
29714                         }
29715                         break;
29716                     case 245:
29717                     case 214:
29718                     case 246:
29719                         if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968)) {
29720                             if (!isTypeParameterSymbolDeclaredInContainer(result, location)) {
29721                                 result = undefined;
29722                                 break;
29723                             }
29724                             if (lastLocation && ts.hasModifier(lastLocation, 32)) {
29725                                 error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters);
29726                                 return undefined;
29727                             }
29728                             break loop;
29729                         }
29730                         if (location.kind === 214 && meaning & 32) {
29731                             var className = location.name;
29732                             if (className && name === className.escapedText) {
29733                                 result = location.symbol;
29734                                 break loop;
29735                             }
29736                         }
29737                         break;
29738                     case 216:
29739                         if (lastLocation === location.expression && location.parent.token === 90) {
29740                             var container = location.parent.parent;
29741                             if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968))) {
29742                                 if (nameNotFoundMessage) {
29743                                     error(errorLocation, ts.Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters);
29744                                 }
29745                                 return undefined;
29746                             }
29747                         }
29748                         break;
29749                     case 154:
29750                         grandparent = location.parent.parent;
29751                         if (ts.isClassLike(grandparent) || grandparent.kind === 246) {
29752                             if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968)) {
29753                                 error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type);
29754                                 return undefined;
29755                             }
29756                         }
29757                         break;
29758                     case 202:
29759                         if (compilerOptions.target >= 2) {
29760                             break;
29761                         }
29762                     case 161:
29763                     case 162:
29764                     case 163:
29765                     case 164:
29766                     case 244:
29767                         if (meaning & 3 && name === "arguments") {
29768                             result = argumentsSymbol;
29769                             break loop;
29770                         }
29771                         break;
29772                     case 201:
29773                         if (meaning & 3 && name === "arguments") {
29774                             result = argumentsSymbol;
29775                             break loop;
29776                         }
29777                         if (meaning & 16) {
29778                             var functionName = location.name;
29779                             if (functionName && name === functionName.escapedText) {
29780                                 result = location.symbol;
29781                                 break loop;
29782                             }
29783                         }
29784                         break;
29785                     case 157:
29786                         if (location.parent && location.parent.kind === 156) {
29787                             location = location.parent;
29788                         }
29789                         if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 245)) {
29790                             location = location.parent;
29791                         }
29792                         break;
29793                     case 322:
29794                     case 315:
29795                     case 316:
29796                         location = ts.getJSDocHost(location);
29797                         break;
29798                     case 156:
29799                         if (lastLocation && (lastLocation === location.initializer ||
29800                             lastLocation === location.name && ts.isBindingPattern(lastLocation))) {
29801                             if (!associatedDeclarationForContainingInitializerOrBindingName) {
29802                                 associatedDeclarationForContainingInitializerOrBindingName = location;
29803                             }
29804                         }
29805                         break;
29806                     case 191:
29807                         if (lastLocation && (lastLocation === location.initializer ||
29808                             lastLocation === location.name && ts.isBindingPattern(lastLocation))) {
29809                             var root = ts.getRootDeclaration(location);
29810                             if (root.kind === 156) {
29811                                 if (!associatedDeclarationForContainingInitializerOrBindingName) {
29812                                     associatedDeclarationForContainingInitializerOrBindingName = location;
29813                                 }
29814                             }
29815                         }
29816                         break;
29817                 }
29818                 if (isSelfReferenceLocation(location)) {
29819                     lastSelfReferenceLocation = location;
29820                 }
29821                 lastLocation = location;
29822                 location = location.parent;
29823             }
29824             if (isUse && result && (!lastSelfReferenceLocation || result !== lastSelfReferenceLocation.symbol)) {
29825                 result.isReferenced |= meaning;
29826             }
29827             if (!result) {
29828                 if (lastLocation) {
29829                     ts.Debug.assert(lastLocation.kind === 290);
29830                     if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) {
29831                         return lastLocation.symbol;
29832                     }
29833                 }
29834                 if (!excludeGlobals) {
29835                     result = lookup(globals, name, meaning);
29836                 }
29837             }
29838             if (!result) {
29839                 if (originalLocation && ts.isInJSFile(originalLocation) && originalLocation.parent) {
29840                     if (ts.isRequireCall(originalLocation.parent, false)) {
29841                         return requireSymbol;
29842                     }
29843                 }
29844             }
29845             if (!result) {
29846                 if (nameNotFoundMessage) {
29847                     if (!errorLocation ||
29848                         !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) &&
29849                             !checkAndReportErrorForExtendingInterface(errorLocation) &&
29850                             !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
29851                             !checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
29852                             !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) &&
29853                             !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
29854                             !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
29855                         var suggestion = void 0;
29856                         if (suggestedNameNotFoundMessage && suggestionCount < maximumSuggestionCount) {
29857                             suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning);
29858                             if (suggestion) {
29859                                 var suggestionName = symbolToString(suggestion);
29860                                 var diagnostic = error(errorLocation, suggestedNameNotFoundMessage, diagnosticName(nameArg), suggestionName);
29861                                 if (suggestion.valueDeclaration) {
29862                                     ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestionName));
29863                                 }
29864                             }
29865                         }
29866                         if (!suggestion) {
29867                             error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
29868                         }
29869                         suggestionCount++;
29870                     }
29871                 }
29872                 return undefined;
29873             }
29874             if (nameNotFoundMessage) {
29875                 if (propertyWithInvalidInitializer && !(compilerOptions.target === 99 && compilerOptions.useDefineForClassFields)) {
29876                     var propertyName = propertyWithInvalidInitializer.name;
29877                     error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), diagnosticName(nameArg));
29878                     return undefined;
29879                 }
29880                 if (errorLocation &&
29881                     (meaning & 2 ||
29882                         ((meaning & 32 || meaning & 384) && (meaning & 111551) === 111551))) {
29883                     var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result);
29884                     if (exportOrLocalSymbol.flags & 2 || exportOrLocalSymbol.flags & 32 || exportOrLocalSymbol.flags & 384) {
29885                         checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation);
29886                     }
29887                 }
29888                 if (result && isInExternalModule && (meaning & 111551) === 111551 && !(originalLocation.flags & 4194304)) {
29889                     var merged = getMergedSymbol(result);
29890                     if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) {
29891                         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));
29892                     }
29893                 }
29894                 if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551) === 111551) {
29895                     var candidate = getMergedSymbol(getLateBoundSymbol(result));
29896                     var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializerOrBindingName);
29897                     if (candidate === getSymbolOfNode(associatedDeclarationForContainingInitializerOrBindingName)) {
29898                         error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_itself, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name));
29899                     }
29900                     else if (candidate.valueDeclaration && candidate.valueDeclaration.pos > associatedDeclarationForContainingInitializerOrBindingName.pos && root.parent.locals && lookup(root.parent.locals, candidate.escapedName, meaning) === candidate) {
29901                         error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), ts.declarationNameToString(errorLocation));
29902                     }
29903                 }
29904                 if (result && errorLocation && meaning & 111551 && result.flags & 2097152) {
29905                     checkSymbolUsageInExpressionContext(result, name, errorLocation);
29906                 }
29907             }
29908             return result;
29909         }
29910         function checkSymbolUsageInExpressionContext(symbol, name, useSite) {
29911             if (!ts.isValidTypeOnlyAliasUseSite(useSite)) {
29912                 var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(symbol);
29913                 if (typeOnlyDeclaration) {
29914                     var isExport = ts.typeOnlyDeclarationIsExport(typeOnlyDeclaration);
29915                     var message = isExport
29916                         ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
29917                         : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
29918                     var relatedMessage = isExport
29919                         ? ts.Diagnostics._0_was_exported_here
29920                         : ts.Diagnostics._0_was_imported_here;
29921                     var unescapedName = ts.unescapeLeadingUnderscores(name);
29922                     ts.addRelatedInfo(error(useSite, message, unescapedName), ts.createDiagnosticForNode(typeOnlyDeclaration, relatedMessage, unescapedName));
29923                 }
29924             }
29925         }
29926         function getIsDeferredContext(location, lastLocation) {
29927             if (location.kind !== 202 && location.kind !== 201) {
29928                 return ts.isTypeQueryNode(location) || ((ts.isFunctionLikeDeclaration(location) ||
29929                     (location.kind === 159 && !ts.hasModifier(location, 32))) && (!lastLocation || lastLocation !== location.name));
29930             }
29931             if (lastLocation && lastLocation === location.name) {
29932                 return false;
29933             }
29934             if (location.asteriskToken || ts.hasModifier(location, 256)) {
29935                 return true;
29936             }
29937             return !ts.getImmediatelyInvokedFunctionExpression(location);
29938         }
29939         function isSelfReferenceLocation(node) {
29940             switch (node.kind) {
29941                 case 244:
29942                 case 245:
29943                 case 246:
29944                 case 248:
29945                 case 247:
29946                 case 249:
29947                     return true;
29948                 default:
29949                     return false;
29950             }
29951         }
29952         function diagnosticName(nameArg) {
29953             return ts.isString(nameArg) ? ts.unescapeLeadingUnderscores(nameArg) : ts.declarationNameToString(nameArg);
29954         }
29955         function isTypeParameterSymbolDeclaredInContainer(symbol, container) {
29956             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
29957                 var decl = _a[_i];
29958                 if (decl.kind === 155) {
29959                     var parent = ts.isJSDocTemplateTag(decl.parent) ? ts.getJSDocHost(decl.parent) : decl.parent;
29960                     if (parent === container) {
29961                         return !(ts.isJSDocTemplateTag(decl.parent) && ts.find(decl.parent.parent.tags, ts.isJSDocTypeAlias));
29962                     }
29963                 }
29964             }
29965             return false;
29966         }
29967         function checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) {
29968             if (!ts.isIdentifier(errorLocation) || errorLocation.escapedText !== name || isTypeReferenceIdentifier(errorLocation) || isInTypeQuery(errorLocation)) {
29969                 return false;
29970             }
29971             var container = ts.getThisContainer(errorLocation, false);
29972             var location = container;
29973             while (location) {
29974                 if (ts.isClassLike(location.parent)) {
29975                     var classSymbol = getSymbolOfNode(location.parent);
29976                     if (!classSymbol) {
29977                         break;
29978                     }
29979                     var constructorType = getTypeOfSymbol(classSymbol);
29980                     if (getPropertyOfType(constructorType, name)) {
29981                         error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0, diagnosticName(nameArg), symbolToString(classSymbol));
29982                         return true;
29983                     }
29984                     if (location === container && !ts.hasModifier(location, 32)) {
29985                         var instanceType = getDeclaredTypeOfSymbol(classSymbol).thisType;
29986                         if (getPropertyOfType(instanceType, name)) {
29987                             error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0, diagnosticName(nameArg));
29988                             return true;
29989                         }
29990                     }
29991                 }
29992                 location = location.parent;
29993             }
29994             return false;
29995         }
29996         function checkAndReportErrorForExtendingInterface(errorLocation) {
29997             var expression = getEntityNameForExtendingInterface(errorLocation);
29998             if (expression && resolveEntityName(expression, 64, true)) {
29999                 error(errorLocation, ts.Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements, ts.getTextOfNode(expression));
30000                 return true;
30001             }
30002             return false;
30003         }
30004         function getEntityNameForExtendingInterface(node) {
30005             switch (node.kind) {
30006                 case 75:
30007                 case 194:
30008                     return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined;
30009                 case 216:
30010                     if (ts.isEntityNameExpression(node.expression)) {
30011                         return node.expression;
30012                     }
30013                 default:
30014                     return undefined;
30015             }
30016         }
30017         function checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) {
30018             var namespaceMeaning = 1920 | (ts.isInJSFile(errorLocation) ? 111551 : 0);
30019             if (meaning === namespaceMeaning) {
30020                 var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 & ~namespaceMeaning, undefined, undefined, false));
30021                 var parent = errorLocation.parent;
30022                 if (symbol) {
30023                     if (ts.isQualifiedName(parent)) {
30024                         ts.Debug.assert(parent.left === errorLocation, "Should only be resolving left side of qualified name as a namespace");
30025                         var propName = parent.right.escapedText;
30026                         var propType = getPropertyOfType(getDeclaredTypeOfSymbol(symbol), propName);
30027                         if (propType) {
30028                             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));
30029                             return true;
30030                         }
30031                     }
30032                     error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here, ts.unescapeLeadingUnderscores(name));
30033                     return true;
30034                 }
30035             }
30036             return false;
30037         }
30038         function checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning) {
30039             if (meaning & (788968 & ~1920)) {
30040                 var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 & 111551, undefined, undefined, false));
30041                 if (symbol && !(symbol.flags & 1920)) {
30042                     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));
30043                     return true;
30044                 }
30045             }
30046             return false;
30047         }
30048         function isPrimitiveTypeName(name) {
30049             return name === "any" || name === "string" || name === "number" || name === "boolean" || name === "never" || name === "unknown";
30050         }
30051         function checkAndReportErrorForExportingPrimitiveType(errorLocation, name) {
30052             if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 263) {
30053                 error(errorLocation, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, name);
30054                 return true;
30055             }
30056             return false;
30057         }
30058         function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) {
30059             if (meaning & (111551 & ~1024)) {
30060                 if (isPrimitiveTypeName(name)) {
30061                     error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name));
30062                     return true;
30063                 }
30064                 var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 & ~111551, undefined, undefined, false));
30065                 if (symbol && !(symbol.flags & 1024)) {
30066                     var message = isES2015OrLaterConstructorName(name)
30067                         ? 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
30068                         : ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here;
30069                     error(errorLocation, message, ts.unescapeLeadingUnderscores(name));
30070                     return true;
30071                 }
30072             }
30073             return false;
30074         }
30075         function isES2015OrLaterConstructorName(n) {
30076             switch (n) {
30077                 case "Promise":
30078                 case "Symbol":
30079                 case "Map":
30080                 case "WeakMap":
30081                 case "Set":
30082                 case "WeakSet":
30083                     return true;
30084             }
30085             return false;
30086         }
30087         function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) {
30088             if (meaning & (111551 & ~1024 & ~788968)) {
30089                 var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 & ~111551, undefined, undefined, false));
30090                 if (symbol) {
30091                     error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name));
30092                     return true;
30093                 }
30094             }
30095             else if (meaning & (788968 & ~1024 & ~111551)) {
30096                 var symbol = resolveSymbol(resolveName(errorLocation, name, (512 | 1024) & ~788968, undefined, undefined, false));
30097                 if (symbol) {
30098                     error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name));
30099                     return true;
30100                 }
30101             }
30102             return false;
30103         }
30104         function checkResolvedBlockScopedVariable(result, errorLocation) {
30105             ts.Debug.assert(!!(result.flags & 2 || result.flags & 32 || result.flags & 384));
30106             if (result.flags & (16 | 1 | 67108864) && result.flags & 32) {
30107                 return;
30108             }
30109             var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 248); });
30110             if (declaration === undefined)
30111                 return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration");
30112             if (!(declaration.flags & 8388608) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) {
30113                 var diagnosticMessage = void 0;
30114                 var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration));
30115                 if (result.flags & 2) {
30116                     diagnosticMessage = error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationName);
30117                 }
30118                 else if (result.flags & 32) {
30119                     diagnosticMessage = error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName);
30120                 }
30121                 else if (result.flags & 256) {
30122                     diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName);
30123                 }
30124                 else {
30125                     ts.Debug.assert(!!(result.flags & 128));
30126                     if (compilerOptions.preserveConstEnums) {
30127                         diagnosticMessage = error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName);
30128                     }
30129                 }
30130                 if (diagnosticMessage) {
30131                     ts.addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(declaration, ts.Diagnostics._0_is_declared_here, declarationName));
30132                 }
30133             }
30134         }
30135         function isSameScopeDescendentOf(initial, parent, stopAt) {
30136             return !!parent && !!ts.findAncestor(initial, function (n) { return n === stopAt || ts.isFunctionLike(n) ? "quit" : n === parent; });
30137         }
30138         function getAnyImportSyntax(node) {
30139             switch (node.kind) {
30140                 case 253:
30141                     return node;
30142                 case 255:
30143                     return node.parent;
30144                 case 256:
30145                     return node.parent.parent;
30146                 case 258:
30147                     return node.parent.parent.parent;
30148                 default:
30149                     return undefined;
30150             }
30151         }
30152         function getDeclarationOfAliasSymbol(symbol) {
30153             return ts.find(symbol.declarations, isAliasSymbolDeclaration);
30154         }
30155         function isAliasSymbolDeclaration(node) {
30156             return node.kind === 253 ||
30157                 node.kind === 252 ||
30158                 node.kind === 255 && !!node.name ||
30159                 node.kind === 256 ||
30160                 node.kind === 262 ||
30161                 node.kind === 258 ||
30162                 node.kind === 263 ||
30163                 node.kind === 259 && ts.exportAssignmentIsAlias(node) ||
30164                 ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 && ts.exportAssignmentIsAlias(node) ||
30165                 ts.isPropertyAccessExpression(node)
30166                     && ts.isBinaryExpression(node.parent)
30167                     && node.parent.left === node
30168                     && node.parent.operatorToken.kind === 62
30169                     && isAliasableOrJsExpression(node.parent.right) ||
30170                 node.kind === 282 ||
30171                 node.kind === 281 && isAliasableOrJsExpression(node.initializer);
30172         }
30173         function isAliasableOrJsExpression(e) {
30174             return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
30175         }
30176         function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) {
30177             if (node.moduleReference.kind === 265) {
30178                 var immediate = resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node));
30179                 var resolved_4 = resolveExternalModuleSymbol(immediate);
30180                 markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved_4, false);
30181                 return resolved_4;
30182             }
30183             var resolved = getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias);
30184             checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node, resolved);
30185             return resolved;
30186         }
30187         function checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node, resolved) {
30188             if (markSymbolOfAliasDeclarationIfTypeOnly(node, undefined, resolved, false)) {
30189                 var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(getSymbolOfNode(node));
30190                 var isExport = ts.typeOnlyDeclarationIsExport(typeOnlyDeclaration);
30191                 var message = isExport
30192                     ? ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type
30193                     : ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type;
30194                 var relatedMessage = isExport
30195                     ? ts.Diagnostics._0_was_exported_here
30196                     : ts.Diagnostics._0_was_imported_here;
30197                 var name = ts.unescapeLeadingUnderscores(typeOnlyDeclaration.name.escapedText);
30198                 ts.addRelatedInfo(error(node.moduleReference, message), ts.createDiagnosticForNode(typeOnlyDeclaration, relatedMessage, name));
30199             }
30200         }
30201         function resolveExportByName(moduleSymbol, name, sourceNode, dontResolveAlias) {
30202             var exportValue = moduleSymbol.exports.get("export=");
30203             if (exportValue) {
30204                 return getPropertyOfType(getTypeOfSymbol(exportValue), name);
30205             }
30206             var exportSymbol = moduleSymbol.exports.get(name);
30207             var resolved = resolveSymbol(exportSymbol, dontResolveAlias);
30208             markSymbolOfAliasDeclarationIfTypeOnly(sourceNode, exportSymbol, resolved, false);
30209             return resolved;
30210         }
30211         function isSyntacticDefault(node) {
30212             return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasModifier(node, 512) || ts.isExportSpecifier(node));
30213         }
30214         function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias) {
30215             if (!allowSyntheticDefaultImports) {
30216                 return false;
30217             }
30218             if (!file || file.isDeclarationFile) {
30219                 var defaultExportSymbol = resolveExportByName(moduleSymbol, "default", undefined, true);
30220                 if (defaultExportSymbol && ts.some(defaultExportSymbol.declarations, isSyntacticDefault)) {
30221                     return false;
30222                 }
30223                 if (resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), undefined, dontResolveAlias)) {
30224                     return false;
30225                 }
30226                 return true;
30227             }
30228             if (!ts.isSourceFileJS(file)) {
30229                 return hasExportAssignmentSymbol(moduleSymbol);
30230             }
30231             return !file.externalModuleIndicator && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), undefined, dontResolveAlias);
30232         }
30233         function getTargetOfImportClause(node, dontResolveAlias) {
30234             var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier);
30235             if (moduleSymbol) {
30236                 var exportDefaultSymbol = void 0;
30237                 if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) {
30238                     exportDefaultSymbol = moduleSymbol;
30239                 }
30240                 else {
30241                     exportDefaultSymbol = resolveExportByName(moduleSymbol, "default", node, dontResolveAlias);
30242                 }
30243                 var file = ts.find(moduleSymbol.declarations, ts.isSourceFile);
30244                 var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias);
30245                 if (!exportDefaultSymbol && !hasSyntheticDefault) {
30246                     if (hasExportAssignmentSymbol(moduleSymbol)) {
30247                         var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop";
30248                         var exportEqualsSymbol = moduleSymbol.exports.get("export=");
30249                         var exportAssignment = exportEqualsSymbol.valueDeclaration;
30250                         var err = error(node.name, ts.Diagnostics.Module_0_can_only_be_default_imported_using_the_1_flag, symbolToString(moduleSymbol), compilerOptionName);
30251                         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));
30252                     }
30253                     else {
30254                         reportNonDefaultExport(moduleSymbol, node);
30255                     }
30256                 }
30257                 else if (hasSyntheticDefault) {
30258                     var resolved = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
30259                     markSymbolOfAliasDeclarationIfTypeOnly(node, moduleSymbol, resolved, false);
30260                     return resolved;
30261                 }
30262                 markSymbolOfAliasDeclarationIfTypeOnly(node, exportDefaultSymbol, undefined, false);
30263                 return exportDefaultSymbol;
30264             }
30265         }
30266         function reportNonDefaultExport(moduleSymbol, node) {
30267             var _a, _b;
30268             if ((_a = moduleSymbol.exports) === null || _a === void 0 ? void 0 : _a.has(node.symbol.escapedName)) {
30269                 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));
30270             }
30271             else {
30272                 var diagnostic = error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol));
30273                 var exportStar = (_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.get("__export");
30274                 if (exportStar) {
30275                     var defaultExport = ts.find(exportStar.declarations, function (decl) {
30276                         var _a, _b;
30277                         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")));
30278                     });
30279                     if (defaultExport) {
30280                         ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(defaultExport, ts.Diagnostics.export_Asterisk_does_not_re_export_a_default));
30281                     }
30282                 }
30283             }
30284         }
30285         function getTargetOfNamespaceImport(node, dontResolveAlias) {
30286             var moduleSpecifier = node.parent.parent.moduleSpecifier;
30287             var immediate = resolveExternalModuleName(node, moduleSpecifier);
30288             var resolved = resolveESModuleSymbol(immediate, moduleSpecifier, dontResolveAlias, false);
30289             markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved, false);
30290             return resolved;
30291         }
30292         function getTargetOfNamespaceExport(node, dontResolveAlias) {
30293             var moduleSpecifier = node.parent.moduleSpecifier;
30294             var immediate = moduleSpecifier && resolveExternalModuleName(node, moduleSpecifier);
30295             var resolved = moduleSpecifier && resolveESModuleSymbol(immediate, moduleSpecifier, dontResolveAlias, false);
30296             markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved, false);
30297             return resolved;
30298         }
30299         function combineValueAndTypeSymbols(valueSymbol, typeSymbol) {
30300             if (valueSymbol === unknownSymbol && typeSymbol === unknownSymbol) {
30301                 return unknownSymbol;
30302             }
30303             if (valueSymbol.flags & (788968 | 1920)) {
30304                 return valueSymbol;
30305             }
30306             var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.escapedName);
30307             result.declarations = ts.deduplicate(ts.concatenate(valueSymbol.declarations, typeSymbol.declarations), ts.equateValues);
30308             result.parent = valueSymbol.parent || typeSymbol.parent;
30309             if (valueSymbol.valueDeclaration)
30310                 result.valueDeclaration = valueSymbol.valueDeclaration;
30311             if (typeSymbol.members)
30312                 result.members = ts.cloneMap(typeSymbol.members);
30313             if (valueSymbol.exports)
30314                 result.exports = ts.cloneMap(valueSymbol.exports);
30315             return result;
30316         }
30317         function getExportOfModule(symbol, specifier, dontResolveAlias) {
30318             var _a;
30319             if (symbol.flags & 1536) {
30320                 var name = ((_a = specifier.propertyName) !== null && _a !== void 0 ? _a : specifier.name).escapedText;
30321                 var exportSymbol = getExportsOfSymbol(symbol).get(name);
30322                 var resolved = resolveSymbol(exportSymbol, dontResolveAlias);
30323                 markSymbolOfAliasDeclarationIfTypeOnly(specifier, exportSymbol, resolved, false);
30324                 return resolved;
30325             }
30326         }
30327         function getPropertyOfVariable(symbol, name) {
30328             if (symbol.flags & 3) {
30329                 var typeAnnotation = symbol.valueDeclaration.type;
30330                 if (typeAnnotation) {
30331                     return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name));
30332                 }
30333             }
30334         }
30335         function getExternalModuleMember(node, specifier, dontResolveAlias) {
30336             var _a;
30337             if (dontResolveAlias === void 0) { dontResolveAlias = false; }
30338             var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier);
30339             var name = specifier.propertyName || specifier.name;
30340             var suppressInteropError = name.escapedText === "default" && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop);
30341             var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias, suppressInteropError);
30342             if (targetSymbol) {
30343                 if (name.escapedText) {
30344                     if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) {
30345                         return moduleSymbol;
30346                     }
30347                     var symbolFromVariable = void 0;
30348                     if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=")) {
30349                         symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name.escapedText);
30350                     }
30351                     else {
30352                         symbolFromVariable = getPropertyOfVariable(targetSymbol, name.escapedText);
30353                     }
30354                     symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias);
30355                     var symbolFromModule = getExportOfModule(targetSymbol, specifier, dontResolveAlias);
30356                     if (symbolFromModule === undefined && name.escapedText === "default") {
30357                         var file = ts.find(moduleSymbol.declarations, ts.isSourceFile);
30358                         if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias)) {
30359                             symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
30360                         }
30361                     }
30362                     var symbol = symbolFromModule && symbolFromVariable && symbolFromModule !== symbolFromVariable ?
30363                         combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) :
30364                         symbolFromModule || symbolFromVariable;
30365                     if (!symbol) {
30366                         var moduleName = getFullyQualifiedName(moduleSymbol, node);
30367                         var declarationName = ts.declarationNameToString(name);
30368                         var suggestion = getSuggestedSymbolForNonexistentModule(name, targetSymbol);
30369                         if (suggestion !== undefined) {
30370                             var suggestionName = symbolToString(suggestion);
30371                             var diagnostic = error(name, ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_2, moduleName, declarationName, suggestionName);
30372                             if (suggestion.valueDeclaration) {
30373                                 ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestionName));
30374                             }
30375                         }
30376                         else {
30377                             if ((_a = moduleSymbol.exports) === null || _a === void 0 ? void 0 : _a.has("default")) {
30378                                 error(name, ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead, moduleName, declarationName);
30379                             }
30380                             else {
30381                                 reportNonExportedMember(node, name, declarationName, moduleSymbol, moduleName);
30382                             }
30383                         }
30384                     }
30385                     return symbol;
30386                 }
30387             }
30388         }
30389         function reportNonExportedMember(node, name, declarationName, moduleSymbol, moduleName) {
30390             var _a;
30391             var localSymbol = (_a = moduleSymbol.valueDeclaration.locals) === null || _a === void 0 ? void 0 : _a.get(name.escapedText);
30392             var exports = moduleSymbol.exports;
30393             if (localSymbol) {
30394                 var exportedEqualsSymbol = exports === null || exports === void 0 ? void 0 : exports.get("export=");
30395                 if (exportedEqualsSymbol) {
30396                     getSymbolIfSameReference(exportedEqualsSymbol, localSymbol) ? reportInvalidImportEqualsExportMember(node, name, declarationName, moduleName) :
30397                         error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName);
30398                 }
30399                 else {
30400                     var exportedSymbol = exports ? ts.find(symbolsToArray(exports), function (symbol) { return !!getSymbolIfSameReference(symbol, localSymbol); }) : undefined;
30401                     var diagnostic = exportedSymbol ? error(name, ts.Diagnostics.Module_0_declares_1_locally_but_it_is_exported_as_2, moduleName, declarationName, symbolToString(exportedSymbol)) :
30402                         error(name, ts.Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported, moduleName, declarationName);
30403                     ts.addRelatedInfo.apply(void 0, __spreadArrays([diagnostic], ts.map(localSymbol.declarations, function (decl, index) {
30404                         return ts.createDiagnosticForNode(decl, index === 0 ? ts.Diagnostics._0_is_declared_here : ts.Diagnostics.and_here, declarationName);
30405                     })));
30406                 }
30407             }
30408             else {
30409                 error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName);
30410             }
30411         }
30412         function reportInvalidImportEqualsExportMember(node, name, declarationName, moduleName) {
30413             if (moduleKind >= ts.ModuleKind.ES2015) {
30414                 var message = compilerOptions.esModuleInterop ? ts.Diagnostics._0_can_only_be_imported_by_using_a_default_import :
30415                     ts.Diagnostics._0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import;
30416                 error(name, message, declarationName);
30417             }
30418             else {
30419                 if (ts.isInJSFile(node)) {
30420                     var message = compilerOptions.esModuleInterop ? ts.Diagnostics._0_can_only_be_imported_by_using_a_require_call_or_by_using_a_default_import :
30421                         ts.Diagnostics._0_can_only_be_imported_by_using_a_require_call_or_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import;
30422                     error(name, message, declarationName);
30423                 }
30424                 else {
30425                     var message = compilerOptions.esModuleInterop ? ts.Diagnostics._0_can_only_be_imported_by_using_import_1_require_2_or_a_default_import :
30426                         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;
30427                     error(name, message, declarationName, declarationName, moduleName);
30428                 }
30429             }
30430         }
30431         function getTargetOfImportSpecifier(node, dontResolveAlias) {
30432             var resolved = getExternalModuleMember(node.parent.parent.parent, node, dontResolveAlias);
30433             markSymbolOfAliasDeclarationIfTypeOnly(node, undefined, resolved, false);
30434             return resolved;
30435         }
30436         function getTargetOfNamespaceExportDeclaration(node, dontResolveAlias) {
30437             var resolved = resolveExternalModuleSymbol(node.parent.symbol, dontResolveAlias);
30438             markSymbolOfAliasDeclarationIfTypeOnly(node, undefined, resolved, false);
30439             return resolved;
30440         }
30441         function getTargetOfExportSpecifier(node, meaning, dontResolveAlias) {
30442             var resolved = node.parent.parent.moduleSpecifier ?
30443                 getExternalModuleMember(node.parent.parent, node, dontResolveAlias) :
30444                 resolveEntityName(node.propertyName || node.name, meaning, false, dontResolveAlias);
30445             markSymbolOfAliasDeclarationIfTypeOnly(node, undefined, resolved, false);
30446             return resolved;
30447         }
30448         function getTargetOfExportAssignment(node, dontResolveAlias) {
30449             var expression = ts.isExportAssignment(node) ? node.expression : node.right;
30450             var resolved = getTargetOfAliasLikeExpression(expression, dontResolveAlias);
30451             markSymbolOfAliasDeclarationIfTypeOnly(node, undefined, resolved, false);
30452             return resolved;
30453         }
30454         function getTargetOfAliasLikeExpression(expression, dontResolveAlias) {
30455             if (ts.isClassExpression(expression)) {
30456                 return checkExpressionCached(expression).symbol;
30457             }
30458             if (!ts.isEntityName(expression) && !ts.isEntityNameExpression(expression)) {
30459                 return undefined;
30460             }
30461             var aliasLike = resolveEntityName(expression, 111551 | 788968 | 1920, true, dontResolveAlias);
30462             if (aliasLike) {
30463                 return aliasLike;
30464             }
30465             checkExpressionCached(expression);
30466             return getNodeLinks(expression).resolvedSymbol;
30467         }
30468         function getTargetOfPropertyAssignment(node, dontRecursivelyResolve) {
30469             var expression = node.initializer;
30470             return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve);
30471         }
30472         function getTargetOfPropertyAccessExpression(node, dontRecursivelyResolve) {
30473             if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62)) {
30474                 return undefined;
30475             }
30476             return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve);
30477         }
30478         function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) {
30479             if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; }
30480             switch (node.kind) {
30481                 case 253:
30482                     return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve);
30483                 case 255:
30484                     return getTargetOfImportClause(node, dontRecursivelyResolve);
30485                 case 256:
30486                     return getTargetOfNamespaceImport(node, dontRecursivelyResolve);
30487                 case 262:
30488                     return getTargetOfNamespaceExport(node, dontRecursivelyResolve);
30489                 case 258:
30490                     return getTargetOfImportSpecifier(node, dontRecursivelyResolve);
30491                 case 263:
30492                     return getTargetOfExportSpecifier(node, 111551 | 788968 | 1920, dontRecursivelyResolve);
30493                 case 259:
30494                 case 209:
30495                     return getTargetOfExportAssignment(node, dontRecursivelyResolve);
30496                 case 252:
30497                     return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve);
30498                 case 282:
30499                     return resolveEntityName(node.name, 111551 | 788968 | 1920, true, dontRecursivelyResolve);
30500                 case 281:
30501                     return getTargetOfPropertyAssignment(node, dontRecursivelyResolve);
30502                 case 194:
30503                     return getTargetOfPropertyAccessExpression(node, dontRecursivelyResolve);
30504                 default:
30505                     return ts.Debug.fail();
30506             }
30507         }
30508         function isNonLocalAlias(symbol, excludes) {
30509             if (excludes === void 0) { excludes = 111551 | 788968 | 1920; }
30510             if (!symbol)
30511                 return false;
30512             return (symbol.flags & (2097152 | excludes)) === 2097152 || !!(symbol.flags & 2097152 && symbol.flags & 67108864);
30513         }
30514         function resolveSymbol(symbol, dontResolveAlias) {
30515             return !dontResolveAlias && isNonLocalAlias(symbol) ? resolveAlias(symbol) : symbol;
30516         }
30517         function resolveAlias(symbol) {
30518             ts.Debug.assert((symbol.flags & 2097152) !== 0, "Should only get Alias here.");
30519             var links = getSymbolLinks(symbol);
30520             if (!links.target) {
30521                 links.target = resolvingSymbol;
30522                 var node = getDeclarationOfAliasSymbol(symbol);
30523                 if (!node)
30524                     return ts.Debug.fail();
30525                 var target = getTargetOfAliasDeclaration(node);
30526                 if (links.target === resolvingSymbol) {
30527                     links.target = target || unknownSymbol;
30528                 }
30529                 else {
30530                     error(node, ts.Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol));
30531                 }
30532             }
30533             else if (links.target === resolvingSymbol) {
30534                 links.target = unknownSymbol;
30535             }
30536             return links.target;
30537         }
30538         function tryResolveAlias(symbol) {
30539             var links = getSymbolLinks(symbol);
30540             if (links.target !== resolvingSymbol) {
30541                 return resolveAlias(symbol);
30542             }
30543             return undefined;
30544         }
30545         function markSymbolOfAliasDeclarationIfTypeOnly(aliasDeclaration, immediateTarget, finalTarget, overwriteEmpty) {
30546             if (!aliasDeclaration)
30547                 return false;
30548             var sourceSymbol = getSymbolOfNode(aliasDeclaration);
30549             if (ts.isTypeOnlyImportOrExportDeclaration(aliasDeclaration)) {
30550                 var links_1 = getSymbolLinks(sourceSymbol);
30551                 links_1.typeOnlyDeclaration = aliasDeclaration;
30552                 return true;
30553             }
30554             var links = getSymbolLinks(sourceSymbol);
30555             return markSymbolOfAliasDeclarationIfTypeOnlyWorker(links, immediateTarget, overwriteEmpty)
30556                 || markSymbolOfAliasDeclarationIfTypeOnlyWorker(links, finalTarget, overwriteEmpty);
30557         }
30558         function markSymbolOfAliasDeclarationIfTypeOnlyWorker(aliasDeclarationLinks, target, overwriteEmpty) {
30559             var _a, _b, _c;
30560             if (target && (aliasDeclarationLinks.typeOnlyDeclaration === undefined || overwriteEmpty && aliasDeclarationLinks.typeOnlyDeclaration === false)) {
30561                 var exportSymbol = (_b = (_a = target.exports) === null || _a === void 0 ? void 0 : _a.get("export=")) !== null && _b !== void 0 ? _b : target;
30562                 var typeOnly = exportSymbol.declarations && ts.find(exportSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration);
30563                 aliasDeclarationLinks.typeOnlyDeclaration = (_c = typeOnly !== null && typeOnly !== void 0 ? typeOnly : getSymbolLinks(exportSymbol).typeOnlyDeclaration) !== null && _c !== void 0 ? _c : false;
30564             }
30565             return !!aliasDeclarationLinks.typeOnlyDeclaration;
30566         }
30567         function getTypeOnlyAliasDeclaration(symbol) {
30568             if (!(symbol.flags & 2097152)) {
30569                 return undefined;
30570             }
30571             var links = getSymbolLinks(symbol);
30572             return links.typeOnlyDeclaration || undefined;
30573         }
30574         function markExportAsReferenced(node) {
30575             var symbol = getSymbolOfNode(node);
30576             var target = resolveAlias(symbol);
30577             if (target) {
30578                 var markAlias = target === unknownSymbol ||
30579                     ((target.flags & 111551) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol));
30580                 if (markAlias) {
30581                     markAliasSymbolAsReferenced(symbol);
30582                 }
30583             }
30584         }
30585         function markAliasSymbolAsReferenced(symbol) {
30586             var links = getSymbolLinks(symbol);
30587             if (!links.referenced) {
30588                 links.referenced = true;
30589                 var node = getDeclarationOfAliasSymbol(symbol);
30590                 if (!node)
30591                     return ts.Debug.fail();
30592                 if (ts.isInternalModuleImportEqualsDeclaration(node)) {
30593                     var target = resolveSymbol(symbol);
30594                     if (target === unknownSymbol || target.flags & 111551) {
30595                         checkExpressionCached(node.moduleReference);
30596                     }
30597                 }
30598             }
30599         }
30600         function markConstEnumAliasAsReferenced(symbol) {
30601             var links = getSymbolLinks(symbol);
30602             if (!links.constEnumReferenced) {
30603                 links.constEnumReferenced = true;
30604             }
30605         }
30606         function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, dontResolveAlias) {
30607             if (entityName.kind === 75 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) {
30608                 entityName = entityName.parent;
30609             }
30610             if (entityName.kind === 75 || entityName.parent.kind === 153) {
30611                 return resolveEntityName(entityName, 1920, false, dontResolveAlias);
30612             }
30613             else {
30614                 ts.Debug.assert(entityName.parent.kind === 253);
30615                 return resolveEntityName(entityName, 111551 | 788968 | 1920, false, dontResolveAlias);
30616             }
30617         }
30618         function getFullyQualifiedName(symbol, containingLocation) {
30619             return symbol.parent ? getFullyQualifiedName(symbol.parent, containingLocation) + "." + symbolToString(symbol) : symbolToString(symbol, containingLocation, undefined, 16 | 4);
30620         }
30621         function resolveEntityName(name, meaning, ignoreErrors, dontResolveAlias, location) {
30622             if (ts.nodeIsMissing(name)) {
30623                 return undefined;
30624             }
30625             var namespaceMeaning = 1920 | (ts.isInJSFile(name) ? meaning & 111551 : 0);
30626             var symbol;
30627             if (name.kind === 75) {
30628                 var message = meaning === namespaceMeaning || ts.nodeIsSynthesized(name) ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(ts.getFirstIdentifier(name));
30629                 var symbolFromJSPrototype = ts.isInJSFile(name) && !ts.nodeIsSynthesized(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined;
30630                 symbol = getMergedSymbol(resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, true));
30631                 if (!symbol) {
30632                     return getMergedSymbol(symbolFromJSPrototype);
30633                 }
30634             }
30635             else if (name.kind === 153 || name.kind === 194) {
30636                 var left = name.kind === 153 ? name.left : name.expression;
30637                 var right = name.kind === 153 ? name.right : name.name;
30638                 var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, false, location);
30639                 if (!namespace || ts.nodeIsMissing(right)) {
30640                     return undefined;
30641                 }
30642                 else if (namespace === unknownSymbol) {
30643                     return namespace;
30644                 }
30645                 if (ts.isInJSFile(name)) {
30646                     if (namespace.valueDeclaration &&
30647                         ts.isVariableDeclaration(namespace.valueDeclaration) &&
30648                         namespace.valueDeclaration.initializer &&
30649                         isCommonJsRequire(namespace.valueDeclaration.initializer)) {
30650                         var moduleName = namespace.valueDeclaration.initializer.arguments[0];
30651                         var moduleSym = resolveExternalModuleName(moduleName, moduleName);
30652                         if (moduleSym) {
30653                             var resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym);
30654                             if (resolvedModuleSymbol) {
30655                                 namespace = resolvedModuleSymbol;
30656                             }
30657                         }
30658                     }
30659                 }
30660                 symbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, meaning));
30661                 if (!symbol) {
30662                     if (!ignoreErrors) {
30663                         error(right, ts.Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(namespace), ts.declarationNameToString(right));
30664                     }
30665                     return undefined;
30666                 }
30667             }
30668             else {
30669                 throw ts.Debug.assertNever(name, "Unknown entity name kind.");
30670             }
30671             ts.Debug.assert((ts.getCheckFlags(symbol) & 1) === 0, "Should never get an instantiated symbol here.");
30672             if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 || name.parent.kind === 259)) {
30673                 markSymbolOfAliasDeclarationIfTypeOnly(ts.getAliasDeclarationFromName(name), symbol, undefined, true);
30674             }
30675             return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol);
30676         }
30677         function resolveEntityNameFromAssignmentDeclaration(name, meaning) {
30678             if (isJSDocTypeReference(name.parent)) {
30679                 var secondaryLocation = getAssignmentDeclarationLocation(name.parent);
30680                 if (secondaryLocation) {
30681                     return resolveName(secondaryLocation, name.escapedText, meaning, undefined, name, true);
30682                 }
30683             }
30684         }
30685         function getAssignmentDeclarationLocation(node) {
30686             var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 4194304) ? "quit" : ts.isJSDocTypeAlias(node); });
30687             if (typeAlias) {
30688                 return;
30689             }
30690             var host = ts.getJSDocHost(node);
30691             if (ts.isExpressionStatement(host) &&
30692                 ts.isBinaryExpression(host.expression) &&
30693                 ts.getAssignmentDeclarationKind(host.expression) === 3) {
30694                 var symbol = getSymbolOfNode(host.expression.left);
30695                 if (symbol) {
30696                     return getDeclarationOfJSPrototypeContainer(symbol);
30697                 }
30698             }
30699             if ((ts.isObjectLiteralMethod(host) || ts.isPropertyAssignment(host)) &&
30700                 ts.isBinaryExpression(host.parent.parent) &&
30701                 ts.getAssignmentDeclarationKind(host.parent.parent) === 6) {
30702                 var symbol = getSymbolOfNode(host.parent.parent.left);
30703                 if (symbol) {
30704                     return getDeclarationOfJSPrototypeContainer(symbol);
30705                 }
30706             }
30707             var sig = ts.getEffectiveJSDocHost(node);
30708             if (sig && ts.isFunctionLike(sig)) {
30709                 var symbol = getSymbolOfNode(sig);
30710                 return symbol && symbol.valueDeclaration;
30711             }
30712         }
30713         function getDeclarationOfJSPrototypeContainer(symbol) {
30714             var decl = symbol.parent.valueDeclaration;
30715             if (!decl) {
30716                 return undefined;
30717             }
30718             var initializer = ts.isAssignmentDeclaration(decl) ? ts.getAssignedExpandoInitializer(decl) :
30719                 ts.hasOnlyExpressionInitializer(decl) ? ts.getDeclaredExpandoInitializer(decl) :
30720                     undefined;
30721             return initializer || decl;
30722         }
30723         function getExpandoSymbol(symbol) {
30724             var decl = symbol.valueDeclaration;
30725             if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 || ts.getExpandoInitializer(decl, false)) {
30726                 return undefined;
30727             }
30728             var init = ts.isVariableDeclaration(decl) ? ts.getDeclaredExpandoInitializer(decl) : ts.getAssignedExpandoInitializer(decl);
30729             if (init) {
30730                 var initSymbol = getSymbolOfNode(init);
30731                 if (initSymbol) {
30732                     return mergeJSSymbols(initSymbol, symbol);
30733                 }
30734             }
30735         }
30736         function resolveExternalModuleName(location, moduleReferenceExpression, ignoreErrors) {
30737             return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? undefined : ts.Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations);
30738         }
30739         function resolveExternalModuleNameWorker(location, moduleReferenceExpression, moduleNotFoundError, isForAugmentation) {
30740             if (isForAugmentation === void 0) { isForAugmentation = false; }
30741             return ts.isStringLiteralLike(moduleReferenceExpression)
30742                 ? resolveExternalModule(location, moduleReferenceExpression.text, moduleNotFoundError, moduleReferenceExpression, isForAugmentation)
30743                 : undefined;
30744         }
30745         function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) {
30746             if (isForAugmentation === void 0) { isForAugmentation = false; }
30747             if (ts.startsWith(moduleReference, "@types/")) {
30748                 var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1;
30749                 var withoutAtTypePrefix = ts.removePrefix(moduleReference, "@types/");
30750                 error(errorNode, diag, withoutAtTypePrefix, moduleReference);
30751             }
30752             var ambientModule = tryFindAmbientModule(moduleReference, true);
30753             if (ambientModule) {
30754                 return ambientModule;
30755             }
30756             var currentSourceFile = ts.getSourceFileOfNode(location);
30757             var resolvedModule = ts.getResolvedModule(currentSourceFile, moduleReference);
30758             var resolutionDiagnostic = resolvedModule && ts.getResolutionDiagnostic(compilerOptions, resolvedModule);
30759             var sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName);
30760             if (sourceFile) {
30761                 if (sourceFile.symbol) {
30762                     if (resolvedModule.isExternalLibraryImport && !ts.resolutionExtensionIsTSOrJson(resolvedModule.extension)) {
30763                         errorOnImplicitAnyModule(false, errorNode, resolvedModule, moduleReference);
30764                     }
30765                     return getMergedSymbol(sourceFile.symbol);
30766                 }
30767                 if (moduleNotFoundError) {
30768                     error(errorNode, ts.Diagnostics.File_0_is_not_a_module, sourceFile.fileName);
30769                 }
30770                 return undefined;
30771             }
30772             if (patternAmbientModules) {
30773                 var pattern = ts.findBestPatternMatch(patternAmbientModules, function (_) { return _.pattern; }, moduleReference);
30774                 if (pattern) {
30775                     var augmentation = patternAmbientModuleAugmentations && patternAmbientModuleAugmentations.get(moduleReference);
30776                     if (augmentation) {
30777                         return getMergedSymbol(augmentation);
30778                     }
30779                     return getMergedSymbol(pattern.symbol);
30780                 }
30781             }
30782             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) {
30783                 if (isForAugmentation) {
30784                     var diag = ts.Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented;
30785                     error(errorNode, diag, moduleReference, resolvedModule.resolvedFileName);
30786                 }
30787                 else {
30788                     errorOnImplicitAnyModule(noImplicitAny && !!moduleNotFoundError, errorNode, resolvedModule, moduleReference);
30789                 }
30790                 return undefined;
30791             }
30792             if (moduleNotFoundError) {
30793                 if (resolvedModule) {
30794                     var redirect = host.getProjectReferenceRedirect(resolvedModule.resolvedFileName);
30795                     if (redirect) {
30796                         error(errorNode, ts.Diagnostics.Output_file_0_has_not_been_built_from_source_file_1, redirect, resolvedModule.resolvedFileName);
30797                         return undefined;
30798                     }
30799                 }
30800                 if (resolutionDiagnostic) {
30801                     error(errorNode, resolutionDiagnostic, moduleReference, resolvedModule.resolvedFileName);
30802                 }
30803                 else {
30804                     var tsExtension = ts.tryExtractTSExtension(moduleReference);
30805                     if (tsExtension) {
30806                         var diag = ts.Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead;
30807                         error(errorNode, diag, tsExtension, ts.removeExtension(moduleReference, tsExtension));
30808                     }
30809                     else if (!compilerOptions.resolveJsonModule &&
30810                         ts.fileExtensionIs(moduleReference, ".json") &&
30811                         ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs &&
30812                         ts.hasJsonModuleEmitEnabled(compilerOptions)) {
30813                         error(errorNode, ts.Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference);
30814                     }
30815                     else {
30816                         error(errorNode, moduleNotFoundError, moduleReference);
30817                     }
30818                 }
30819             }
30820             return undefined;
30821         }
30822         function errorOnImplicitAnyModule(isError, errorNode, _a, moduleReference) {
30823             var packageId = _a.packageId, resolvedFileName = _a.resolvedFileName;
30824             var errorInfo = !ts.isExternalModuleNameRelative(moduleReference) && packageId
30825                 ? typesPackageExists(packageId.name)
30826                     ? 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))
30827                     : 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))
30828                 : undefined;
30829             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));
30830         }
30831         function typesPackageExists(packageName) {
30832             return getPackagesSet().has(ts.getTypesPackageName(packageName));
30833         }
30834         function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) {
30835             if (moduleSymbol === null || moduleSymbol === void 0 ? void 0 : moduleSymbol.exports) {
30836                 var exportEquals = resolveSymbol(moduleSymbol.exports.get("export="), dontResolveAlias);
30837                 var exported = getCommonJsExportEquals(getMergedSymbol(exportEquals), getMergedSymbol(moduleSymbol));
30838                 return getMergedSymbol(exported) || moduleSymbol;
30839             }
30840             return undefined;
30841         }
30842         function getCommonJsExportEquals(exported, moduleSymbol) {
30843             if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152) {
30844                 return exported;
30845             }
30846             var links = getSymbolLinks(exported);
30847             if (links.cjsExportMerged) {
30848                 return links.cjsExportMerged;
30849             }
30850             var merged = exported.flags & 33554432 ? exported : cloneSymbol(exported);
30851             merged.flags = merged.flags | 512;
30852             if (merged.exports === undefined) {
30853                 merged.exports = ts.createSymbolTable();
30854             }
30855             moduleSymbol.exports.forEach(function (s, name) {
30856                 if (name === "export=")
30857                     return;
30858                 merged.exports.set(name, merged.exports.has(name) ? mergeSymbol(merged.exports.get(name), s) : s);
30859             });
30860             getSymbolLinks(merged).cjsExportMerged = merged;
30861             return links.cjsExportMerged = merged;
30862         }
30863         function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias, suppressInteropError) {
30864             var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias);
30865             if (!dontResolveAlias && symbol) {
30866                 if (!suppressInteropError && !(symbol.flags & (1536 | 3)) && !ts.getDeclarationOfKind(symbol, 290)) {
30867                     var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015
30868                         ? "allowSyntheticDefaultImports"
30869                         : "esModuleInterop";
30870                     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);
30871                     return symbol;
30872                 }
30873                 if (compilerOptions.esModuleInterop) {
30874                     var referenceParent = referencingLocation.parent;
30875                     if ((ts.isImportDeclaration(referenceParent) && ts.getNamespaceDeclarationNode(referenceParent)) ||
30876                         ts.isImportCall(referenceParent)) {
30877                         var type = getTypeOfSymbol(symbol);
30878                         var sigs = getSignaturesOfStructuredType(type, 0);
30879                         if (!sigs || !sigs.length) {
30880                             sigs = getSignaturesOfStructuredType(type, 1);
30881                         }
30882                         if (sigs && sigs.length) {
30883                             var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol);
30884                             var result = createSymbol(symbol.flags, symbol.escapedName);
30885                             result.declarations = symbol.declarations ? symbol.declarations.slice() : [];
30886                             result.parent = symbol.parent;
30887                             result.target = symbol;
30888                             result.originatingImport = referenceParent;
30889                             if (symbol.valueDeclaration)
30890                                 result.valueDeclaration = symbol.valueDeclaration;
30891                             if (symbol.constEnumOnlyModule)
30892                                 result.constEnumOnlyModule = true;
30893                             if (symbol.members)
30894                                 result.members = ts.cloneMap(symbol.members);
30895                             if (symbol.exports)
30896                                 result.exports = ts.cloneMap(symbol.exports);
30897                             var resolvedModuleType = resolveStructuredTypeMembers(moduleType);
30898                             result.type = createAnonymousType(result, resolvedModuleType.members, ts.emptyArray, ts.emptyArray, resolvedModuleType.stringIndexInfo, resolvedModuleType.numberIndexInfo);
30899                             return result;
30900                         }
30901                     }
30902                 }
30903             }
30904             return symbol;
30905         }
30906         function hasExportAssignmentSymbol(moduleSymbol) {
30907             return moduleSymbol.exports.get("export=") !== undefined;
30908         }
30909         function getExportsOfModuleAsArray(moduleSymbol) {
30910             return symbolsToArray(getExportsOfModule(moduleSymbol));
30911         }
30912         function getExportsAndPropertiesOfModule(moduleSymbol) {
30913             var exports = getExportsOfModuleAsArray(moduleSymbol);
30914             var exportEquals = resolveExternalModuleSymbol(moduleSymbol);
30915             if (exportEquals !== moduleSymbol) {
30916                 ts.addRange(exports, getPropertiesOfType(getTypeOfSymbol(exportEquals)));
30917             }
30918             return exports;
30919         }
30920         function tryGetMemberInModuleExports(memberName, moduleSymbol) {
30921             var symbolTable = getExportsOfModule(moduleSymbol);
30922             if (symbolTable) {
30923                 return symbolTable.get(memberName);
30924             }
30925         }
30926         function tryGetMemberInModuleExportsAndProperties(memberName, moduleSymbol) {
30927             var symbol = tryGetMemberInModuleExports(memberName, moduleSymbol);
30928             if (symbol) {
30929                 return symbol;
30930             }
30931             var exportEquals = resolveExternalModuleSymbol(moduleSymbol);
30932             if (exportEquals === moduleSymbol) {
30933                 return undefined;
30934             }
30935             var type = getTypeOfSymbol(exportEquals);
30936             return type.flags & 131068 ||
30937                 ts.getObjectFlags(type) & 1 ||
30938                 isArrayOrTupleLikeType(type)
30939                 ? undefined
30940                 : getPropertyOfType(type, memberName);
30941         }
30942         function getExportsOfSymbol(symbol) {
30943             return symbol.flags & 6256 ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports") :
30944                 symbol.flags & 1536 ? getExportsOfModule(symbol) :
30945                     symbol.exports || emptySymbols;
30946         }
30947         function getExportsOfModule(moduleSymbol) {
30948             var links = getSymbolLinks(moduleSymbol);
30949             return links.resolvedExports || (links.resolvedExports = getExportsOfModuleWorker(moduleSymbol));
30950         }
30951         function extendExportSymbols(target, source, lookupTable, exportNode) {
30952             if (!source)
30953                 return;
30954             source.forEach(function (sourceSymbol, id) {
30955                 if (id === "default")
30956                     return;
30957                 var targetSymbol = target.get(id);
30958                 if (!targetSymbol) {
30959                     target.set(id, sourceSymbol);
30960                     if (lookupTable && exportNode) {
30961                         lookupTable.set(id, {
30962                             specifierText: ts.getTextOfNode(exportNode.moduleSpecifier)
30963                         });
30964                     }
30965                 }
30966                 else if (lookupTable && exportNode && targetSymbol && resolveSymbol(targetSymbol) !== resolveSymbol(sourceSymbol)) {
30967                     var collisionTracker = lookupTable.get(id);
30968                     if (!collisionTracker.exportsWithDuplicate) {
30969                         collisionTracker.exportsWithDuplicate = [exportNode];
30970                     }
30971                     else {
30972                         collisionTracker.exportsWithDuplicate.push(exportNode);
30973                     }
30974                 }
30975             });
30976         }
30977         function getExportsOfModuleWorker(moduleSymbol) {
30978             var visitedSymbols = [];
30979             moduleSymbol = resolveExternalModuleSymbol(moduleSymbol);
30980             return visit(moduleSymbol) || emptySymbols;
30981             function visit(symbol) {
30982                 if (!(symbol && symbol.exports && ts.pushIfUnique(visitedSymbols, symbol))) {
30983                     return;
30984                 }
30985                 var symbols = ts.cloneMap(symbol.exports);
30986                 var exportStars = symbol.exports.get("__export");
30987                 if (exportStars) {
30988                     var nestedSymbols = ts.createSymbolTable();
30989                     var lookupTable_1 = ts.createMap();
30990                     for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) {
30991                         var node = _a[_i];
30992                         var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier);
30993                         var exportedSymbols = visit(resolvedModule);
30994                         extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable_1, node);
30995                     }
30996                     lookupTable_1.forEach(function (_a, id) {
30997                         var exportsWithDuplicate = _a.exportsWithDuplicate;
30998                         if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || symbols.has(id)) {
30999                             return;
31000                         }
31001                         for (var _i = 0, exportsWithDuplicate_1 = exportsWithDuplicate; _i < exportsWithDuplicate_1.length; _i++) {
31002                             var node = exportsWithDuplicate_1[_i];
31003                             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)));
31004                         }
31005                     });
31006                     extendExportSymbols(symbols, nestedSymbols);
31007                 }
31008                 return symbols;
31009             }
31010         }
31011         function getMergedSymbol(symbol) {
31012             var merged;
31013             return symbol && symbol.mergeId && (merged = mergedSymbols[symbol.mergeId]) ? merged : symbol;
31014         }
31015         function getSymbolOfNode(node) {
31016             return getMergedSymbol(node.symbol && getLateBoundSymbol(node.symbol));
31017         }
31018         function getParentOfSymbol(symbol) {
31019             return getMergedSymbol(symbol.parent && getLateBoundSymbol(symbol.parent));
31020         }
31021         function getAlternativeContainingModules(symbol, enclosingDeclaration) {
31022             var containingFile = ts.getSourceFileOfNode(enclosingDeclaration);
31023             var id = "" + getNodeId(containingFile);
31024             var links = getSymbolLinks(symbol);
31025             var results;
31026             if (links.extendedContainersByFile && (results = links.extendedContainersByFile.get(id))) {
31027                 return results;
31028             }
31029             if (containingFile && containingFile.imports) {
31030                 for (var _i = 0, _a = containingFile.imports; _i < _a.length; _i++) {
31031                     var importRef = _a[_i];
31032                     if (ts.nodeIsSynthesized(importRef))
31033                         continue;
31034                     var resolvedModule = resolveExternalModuleName(enclosingDeclaration, importRef, true);
31035                     if (!resolvedModule)
31036                         continue;
31037                     var ref = getAliasForSymbolInContainer(resolvedModule, symbol);
31038                     if (!ref)
31039                         continue;
31040                     results = ts.append(results, resolvedModule);
31041                 }
31042                 if (ts.length(results)) {
31043                     (links.extendedContainersByFile || (links.extendedContainersByFile = ts.createMap())).set(id, results);
31044                     return results;
31045                 }
31046             }
31047             if (links.extendedContainers) {
31048                 return links.extendedContainers;
31049             }
31050             var otherFiles = host.getSourceFiles();
31051             for (var _b = 0, otherFiles_1 = otherFiles; _b < otherFiles_1.length; _b++) {
31052                 var file = otherFiles_1[_b];
31053                 if (!ts.isExternalModule(file))
31054                     continue;
31055                 var sym = getSymbolOfNode(file);
31056                 var ref = getAliasForSymbolInContainer(sym, symbol);
31057                 if (!ref)
31058                     continue;
31059                 results = ts.append(results, sym);
31060             }
31061             return links.extendedContainers = results || ts.emptyArray;
31062         }
31063         function getContainersOfSymbol(symbol, enclosingDeclaration) {
31064             var container = getParentOfSymbol(symbol);
31065             if (container && !(symbol.flags & 262144)) {
31066                 var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer);
31067                 var reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration);
31068                 if (enclosingDeclaration && getAccessibleSymbolChain(container, enclosingDeclaration, 1920, false)) {
31069                     return ts.concatenate(ts.concatenate([container], additionalContainers), reexportContainers);
31070                 }
31071                 var res = ts.append(additionalContainers, container);
31072                 return ts.concatenate(res, reexportContainers);
31073             }
31074             var candidates = ts.mapDefined(symbol.declarations, function (d) {
31075                 if (!ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) {
31076                     return getSymbolOfNode(d.parent);
31077                 }
31078                 if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 62 && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) {
31079                     if (ts.isModuleExportsAccessExpression(d.parent.left) || ts.isExportsIdentifier(d.parent.left.expression)) {
31080                         return getSymbolOfNode(ts.getSourceFileOfNode(d));
31081                     }
31082                     checkExpressionCached(d.parent.left.expression);
31083                     return getNodeLinks(d.parent.left.expression).resolvedSymbol;
31084                 }
31085             });
31086             if (!ts.length(candidates)) {
31087                 return undefined;
31088             }
31089             return ts.mapDefined(candidates, function (candidate) { return getAliasForSymbolInContainer(candidate, symbol) ? candidate : undefined; });
31090             function fileSymbolIfFileSymbolExportEqualsContainer(d) {
31091                 return container && getFileSymbolIfFileSymbolExportEqualsContainer(d, container);
31092             }
31093         }
31094         function getFileSymbolIfFileSymbolExportEqualsContainer(d, container) {
31095             var fileSymbol = getExternalModuleContainer(d);
31096             var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=");
31097             return exported && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined;
31098         }
31099         function getAliasForSymbolInContainer(container, symbol) {
31100             if (container === getParentOfSymbol(symbol)) {
31101                 return symbol;
31102             }
31103             var exportEquals = container.exports && container.exports.get("export=");
31104             if (exportEquals && getSymbolIfSameReference(exportEquals, symbol)) {
31105                 return container;
31106             }
31107             var exports = getExportsOfSymbol(container);
31108             var quick = exports.get(symbol.escapedName);
31109             if (quick && getSymbolIfSameReference(quick, symbol)) {
31110                 return quick;
31111             }
31112             return ts.forEachEntry(exports, function (exported) {
31113                 if (getSymbolIfSameReference(exported, symbol)) {
31114                     return exported;
31115                 }
31116             });
31117         }
31118         function getSymbolIfSameReference(s1, s2) {
31119             if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) {
31120                 return s1;
31121             }
31122         }
31123         function getExportSymbolOfValueSymbolIfExported(symbol) {
31124             return getMergedSymbol(symbol && (symbol.flags & 1048576) !== 0 ? symbol.exportSymbol : symbol);
31125         }
31126         function symbolIsValue(symbol) {
31127             return !!(symbol.flags & 111551 || symbol.flags & 2097152 && resolveAlias(symbol).flags & 111551 && !getTypeOnlyAliasDeclaration(symbol));
31128         }
31129         function findConstructorDeclaration(node) {
31130             var members = node.members;
31131             for (var _i = 0, members_3 = members; _i < members_3.length; _i++) {
31132                 var member = members_3[_i];
31133                 if (member.kind === 162 && ts.nodeIsPresent(member.body)) {
31134                     return member;
31135                 }
31136             }
31137         }
31138         function createType(flags) {
31139             var result = new Type(checker, flags);
31140             typeCount++;
31141             result.id = typeCount;
31142             return result;
31143         }
31144         function createIntrinsicType(kind, intrinsicName, objectFlags) {
31145             if (objectFlags === void 0) { objectFlags = 0; }
31146             var type = createType(kind);
31147             type.intrinsicName = intrinsicName;
31148             type.objectFlags = objectFlags;
31149             return type;
31150         }
31151         function createBooleanType(trueFalseTypes) {
31152             var type = getUnionType(trueFalseTypes);
31153             type.flags |= 16;
31154             type.intrinsicName = "boolean";
31155             return type;
31156         }
31157         function createObjectType(objectFlags, symbol) {
31158             var type = createType(524288);
31159             type.objectFlags = objectFlags;
31160             type.symbol = symbol;
31161             type.members = undefined;
31162             type.properties = undefined;
31163             type.callSignatures = undefined;
31164             type.constructSignatures = undefined;
31165             type.stringIndexInfo = undefined;
31166             type.numberIndexInfo = undefined;
31167             return type;
31168         }
31169         function createTypeofType() {
31170             return getUnionType(ts.arrayFrom(typeofEQFacts.keys(), getLiteralType));
31171         }
31172         function createTypeParameter(symbol) {
31173             var type = createType(262144);
31174             if (symbol)
31175                 type.symbol = symbol;
31176             return type;
31177         }
31178         function isReservedMemberName(name) {
31179             return name.charCodeAt(0) === 95 &&
31180                 name.charCodeAt(1) === 95 &&
31181                 name.charCodeAt(2) !== 95 &&
31182                 name.charCodeAt(2) !== 64 &&
31183                 name.charCodeAt(2) !== 35;
31184         }
31185         function getNamedMembers(members) {
31186             var result;
31187             members.forEach(function (symbol, id) {
31188                 if (!isReservedMemberName(id) && symbolIsValue(symbol)) {
31189                     (result || (result = [])).push(symbol);
31190                 }
31191             });
31192             return result || ts.emptyArray;
31193         }
31194         function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) {
31195             type.members = members;
31196             type.properties = members === emptySymbols ? ts.emptyArray : getNamedMembers(members);
31197             type.callSignatures = callSignatures;
31198             type.constructSignatures = constructSignatures;
31199             type.stringIndexInfo = stringIndexInfo;
31200             type.numberIndexInfo = numberIndexInfo;
31201             return type;
31202         }
31203         function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) {
31204             return setStructuredTypeMembers(createObjectType(16, symbol), members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
31205         }
31206         function forEachSymbolTableInScope(enclosingDeclaration, callback) {
31207             var result;
31208             var _loop_7 = function (location) {
31209                 if (location.locals && !isGlobalSourceFile(location)) {
31210                     if (result = callback(location.locals)) {
31211                         return { value: result };
31212                     }
31213                 }
31214                 switch (location.kind) {
31215                     case 290:
31216                         if (!ts.isExternalOrCommonJsModule(location)) {
31217                             break;
31218                         }
31219                     case 249:
31220                         var sym = getSymbolOfNode(location);
31221                         if (result = callback((sym === null || sym === void 0 ? void 0 : sym.exports) || emptySymbols)) {
31222                             return { value: result };
31223                         }
31224                         break;
31225                     case 245:
31226                     case 214:
31227                     case 246:
31228                         var table_1;
31229                         (getSymbolOfNode(location).members || emptySymbols).forEach(function (memberSymbol, key) {
31230                             if (memberSymbol.flags & (788968 & ~67108864)) {
31231                                 (table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol);
31232                             }
31233                         });
31234                         if (table_1 && (result = callback(table_1))) {
31235                             return { value: result };
31236                         }
31237                         break;
31238                 }
31239             };
31240             for (var location = enclosingDeclaration; location; location = location.parent) {
31241                 var state_2 = _loop_7(location);
31242                 if (typeof state_2 === "object")
31243                     return state_2.value;
31244             }
31245             return callback(globals);
31246         }
31247         function getQualifiedLeftMeaning(rightMeaning) {
31248             return rightMeaning === 111551 ? 111551 : 1920;
31249         }
31250         function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing, visitedSymbolTablesMap) {
31251             if (visitedSymbolTablesMap === void 0) { visitedSymbolTablesMap = ts.createMap(); }
31252             if (!(symbol && !isPropertyOrMethodDeclarationSymbol(symbol))) {
31253                 return undefined;
31254             }
31255             var id = "" + getSymbolId(symbol);
31256             var visitedSymbolTables = visitedSymbolTablesMap.get(id);
31257             if (!visitedSymbolTables) {
31258                 visitedSymbolTablesMap.set(id, visitedSymbolTables = []);
31259             }
31260             return forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable);
31261             function getAccessibleSymbolChainFromSymbolTable(symbols, ignoreQualification) {
31262                 if (!ts.pushIfUnique(visitedSymbolTables, symbols)) {
31263                     return undefined;
31264                 }
31265                 var result = trySymbolTable(symbols, ignoreQualification);
31266                 visitedSymbolTables.pop();
31267                 return result;
31268             }
31269             function canQualifySymbol(symbolFromSymbolTable, meaning) {
31270                 return !needsQualification(symbolFromSymbolTable, enclosingDeclaration, meaning) ||
31271                     !!getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing, visitedSymbolTablesMap);
31272             }
31273             function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol, ignoreQualification) {
31274                 return (symbol === (resolvedAliasSymbol || symbolFromSymbolTable) || getMergedSymbol(symbol) === getMergedSymbol(resolvedAliasSymbol || symbolFromSymbolTable)) &&
31275                     !ts.some(symbolFromSymbolTable.declarations, hasNonGlobalAugmentationExternalModuleSymbol) &&
31276                     (ignoreQualification || canQualifySymbol(getMergedSymbol(symbolFromSymbolTable), meaning));
31277             }
31278             function trySymbolTable(symbols, ignoreQualification) {
31279                 if (isAccessible(symbols.get(symbol.escapedName), undefined, ignoreQualification)) {
31280                     return [symbol];
31281                 }
31282                 var result = ts.forEachEntry(symbols, function (symbolFromSymbolTable) {
31283                     if (symbolFromSymbolTable.flags & 2097152
31284                         && symbolFromSymbolTable.escapedName !== "export="
31285                         && symbolFromSymbolTable.escapedName !== "default"
31286                         && !(ts.isUMDExportSymbol(symbolFromSymbolTable) && enclosingDeclaration && ts.isExternalModule(ts.getSourceFileOfNode(enclosingDeclaration)))
31287                         && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration))
31288                         && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 263))) {
31289                         var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable);
31290                         var candidate = getCandidateListForSymbol(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification);
31291                         if (candidate) {
31292                             return candidate;
31293                         }
31294                     }
31295                     if (symbolFromSymbolTable.escapedName === symbol.escapedName && symbolFromSymbolTable.exportSymbol) {
31296                         if (isAccessible(getMergedSymbol(symbolFromSymbolTable.exportSymbol), undefined, ignoreQualification)) {
31297                             return [symbol];
31298                         }
31299                     }
31300                 });
31301                 return result || (symbols === globals ? getCandidateListForSymbol(globalThisSymbol, globalThisSymbol, ignoreQualification) : undefined);
31302             }
31303             function getCandidateListForSymbol(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification) {
31304                 if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification)) {
31305                     return [symbolFromSymbolTable];
31306                 }
31307                 var candidateTable = getExportsOfSymbol(resolvedImportedSymbol);
31308                 var accessibleSymbolsFromExports = candidateTable && getAccessibleSymbolChainFromSymbolTable(candidateTable, true);
31309                 if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) {
31310                     return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports);
31311                 }
31312             }
31313         }
31314         function needsQualification(symbol, enclosingDeclaration, meaning) {
31315             var qualify = false;
31316             forEachSymbolTableInScope(enclosingDeclaration, function (symbolTable) {
31317                 var symbolFromSymbolTable = getMergedSymbol(symbolTable.get(symbol.escapedName));
31318                 if (!symbolFromSymbolTable) {
31319                     return false;
31320                 }
31321                 if (symbolFromSymbolTable === symbol) {
31322                     return true;
31323                 }
31324                 symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 263)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable;
31325                 if (symbolFromSymbolTable.flags & meaning) {
31326                     qualify = true;
31327                     return true;
31328                 }
31329                 return false;
31330             });
31331             return qualify;
31332         }
31333         function isPropertyOrMethodDeclarationSymbol(symbol) {
31334             if (symbol.declarations && symbol.declarations.length) {
31335                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
31336                     var declaration = _a[_i];
31337                     switch (declaration.kind) {
31338                         case 159:
31339                         case 161:
31340                         case 163:
31341                         case 164:
31342                             continue;
31343                         default:
31344                             return false;
31345                     }
31346                 }
31347                 return true;
31348             }
31349             return false;
31350         }
31351         function isTypeSymbolAccessible(typeSymbol, enclosingDeclaration) {
31352             var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 788968, false);
31353             return access.accessibility === 0;
31354         }
31355         function isValueSymbolAccessible(typeSymbol, enclosingDeclaration) {
31356             var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 111551, false);
31357             return access.accessibility === 0;
31358         }
31359         function isAnySymbolAccessible(symbols, enclosingDeclaration, initialSymbol, meaning, shouldComputeAliasesToMakeVisible) {
31360             if (!ts.length(symbols))
31361                 return;
31362             var hadAccessibleChain;
31363             var earlyModuleBail = false;
31364             for (var _i = 0, _a = symbols; _i < _a.length; _i++) {
31365                 var symbol = _a[_i];
31366                 var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, false);
31367                 if (accessibleSymbolChain) {
31368                     hadAccessibleChain = symbol;
31369                     var hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0], shouldComputeAliasesToMakeVisible);
31370                     if (hasAccessibleDeclarations) {
31371                         return hasAccessibleDeclarations;
31372                     }
31373                 }
31374                 else {
31375                     if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
31376                         if (shouldComputeAliasesToMakeVisible) {
31377                             earlyModuleBail = true;
31378                             continue;
31379                         }
31380                         return {
31381                             accessibility: 0
31382                         };
31383                     }
31384                 }
31385                 var containers = getContainersOfSymbol(symbol, enclosingDeclaration);
31386                 var firstDecl = !!ts.length(symbol.declarations) && ts.first(symbol.declarations);
31387                 if (!ts.length(containers) && meaning & 111551 && firstDecl && ts.isObjectLiteralExpression(firstDecl)) {
31388                     if (firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent) && firstDecl === firstDecl.parent.initializer) {
31389                         containers = [getSymbolOfNode(firstDecl.parent)];
31390                     }
31391                 }
31392                 var parentResult = isAnySymbolAccessible(containers, enclosingDeclaration, initialSymbol, initialSymbol === symbol ? getQualifiedLeftMeaning(meaning) : meaning, shouldComputeAliasesToMakeVisible);
31393                 if (parentResult) {
31394                     return parentResult;
31395                 }
31396             }
31397             if (earlyModuleBail) {
31398                 return {
31399                     accessibility: 0
31400                 };
31401             }
31402             if (hadAccessibleChain) {
31403                 return {
31404                     accessibility: 1,
31405                     errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning),
31406                     errorModuleName: hadAccessibleChain !== initialSymbol ? symbolToString(hadAccessibleChain, enclosingDeclaration, 1920) : undefined,
31407                 };
31408             }
31409         }
31410         function isSymbolAccessible(symbol, enclosingDeclaration, meaning, shouldComputeAliasesToMakeVisible) {
31411             if (symbol && enclosingDeclaration) {
31412                 var result = isAnySymbolAccessible([symbol], enclosingDeclaration, symbol, meaning, shouldComputeAliasesToMakeVisible);
31413                 if (result) {
31414                     return result;
31415                 }
31416                 var symbolExternalModule = ts.forEach(symbol.declarations, getExternalModuleContainer);
31417                 if (symbolExternalModule) {
31418                     var enclosingExternalModule = getExternalModuleContainer(enclosingDeclaration);
31419                     if (symbolExternalModule !== enclosingExternalModule) {
31420                         return {
31421                             accessibility: 2,
31422                             errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning),
31423                             errorModuleName: symbolToString(symbolExternalModule)
31424                         };
31425                     }
31426                 }
31427                 return {
31428                     accessibility: 1,
31429                     errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning),
31430                 };
31431             }
31432             return { accessibility: 0 };
31433         }
31434         function getExternalModuleContainer(declaration) {
31435             var node = ts.findAncestor(declaration, hasExternalModuleSymbol);
31436             return node && getSymbolOfNode(node);
31437         }
31438         function hasExternalModuleSymbol(declaration) {
31439             return ts.isAmbientModule(declaration) || (declaration.kind === 290 && ts.isExternalOrCommonJsModule(declaration));
31440         }
31441         function hasNonGlobalAugmentationExternalModuleSymbol(declaration) {
31442             return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 290 && ts.isExternalOrCommonJsModule(declaration));
31443         }
31444         function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) {
31445             var aliasesToMakeVisible;
31446             if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 75; }), getIsDeclarationVisible)) {
31447                 return undefined;
31448             }
31449             return { accessibility: 0, aliasesToMakeVisible: aliasesToMakeVisible };
31450             function getIsDeclarationVisible(declaration) {
31451                 if (!isDeclarationVisible(declaration)) {
31452                     var anyImportSyntax = getAnyImportSyntax(declaration);
31453                     if (anyImportSyntax &&
31454                         !ts.hasModifier(anyImportSyntax, 1) &&
31455                         isDeclarationVisible(anyImportSyntax.parent)) {
31456                         return addVisibleAlias(declaration, anyImportSyntax);
31457                     }
31458                     else if (ts.isVariableDeclaration(declaration) && ts.isVariableStatement(declaration.parent.parent) &&
31459                         !ts.hasModifier(declaration.parent.parent, 1) &&
31460                         isDeclarationVisible(declaration.parent.parent.parent)) {
31461                         return addVisibleAlias(declaration, declaration.parent.parent);
31462                     }
31463                     else if (ts.isLateVisibilityPaintedStatement(declaration)
31464                         && !ts.hasModifier(declaration, 1)
31465                         && isDeclarationVisible(declaration.parent)) {
31466                         return addVisibleAlias(declaration, declaration);
31467                     }
31468                     return false;
31469                 }
31470                 return true;
31471             }
31472             function addVisibleAlias(declaration, aliasingStatement) {
31473                 if (shouldComputeAliasToMakeVisible) {
31474                     getNodeLinks(declaration).isVisible = true;
31475                     aliasesToMakeVisible = ts.appendIfUnique(aliasesToMakeVisible, aliasingStatement);
31476                 }
31477                 return true;
31478             }
31479         }
31480         function isEntityNameVisible(entityName, enclosingDeclaration) {
31481             var meaning;
31482             if (entityName.parent.kind === 172 ||
31483                 ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) ||
31484                 entityName.parent.kind === 154) {
31485                 meaning = 111551 | 1048576;
31486             }
31487             else if (entityName.kind === 153 || entityName.kind === 194 ||
31488                 entityName.parent.kind === 253) {
31489                 meaning = 1920;
31490             }
31491             else {
31492                 meaning = 788968;
31493             }
31494             var firstIdentifier = ts.getFirstIdentifier(entityName);
31495             var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, undefined, undefined, false);
31496             return (symbol && hasVisibleDeclarations(symbol, true)) || {
31497                 accessibility: 1,
31498                 errorSymbolName: ts.getTextOfNode(firstIdentifier),
31499                 errorNode: firstIdentifier
31500             };
31501         }
31502         function symbolToString(symbol, enclosingDeclaration, meaning, flags, writer) {
31503             if (flags === void 0) { flags = 4; }
31504             var nodeFlags = 70221824;
31505             if (flags & 2) {
31506                 nodeFlags |= 128;
31507             }
31508             if (flags & 1) {
31509                 nodeFlags |= 512;
31510             }
31511             if (flags & 8) {
31512                 nodeFlags |= 16384;
31513             }
31514             if (flags & 16) {
31515                 nodeFlags |= 134217728;
31516             }
31517             var builder = flags & 4 ? nodeBuilder.symbolToExpression : nodeBuilder.symbolToEntityName;
31518             return writer ? symbolToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(symbolToStringWorker);
31519             function symbolToStringWorker(writer) {
31520                 var entity = builder(symbol, meaning, enclosingDeclaration, nodeFlags);
31521                 var printer = ts.createPrinter({ removeComments: true });
31522                 var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration);
31523                 printer.writeNode(4, entity, sourceFile, writer);
31524                 return writer;
31525             }
31526         }
31527         function signatureToString(signature, enclosingDeclaration, flags, kind, writer) {
31528             if (flags === void 0) { flags = 0; }
31529             return writer ? signatureToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(signatureToStringWorker);
31530             function signatureToStringWorker(writer) {
31531                 var sigOutput;
31532                 if (flags & 262144) {
31533                     sigOutput = kind === 1 ? 171 : 170;
31534                 }
31535                 else {
31536                     sigOutput = kind === 1 ? 166 : 165;
31537                 }
31538                 var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 | 512);
31539                 var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true });
31540                 var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration);
31541                 printer.writeNode(4, sig, sourceFile, ts.getTrailingSemicolonDeferringWriter(writer));
31542                 return writer;
31543             }
31544         }
31545         function typeToString(type, enclosingDeclaration, flags, writer) {
31546             if (flags === void 0) { flags = 1048576 | 16384; }
31547             if (writer === void 0) { writer = ts.createTextWriter(""); }
31548             var noTruncation = compilerOptions.noErrorTruncation || flags & 1;
31549             var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 | (noTruncation ? 1 : 0), writer);
31550             if (typeNode === undefined)
31551                 return ts.Debug.fail("should always get typenode");
31552             var options = { removeComments: true };
31553             var printer = ts.createPrinter(options);
31554             var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration);
31555             printer.writeNode(4, typeNode, sourceFile, writer);
31556             var result = writer.getText();
31557             var maxLength = noTruncation ? ts.noTruncationMaximumTruncationLength * 2 : ts.defaultMaximumTruncationLength * 2;
31558             if (maxLength && result && result.length >= maxLength) {
31559                 return result.substr(0, maxLength - "...".length) + "...";
31560             }
31561             return result;
31562         }
31563         function getTypeNamesForErrorDisplay(left, right) {
31564             var leftStr = symbolValueDeclarationIsContextSensitive(left.symbol) ? typeToString(left, left.symbol.valueDeclaration) : typeToString(left);
31565             var rightStr = symbolValueDeclarationIsContextSensitive(right.symbol) ? typeToString(right, right.symbol.valueDeclaration) : typeToString(right);
31566             if (leftStr === rightStr) {
31567                 leftStr = typeToString(left, undefined, 64);
31568                 rightStr = typeToString(right, undefined, 64);
31569             }
31570             return [leftStr, rightStr];
31571         }
31572         function symbolValueDeclarationIsContextSensitive(symbol) {
31573             return symbol && symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration);
31574         }
31575         function toNodeBuilderFlags(flags) {
31576             if (flags === void 0) { flags = 0; }
31577             return flags & 814775659;
31578         }
31579         function createNodeBuilder() {
31580             return {
31581                 typeToTypeNode: function (type, enclosingDeclaration, flags, tracker) {
31582                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeToTypeNodeHelper(type, context); });
31583                 },
31584                 indexInfoToIndexSignatureDeclaration: function (indexInfo, kind, enclosingDeclaration, flags, tracker) {
31585                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context); });
31586                 },
31587                 signatureToSignatureDeclaration: function (signature, kind, enclosingDeclaration, flags, tracker) {
31588                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return signatureToSignatureDeclarationHelper(signature, kind, context); });
31589                 },
31590                 symbolToEntityName: function (symbol, meaning, enclosingDeclaration, flags, tracker) {
31591                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToName(symbol, context, meaning, false); });
31592                 },
31593                 symbolToExpression: function (symbol, meaning, enclosingDeclaration, flags, tracker) {
31594                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToExpression(symbol, context, meaning); });
31595                 },
31596                 symbolToTypeParameterDeclarations: function (symbol, enclosingDeclaration, flags, tracker) {
31597                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParametersToTypeParameterDeclarations(symbol, context); });
31598                 },
31599                 symbolToParameterDeclaration: function (symbol, enclosingDeclaration, flags, tracker) {
31600                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToParameterDeclaration(symbol, context); });
31601                 },
31602                 typeParameterToDeclaration: function (parameter, enclosingDeclaration, flags, tracker) {
31603                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParameterToDeclaration(parameter, context); });
31604                 },
31605                 symbolTableToDeclarationStatements: function (symbolTable, enclosingDeclaration, flags, tracker, bundled) {
31606                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolTableToDeclarationStatements(symbolTable, context, bundled); });
31607                 },
31608             };
31609             function withContext(enclosingDeclaration, flags, tracker, cb) {
31610                 ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8) === 0);
31611                 var context = {
31612                     enclosingDeclaration: enclosingDeclaration,
31613                     flags: flags || 0,
31614                     tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop, moduleResolverHost: flags & 134217728 ? {
31615                             getCommonSourceDirectory: !!host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; },
31616                             getSourceFiles: function () { return host.getSourceFiles(); },
31617                             getCurrentDirectory: function () { return host.getCurrentDirectory(); },
31618                             getProbableSymlinks: ts.maybeBind(host, host.getProbableSymlinks),
31619                             useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames),
31620                             redirectTargetsMap: host.redirectTargetsMap,
31621                             getProjectReferenceRedirect: function (fileName) { return host.getProjectReferenceRedirect(fileName); },
31622                             isSourceOfProjectReferenceRedirect: function (fileName) { return host.isSourceOfProjectReferenceRedirect(fileName); },
31623                             fileExists: function (fileName) { return host.fileExists(fileName); },
31624                         } : undefined },
31625                     encounteredError: false,
31626                     visitedTypes: undefined,
31627                     symbolDepth: undefined,
31628                     inferTypeParameters: undefined,
31629                     approximateLength: 0
31630                 };
31631                 var resultingNode = cb(context);
31632                 return context.encounteredError ? undefined : resultingNode;
31633             }
31634             function checkTruncationLength(context) {
31635                 if (context.truncating)
31636                     return context.truncating;
31637                 return context.truncating = context.approximateLength > ((context.flags & 1) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength);
31638             }
31639             function typeToTypeNodeHelper(type, context) {
31640                 if (cancellationToken && cancellationToken.throwIfCancellationRequested) {
31641                     cancellationToken.throwIfCancellationRequested();
31642                 }
31643                 var inTypeAlias = context.flags & 8388608;
31644                 context.flags &= ~8388608;
31645                 if (!type) {
31646                     if (!(context.flags & 262144)) {
31647                         context.encounteredError = true;
31648                         return undefined;
31649                     }
31650                     context.approximateLength += 3;
31651                     return ts.createKeywordTypeNode(125);
31652                 }
31653                 if (!(context.flags & 536870912)) {
31654                     type = getReducedType(type);
31655                 }
31656                 if (type.flags & 1) {
31657                     context.approximateLength += 3;
31658                     return ts.createKeywordTypeNode(125);
31659                 }
31660                 if (type.flags & 2) {
31661                     return ts.createKeywordTypeNode(148);
31662                 }
31663                 if (type.flags & 4) {
31664                     context.approximateLength += 6;
31665                     return ts.createKeywordTypeNode(143);
31666                 }
31667                 if (type.flags & 8) {
31668                     context.approximateLength += 6;
31669                     return ts.createKeywordTypeNode(140);
31670                 }
31671                 if (type.flags & 64) {
31672                     context.approximateLength += 6;
31673                     return ts.createKeywordTypeNode(151);
31674                 }
31675                 if (type.flags & 16) {
31676                     context.approximateLength += 7;
31677                     return ts.createKeywordTypeNode(128);
31678                 }
31679                 if (type.flags & 1024 && !(type.flags & 1048576)) {
31680                     var parentSymbol = getParentOfSymbol(type.symbol);
31681                     var parentName = symbolToTypeNode(parentSymbol, context, 788968);
31682                     var enumLiteralName = getDeclaredTypeOfSymbol(parentSymbol) === type
31683                         ? parentName
31684                         : appendReferenceToType(parentName, ts.createTypeReferenceNode(ts.symbolName(type.symbol), undefined));
31685                     return enumLiteralName;
31686                 }
31687                 if (type.flags & 1056) {
31688                     return symbolToTypeNode(type.symbol, context, 788968);
31689                 }
31690                 if (type.flags & 128) {
31691                     context.approximateLength += (type.value.length + 2);
31692                     return ts.createLiteralTypeNode(ts.setEmitFlags(ts.createLiteral(type.value, !!(context.flags & 268435456)), 16777216));
31693                 }
31694                 if (type.flags & 256) {
31695                     var value = type.value;
31696                     context.approximateLength += ("" + value).length;
31697                     return ts.createLiteralTypeNode(value < 0 ? ts.createPrefix(40, ts.createLiteral(-value)) : ts.createLiteral(value));
31698                 }
31699                 if (type.flags & 2048) {
31700                     context.approximateLength += (ts.pseudoBigIntToString(type.value).length) + 1;
31701                     return ts.createLiteralTypeNode((ts.createLiteral(type.value)));
31702                 }
31703                 if (type.flags & 512) {
31704                     context.approximateLength += type.intrinsicName.length;
31705                     return type.intrinsicName === "true" ? ts.createTrue() : ts.createFalse();
31706                 }
31707                 if (type.flags & 8192) {
31708                     if (!(context.flags & 1048576)) {
31709                         if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) {
31710                             context.approximateLength += 6;
31711                             return symbolToTypeNode(type.symbol, context, 111551);
31712                         }
31713                         if (context.tracker.reportInaccessibleUniqueSymbolError) {
31714                             context.tracker.reportInaccessibleUniqueSymbolError();
31715                         }
31716                     }
31717                     context.approximateLength += 13;
31718                     return ts.createTypeOperatorNode(147, ts.createKeywordTypeNode(144));
31719                 }
31720                 if (type.flags & 16384) {
31721                     context.approximateLength += 4;
31722                     return ts.createKeywordTypeNode(110);
31723                 }
31724                 if (type.flags & 32768) {
31725                     context.approximateLength += 9;
31726                     return ts.createKeywordTypeNode(146);
31727                 }
31728                 if (type.flags & 65536) {
31729                     context.approximateLength += 4;
31730                     return ts.createKeywordTypeNode(100);
31731                 }
31732                 if (type.flags & 131072) {
31733                     context.approximateLength += 5;
31734                     return ts.createKeywordTypeNode(137);
31735                 }
31736                 if (type.flags & 4096) {
31737                     context.approximateLength += 6;
31738                     return ts.createKeywordTypeNode(144);
31739                 }
31740                 if (type.flags & 67108864) {
31741                     context.approximateLength += 6;
31742                     return ts.createKeywordTypeNode(141);
31743                 }
31744                 if (isThisTypeParameter(type)) {
31745                     if (context.flags & 4194304) {
31746                         if (!context.encounteredError && !(context.flags & 32768)) {
31747                             context.encounteredError = true;
31748                         }
31749                         if (context.tracker.reportInaccessibleThisError) {
31750                             context.tracker.reportInaccessibleThisError();
31751                         }
31752                     }
31753                     context.approximateLength += 4;
31754                     return ts.createThis();
31755                 }
31756                 if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) {
31757                     var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context);
31758                     if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32))
31759                         return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes);
31760                     return symbolToTypeNode(type.aliasSymbol, context, 788968, typeArgumentNodes);
31761                 }
31762                 var objectFlags = ts.getObjectFlags(type);
31763                 if (objectFlags & 4) {
31764                     ts.Debug.assert(!!(type.flags & 524288));
31765                     return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type);
31766                 }
31767                 if (type.flags & 262144 || objectFlags & 3) {
31768                     if (type.flags & 262144 && ts.contains(context.inferTypeParameters, type)) {
31769                         context.approximateLength += (ts.symbolName(type.symbol).length + 6);
31770                         return ts.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, undefined));
31771                     }
31772                     if (context.flags & 4 &&
31773                         type.flags & 262144 &&
31774                         !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) {
31775                         var name = typeParameterToName(type, context);
31776                         context.approximateLength += ts.idText(name).length;
31777                         return ts.createTypeReferenceNode(ts.createIdentifier(ts.idText(name)), undefined);
31778                     }
31779                     return type.symbol
31780                         ? symbolToTypeNode(type.symbol, context, 788968)
31781                         : ts.createTypeReferenceNode(ts.createIdentifier("?"), undefined);
31782                 }
31783                 if (type.flags & (1048576 | 2097152)) {
31784                     var types = type.flags & 1048576 ? formatUnionTypes(type.types) : type.types;
31785                     if (ts.length(types) === 1) {
31786                         return typeToTypeNodeHelper(types[0], context);
31787                     }
31788                     var typeNodes = mapToTypeNodes(types, context, true);
31789                     if (typeNodes && typeNodes.length > 0) {
31790                         var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 ? 178 : 179, typeNodes);
31791                         return unionOrIntersectionTypeNode;
31792                     }
31793                     else {
31794                         if (!context.encounteredError && !(context.flags & 262144)) {
31795                             context.encounteredError = true;
31796                         }
31797                         return undefined;
31798                     }
31799                 }
31800                 if (objectFlags & (16 | 32)) {
31801                     ts.Debug.assert(!!(type.flags & 524288));
31802                     return createAnonymousTypeNode(type);
31803                 }
31804                 if (type.flags & 4194304) {
31805                     var indexedType = type.type;
31806                     context.approximateLength += 6;
31807                     var indexTypeNode = typeToTypeNodeHelper(indexedType, context);
31808                     return ts.createTypeOperatorNode(indexTypeNode);
31809                 }
31810                 if (type.flags & 8388608) {
31811                     var objectTypeNode = typeToTypeNodeHelper(type.objectType, context);
31812                     var indexTypeNode = typeToTypeNodeHelper(type.indexType, context);
31813                     context.approximateLength += 2;
31814                     return ts.createIndexedAccessTypeNode(objectTypeNode, indexTypeNode);
31815                 }
31816                 if (type.flags & 16777216) {
31817                     var checkTypeNode = typeToTypeNodeHelper(type.checkType, context);
31818                     var saveInferTypeParameters = context.inferTypeParameters;
31819                     context.inferTypeParameters = type.root.inferTypeParameters;
31820                     var extendsTypeNode = typeToTypeNodeHelper(type.extendsType, context);
31821                     context.inferTypeParameters = saveInferTypeParameters;
31822                     var trueTypeNode = typeToTypeNodeOrCircularityElision(getTrueTypeFromConditionalType(type));
31823                     var falseTypeNode = typeToTypeNodeOrCircularityElision(getFalseTypeFromConditionalType(type));
31824                     context.approximateLength += 15;
31825                     return ts.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode);
31826                 }
31827                 if (type.flags & 33554432) {
31828                     return typeToTypeNodeHelper(type.baseType, context);
31829                 }
31830                 return ts.Debug.fail("Should be unreachable.");
31831                 function typeToTypeNodeOrCircularityElision(type) {
31832                     var _a, _b;
31833                     if (type.flags & 1048576) {
31834                         if (context.visitedTypes && context.visitedTypes.has("" + getTypeId(type))) {
31835                             if (!(context.flags & 131072)) {
31836                                 context.encounteredError = true;
31837                                 (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.reportCyclicStructureError) === null || _b === void 0 ? void 0 : _b.call(_a);
31838                             }
31839                             return createElidedInformationPlaceholder(context);
31840                         }
31841                         return visitAndTransformType(type, function (type) { return typeToTypeNodeHelper(type, context); });
31842                     }
31843                     return typeToTypeNodeHelper(type, context);
31844                 }
31845                 function createMappedTypeNodeFromType(type) {
31846                     ts.Debug.assert(!!(type.flags & 524288));
31847                     var readonlyToken = type.declaration.readonlyToken ? ts.createToken(type.declaration.readonlyToken.kind) : undefined;
31848                     var questionToken = type.declaration.questionToken ? ts.createToken(type.declaration.questionToken.kind) : undefined;
31849                     var appropriateConstraintTypeNode;
31850                     if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
31851                         appropriateConstraintTypeNode = ts.createTypeOperatorNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context));
31852                     }
31853                     else {
31854                         appropriateConstraintTypeNode = typeToTypeNodeHelper(getConstraintTypeFromMappedType(type), context);
31855                     }
31856                     var typeParameterNode = typeParameterToDeclarationWithConstraint(getTypeParameterFromMappedType(type), context, appropriateConstraintTypeNode);
31857                     var templateTypeNode = typeToTypeNodeHelper(getTemplateTypeFromMappedType(type), context);
31858                     var mappedTypeNode = ts.createMappedTypeNode(readonlyToken, typeParameterNode, questionToken, templateTypeNode);
31859                     context.approximateLength += 10;
31860                     return ts.setEmitFlags(mappedTypeNode, 1);
31861                 }
31862                 function createAnonymousTypeNode(type) {
31863                     var typeId = "" + type.id;
31864                     var symbol = type.symbol;
31865                     if (symbol) {
31866                         if (isJSConstructor(symbol.valueDeclaration)) {
31867                             var isInstanceType = type === getDeclaredTypeOfClassOrInterface(symbol) ? 788968 : 111551;
31868                             return symbolToTypeNode(symbol, context, isInstanceType);
31869                         }
31870                         else if (symbol.flags & 32 && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 214 && context.flags & 2048) ||
31871                             symbol.flags & (384 | 512) ||
31872                             shouldWriteTypeOfFunctionSymbol()) {
31873                             return symbolToTypeNode(symbol, context, 111551);
31874                         }
31875                         else if (context.visitedTypes && context.visitedTypes.has(typeId)) {
31876                             var typeAlias = getTypeAliasForTypeLiteral(type);
31877                             if (typeAlias) {
31878                                 return symbolToTypeNode(typeAlias, context, 788968);
31879                             }
31880                             else {
31881                                 return createElidedInformationPlaceholder(context);
31882                             }
31883                         }
31884                         else {
31885                             return visitAndTransformType(type, createTypeNodeFromObjectType);
31886                         }
31887                     }
31888                     else {
31889                         return createTypeNodeFromObjectType(type);
31890                     }
31891                     function shouldWriteTypeOfFunctionSymbol() {
31892                         var isStaticMethodSymbol = !!(symbol.flags & 8192) &&
31893                             ts.some(symbol.declarations, function (declaration) { return ts.hasModifier(declaration, 32); });
31894                         var isNonLocalFunctionSymbol = !!(symbol.flags & 16) &&
31895                             (symbol.parent ||
31896                                 ts.forEach(symbol.declarations, function (declaration) {
31897                                     return declaration.parent.kind === 290 || declaration.parent.kind === 250;
31898                                 }));
31899                         if (isStaticMethodSymbol || isNonLocalFunctionSymbol) {
31900                             return (!!(context.flags & 4096) || (context.visitedTypes && context.visitedTypes.has(typeId))) &&
31901                                 (!(context.flags & 8) || isValueSymbolAccessible(symbol, context.enclosingDeclaration));
31902                         }
31903                     }
31904                 }
31905                 function visitAndTransformType(type, transform) {
31906                     var typeId = "" + type.id;
31907                     var isConstructorObject = ts.getObjectFlags(type) & 16 && type.symbol && type.symbol.flags & 32;
31908                     var id = ts.getObjectFlags(type) & 4 && type.node ? "N" + getNodeId(type.node) :
31909                         type.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type.symbol) :
31910                             undefined;
31911                     if (!context.visitedTypes) {
31912                         context.visitedTypes = ts.createMap();
31913                     }
31914                     if (id && !context.symbolDepth) {
31915                         context.symbolDepth = ts.createMap();
31916                     }
31917                     var depth;
31918                     if (id) {
31919                         depth = context.symbolDepth.get(id) || 0;
31920                         if (depth > 10) {
31921                             return createElidedInformationPlaceholder(context);
31922                         }
31923                         context.symbolDepth.set(id, depth + 1);
31924                     }
31925                     context.visitedTypes.set(typeId, true);
31926                     var result = transform(type);
31927                     context.visitedTypes.delete(typeId);
31928                     if (id) {
31929                         context.symbolDepth.set(id, depth);
31930                     }
31931                     return result;
31932                 }
31933                 function createTypeNodeFromObjectType(type) {
31934                     if (isGenericMappedType(type)) {
31935                         return createMappedTypeNodeFromType(type);
31936                     }
31937                     var resolved = resolveStructuredTypeMembers(type);
31938                     if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) {
31939                         if (!resolved.callSignatures.length && !resolved.constructSignatures.length) {
31940                             context.approximateLength += 2;
31941                             return ts.setEmitFlags(ts.createTypeLiteralNode(undefined), 1);
31942                         }
31943                         if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) {
31944                             var signature = resolved.callSignatures[0];
31945                             var signatureNode = signatureToSignatureDeclarationHelper(signature, 170, context);
31946                             return signatureNode;
31947                         }
31948                         if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) {
31949                             var signature = resolved.constructSignatures[0];
31950                             var signatureNode = signatureToSignatureDeclarationHelper(signature, 171, context);
31951                             return signatureNode;
31952                         }
31953                     }
31954                     var savedFlags = context.flags;
31955                     context.flags |= 4194304;
31956                     var members = createTypeNodesFromResolvedType(resolved);
31957                     context.flags = savedFlags;
31958                     var typeLiteralNode = ts.createTypeLiteralNode(members);
31959                     context.approximateLength += 2;
31960                     return ts.setEmitFlags(typeLiteralNode, (context.flags & 1024) ? 0 : 1);
31961                 }
31962                 function typeReferenceToTypeNode(type) {
31963                     var typeArguments = getTypeArguments(type);
31964                     if (type.target === globalArrayType || type.target === globalReadonlyArrayType) {
31965                         if (context.flags & 2) {
31966                             var typeArgumentNode = typeToTypeNodeHelper(typeArguments[0], context);
31967                             return ts.createTypeReferenceNode(type.target === globalArrayType ? "Array" : "ReadonlyArray", [typeArgumentNode]);
31968                         }
31969                         var elementType = typeToTypeNodeHelper(typeArguments[0], context);
31970                         var arrayType = ts.createArrayTypeNode(elementType);
31971                         return type.target === globalArrayType ? arrayType : ts.createTypeOperatorNode(138, arrayType);
31972                     }
31973                     else if (type.target.objectFlags & 8) {
31974                         if (typeArguments.length > 0) {
31975                             var arity = getTypeReferenceArity(type);
31976                             var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context);
31977                             var hasRestElement = type.target.hasRestElement;
31978                             if (tupleConstituentNodes) {
31979                                 for (var i = type.target.minLength; i < Math.min(arity, tupleConstituentNodes.length); i++) {
31980                                     tupleConstituentNodes[i] = hasRestElement && i === arity - 1 ?
31981                                         ts.createRestTypeNode(ts.createArrayTypeNode(tupleConstituentNodes[i])) :
31982                                         ts.createOptionalTypeNode(tupleConstituentNodes[i]);
31983                                 }
31984                                 var tupleTypeNode = ts.createTupleTypeNode(tupleConstituentNodes);
31985                                 return type.target.readonly ? ts.createTypeOperatorNode(138, tupleTypeNode) : tupleTypeNode;
31986                             }
31987                         }
31988                         if (context.encounteredError || (context.flags & 524288)) {
31989                             var tupleTypeNode = ts.createTupleTypeNode([]);
31990                             return type.target.readonly ? ts.createTypeOperatorNode(138, tupleTypeNode) : tupleTypeNode;
31991                         }
31992                         context.encounteredError = true;
31993                         return undefined;
31994                     }
31995                     else if (context.flags & 2048 &&
31996                         type.symbol.valueDeclaration &&
31997                         ts.isClassLike(type.symbol.valueDeclaration) &&
31998                         !isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) {
31999                         return createAnonymousTypeNode(type);
32000                     }
32001                     else {
32002                         var outerTypeParameters = type.target.outerTypeParameters;
32003                         var i = 0;
32004                         var resultType = void 0;
32005                         if (outerTypeParameters) {
32006                             var length_2 = outerTypeParameters.length;
32007                             while (i < length_2) {
32008                                 var start = i;
32009                                 var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]);
32010                                 do {
32011                                     i++;
32012                                 } while (i < length_2 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent);
32013                                 if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) {
32014                                     var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context);
32015                                     var flags_2 = context.flags;
32016                                     context.flags |= 16;
32017                                     var ref = symbolToTypeNode(parent, context, 788968, typeArgumentSlice);
32018                                     context.flags = flags_2;
32019                                     resultType = !resultType ? ref : appendReferenceToType(resultType, ref);
32020                                 }
32021                             }
32022                         }
32023                         var typeArgumentNodes = void 0;
32024                         if (typeArguments.length > 0) {
32025                             var typeParameterCount = (type.target.typeParameters || ts.emptyArray).length;
32026                             typeArgumentNodes = mapToTypeNodes(typeArguments.slice(i, typeParameterCount), context);
32027                         }
32028                         var flags = context.flags;
32029                         context.flags |= 16;
32030                         var finalRef = symbolToTypeNode(type.symbol, context, 788968, typeArgumentNodes);
32031                         context.flags = flags;
32032                         return !resultType ? finalRef : appendReferenceToType(resultType, finalRef);
32033                     }
32034                 }
32035                 function appendReferenceToType(root, ref) {
32036                     if (ts.isImportTypeNode(root)) {
32037                         var innerParams = root.typeArguments;
32038                         if (root.qualifier) {
32039                             (ts.isIdentifier(root.qualifier) ? root.qualifier : root.qualifier.right).typeArguments = innerParams;
32040                         }
32041                         root.typeArguments = ref.typeArguments;
32042                         var ids = getAccessStack(ref);
32043                         for (var _i = 0, ids_1 = ids; _i < ids_1.length; _i++) {
32044                             var id = ids_1[_i];
32045                             root.qualifier = root.qualifier ? ts.createQualifiedName(root.qualifier, id) : id;
32046                         }
32047                         return root;
32048                     }
32049                     else {
32050                         var innerParams = root.typeArguments;
32051                         (ts.isIdentifier(root.typeName) ? root.typeName : root.typeName.right).typeArguments = innerParams;
32052                         root.typeArguments = ref.typeArguments;
32053                         var ids = getAccessStack(ref);
32054                         for (var _a = 0, ids_2 = ids; _a < ids_2.length; _a++) {
32055                             var id = ids_2[_a];
32056                             root.typeName = ts.createQualifiedName(root.typeName, id);
32057                         }
32058                         return root;
32059                     }
32060                 }
32061                 function getAccessStack(ref) {
32062                     var state = ref.typeName;
32063                     var ids = [];
32064                     while (!ts.isIdentifier(state)) {
32065                         ids.unshift(state.right);
32066                         state = state.left;
32067                     }
32068                     ids.unshift(state);
32069                     return ids;
32070                 }
32071                 function createTypeNodesFromResolvedType(resolvedType) {
32072                     if (checkTruncationLength(context)) {
32073                         return [ts.createPropertySignature(undefined, "...", undefined, undefined, undefined)];
32074                     }
32075                     var typeElements = [];
32076                     for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) {
32077                         var signature = _a[_i];
32078                         typeElements.push(signatureToSignatureDeclarationHelper(signature, 165, context));
32079                     }
32080                     for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) {
32081                         var signature = _c[_b];
32082                         typeElements.push(signatureToSignatureDeclarationHelper(signature, 166, context));
32083                     }
32084                     if (resolvedType.stringIndexInfo) {
32085                         var indexSignature = void 0;
32086                         if (resolvedType.objectFlags & 2048) {
32087                             indexSignature = indexInfoToIndexSignatureDeclarationHelper(createIndexInfo(anyType, resolvedType.stringIndexInfo.isReadonly, resolvedType.stringIndexInfo.declaration), 0, context);
32088                             indexSignature.type = createElidedInformationPlaceholder(context);
32089                         }
32090                         else {
32091                             indexSignature = indexInfoToIndexSignatureDeclarationHelper(resolvedType.stringIndexInfo, 0, context);
32092                         }
32093                         typeElements.push(indexSignature);
32094                     }
32095                     if (resolvedType.numberIndexInfo) {
32096                         typeElements.push(indexInfoToIndexSignatureDeclarationHelper(resolvedType.numberIndexInfo, 1, context));
32097                     }
32098                     var properties = resolvedType.properties;
32099                     if (!properties) {
32100                         return typeElements;
32101                     }
32102                     var i = 0;
32103                     for (var _d = 0, properties_1 = properties; _d < properties_1.length; _d++) {
32104                         var propertySymbol = properties_1[_d];
32105                         i++;
32106                         if (context.flags & 2048) {
32107                             if (propertySymbol.flags & 4194304) {
32108                                 continue;
32109                             }
32110                             if (ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & (8 | 16) && context.tracker.reportPrivateInBaseOfClassExpression) {
32111                                 context.tracker.reportPrivateInBaseOfClassExpression(ts.unescapeLeadingUnderscores(propertySymbol.escapedName));
32112                             }
32113                         }
32114                         if (checkTruncationLength(context) && (i + 2 < properties.length - 1)) {
32115                             typeElements.push(ts.createPropertySignature(undefined, "... " + (properties.length - i) + " more ...", undefined, undefined, undefined));
32116                             addPropertyToElementList(properties[properties.length - 1], context, typeElements);
32117                             break;
32118                         }
32119                         addPropertyToElementList(propertySymbol, context, typeElements);
32120                     }
32121                     return typeElements.length ? typeElements : undefined;
32122                 }
32123             }
32124             function createElidedInformationPlaceholder(context) {
32125                 context.approximateLength += 3;
32126                 if (!(context.flags & 1)) {
32127                     return ts.createTypeReferenceNode(ts.createIdentifier("..."), undefined);
32128                 }
32129                 return ts.createKeywordTypeNode(125);
32130             }
32131             function addPropertyToElementList(propertySymbol, context, typeElements) {
32132                 var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192);
32133                 var propertyType = propertyIsReverseMapped && context.flags & 33554432 ?
32134                     anyType : getTypeOfSymbol(propertySymbol);
32135                 var saveEnclosingDeclaration = context.enclosingDeclaration;
32136                 context.enclosingDeclaration = undefined;
32137                 if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096) {
32138                     var decl = ts.first(propertySymbol.declarations);
32139                     if (hasLateBindableName(decl)) {
32140                         if (ts.isBinaryExpression(decl)) {
32141                             var name = ts.getNameOfDeclaration(decl);
32142                             if (name && ts.isElementAccessExpression(name) && ts.isPropertyAccessEntityNameExpression(name.argumentExpression)) {
32143                                 trackComputedName(name.argumentExpression, saveEnclosingDeclaration, context);
32144                             }
32145                         }
32146                         else {
32147                             trackComputedName(decl.name.expression, saveEnclosingDeclaration, context);
32148                         }
32149                     }
32150                 }
32151                 context.enclosingDeclaration = saveEnclosingDeclaration;
32152                 var propertyName = getPropertyNameNodeForSymbol(propertySymbol, context);
32153                 context.approximateLength += (ts.symbolName(propertySymbol).length + 1);
32154                 var optionalToken = propertySymbol.flags & 16777216 ? ts.createToken(57) : undefined;
32155                 if (propertySymbol.flags & (16 | 8192) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) {
32156                     var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768); }), 0);
32157                     for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) {
32158                         var signature = signatures_1[_i];
32159                         var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 160, context);
32160                         methodDeclaration.name = propertyName;
32161                         methodDeclaration.questionToken = optionalToken;
32162                         typeElements.push(preserveCommentsOn(methodDeclaration));
32163                     }
32164                 }
32165                 else {
32166                     var savedFlags = context.flags;
32167                     context.flags |= propertyIsReverseMapped ? 33554432 : 0;
32168                     var propertyTypeNode = void 0;
32169                     if (propertyIsReverseMapped && !!(savedFlags & 33554432)) {
32170                         propertyTypeNode = createElidedInformationPlaceholder(context);
32171                     }
32172                     else {
32173                         propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.createKeywordTypeNode(125);
32174                     }
32175                     context.flags = savedFlags;
32176                     var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(138)] : undefined;
32177                     if (modifiers) {
32178                         context.approximateLength += 9;
32179                     }
32180                     var propertySignature = ts.createPropertySignature(modifiers, propertyName, optionalToken, propertyTypeNode, undefined);
32181                     typeElements.push(preserveCommentsOn(propertySignature));
32182                 }
32183                 function preserveCommentsOn(node) {
32184                     if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 323; })) {
32185                         var d = ts.find(propertySymbol.declarations, function (d) { return d.kind === 323; });
32186                         var commentText = d.comment;
32187                         if (commentText) {
32188                             ts.setSyntheticLeadingComments(node, [{ kind: 3, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]);
32189                         }
32190                     }
32191                     else if (propertySymbol.valueDeclaration) {
32192                         ts.setCommentRange(node, propertySymbol.valueDeclaration);
32193                     }
32194                     return node;
32195                 }
32196             }
32197             function mapToTypeNodes(types, context, isBareList) {
32198                 if (ts.some(types)) {
32199                     if (checkTruncationLength(context)) {
32200                         if (!isBareList) {
32201                             return [ts.createTypeReferenceNode("...", undefined)];
32202                         }
32203                         else if (types.length > 2) {
32204                             return [
32205                                 typeToTypeNodeHelper(types[0], context),
32206                                 ts.createTypeReferenceNode("... " + (types.length - 2) + " more ...", undefined),
32207                                 typeToTypeNodeHelper(types[types.length - 1], context)
32208                             ];
32209                         }
32210                     }
32211                     var mayHaveNameCollisions = !(context.flags & 64);
32212                     var seenNames = mayHaveNameCollisions ? ts.createUnderscoreEscapedMultiMap() : undefined;
32213                     var result_3 = [];
32214                     var i = 0;
32215                     for (var _i = 0, types_1 = types; _i < types_1.length; _i++) {
32216                         var type = types_1[_i];
32217                         i++;
32218                         if (checkTruncationLength(context) && (i + 2 < types.length - 1)) {
32219                             result_3.push(ts.createTypeReferenceNode("... " + (types.length - i) + " more ...", undefined));
32220                             var typeNode_1 = typeToTypeNodeHelper(types[types.length - 1], context);
32221                             if (typeNode_1) {
32222                                 result_3.push(typeNode_1);
32223                             }
32224                             break;
32225                         }
32226                         context.approximateLength += 2;
32227                         var typeNode = typeToTypeNodeHelper(type, context);
32228                         if (typeNode) {
32229                             result_3.push(typeNode);
32230                             if (seenNames && ts.isIdentifierTypeReference(typeNode)) {
32231                                 seenNames.add(typeNode.typeName.escapedText, [type, result_3.length - 1]);
32232                             }
32233                         }
32234                     }
32235                     if (seenNames) {
32236                         var saveContextFlags = context.flags;
32237                         context.flags |= 64;
32238                         seenNames.forEach(function (types) {
32239                             if (!ts.arrayIsHomogeneous(types, function (_a, _b) {
32240                                 var a = _a[0];
32241                                 var b = _b[0];
32242                                 return typesAreSameReference(a, b);
32243                             })) {
32244                                 for (var _i = 0, types_2 = types; _i < types_2.length; _i++) {
32245                                     var _a = types_2[_i], type = _a[0], resultIndex = _a[1];
32246                                     result_3[resultIndex] = typeToTypeNodeHelper(type, context);
32247                                 }
32248                             }
32249                         });
32250                         context.flags = saveContextFlags;
32251                     }
32252                     return result_3;
32253                 }
32254             }
32255             function typesAreSameReference(a, b) {
32256                 return a === b
32257                     || !!a.symbol && a.symbol === b.symbol
32258                     || !!a.aliasSymbol && a.aliasSymbol === b.aliasSymbol;
32259             }
32260             function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context) {
32261                 var name = ts.getNameFromIndexInfo(indexInfo) || "x";
32262                 var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 ? 143 : 140);
32263                 var indexingParameter = ts.createParameter(undefined, undefined, undefined, name, undefined, indexerTypeNode, undefined);
32264                 var typeNode = typeToTypeNodeHelper(indexInfo.type || anyType, context);
32265                 if (!indexInfo.type && !(context.flags & 2097152)) {
32266                     context.encounteredError = true;
32267                 }
32268                 context.approximateLength += (name.length + 4);
32269                 return ts.createIndexSignature(undefined, indexInfo.isReadonly ? [ts.createToken(138)] : undefined, [indexingParameter], typeNode);
32270             }
32271             function signatureToSignatureDeclarationHelper(signature, kind, context, privateSymbolVisitor, bundledImports) {
32272                 var suppressAny = context.flags & 256;
32273                 if (suppressAny)
32274                     context.flags &= ~256;
32275                 var typeParameters;
32276                 var typeArguments;
32277                 if (context.flags & 32 && signature.target && signature.mapper && signature.target.typeParameters) {
32278                     typeArguments = signature.target.typeParameters.map(function (parameter) { return typeToTypeNodeHelper(instantiateType(parameter, signature.mapper), context); });
32279                 }
32280                 else {
32281                     typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); });
32282                 }
32283                 var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 162, privateSymbolVisitor, bundledImports); });
32284                 if (signature.thisParameter) {
32285                     var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context);
32286                     parameters.unshift(thisParameter);
32287                 }
32288                 var returnTypeNode;
32289                 var typePredicate = getTypePredicateOfSignature(signature);
32290                 if (typePredicate) {
32291                     var assertsModifier = typePredicate.kind === 2 || typePredicate.kind === 3 ?
32292                         ts.createToken(124) :
32293                         undefined;
32294                     var parameterName = typePredicate.kind === 1 || typePredicate.kind === 3 ?
32295                         ts.setEmitFlags(ts.createIdentifier(typePredicate.parameterName), 16777216) :
32296                         ts.createThisTypeNode();
32297                     var typeNode = typePredicate.type && typeToTypeNodeHelper(typePredicate.type, context);
32298                     returnTypeNode = ts.createTypePredicateNodeWithModifier(assertsModifier, parameterName, typeNode);
32299                 }
32300                 else {
32301                     var returnType = getReturnTypeOfSignature(signature);
32302                     if (returnType && !(suppressAny && isTypeAny(returnType))) {
32303                         returnTypeNode = serializeReturnTypeForSignature(context, returnType, signature, privateSymbolVisitor, bundledImports);
32304                     }
32305                     else if (!suppressAny) {
32306                         returnTypeNode = ts.createKeywordTypeNode(125);
32307                     }
32308                 }
32309                 context.approximateLength += 3;
32310                 return ts.createSignatureDeclaration(kind, typeParameters, parameters, returnTypeNode, typeArguments);
32311             }
32312             function typeParameterToDeclarationWithConstraint(type, context, constraintNode) {
32313                 var savedContextFlags = context.flags;
32314                 context.flags &= ~512;
32315                 var name = typeParameterToName(type, context);
32316                 var defaultParameter = getDefaultFromTypeParameter(type);
32317                 var defaultParameterNode = defaultParameter && typeToTypeNodeHelper(defaultParameter, context);
32318                 context.flags = savedContextFlags;
32319                 return ts.createTypeParameterDeclaration(name, constraintNode, defaultParameterNode);
32320             }
32321             function typeParameterToDeclaration(type, context, constraint) {
32322                 if (constraint === void 0) { constraint = getConstraintOfTypeParameter(type); }
32323                 var constraintNode = constraint && typeToTypeNodeHelper(constraint, context);
32324                 return typeParameterToDeclarationWithConstraint(type, context, constraintNode);
32325             }
32326             function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags, privateSymbolVisitor, bundledImports) {
32327                 var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 156);
32328                 if (!parameterDeclaration && !ts.isTransientSymbol(parameterSymbol)) {
32329                     parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 317);
32330                 }
32331                 var parameterType = getTypeOfSymbol(parameterSymbol);
32332                 if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) {
32333                     parameterType = getOptionalType(parameterType);
32334                 }
32335                 var parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports);
32336                 var modifiers = !(context.flags & 8192) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.getSynthesizedClone) : undefined;
32337                 var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768;
32338                 var dotDotDotToken = isRest ? ts.createToken(25) : undefined;
32339                 var name = parameterDeclaration ? parameterDeclaration.name ?
32340                     parameterDeclaration.name.kind === 75 ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216) :
32341                         parameterDeclaration.name.kind === 153 ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216) :
32342                             cloneBindingName(parameterDeclaration.name) :
32343                     ts.symbolName(parameterSymbol) :
32344                     ts.symbolName(parameterSymbol);
32345                 var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384;
32346                 var questionToken = isOptional ? ts.createToken(57) : undefined;
32347                 var parameterNode = ts.createParameter(undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, undefined);
32348                 context.approximateLength += ts.symbolName(parameterSymbol).length + 3;
32349                 return parameterNode;
32350                 function cloneBindingName(node) {
32351                     return elideInitializerAndSetEmitFlags(node);
32352                     function elideInitializerAndSetEmitFlags(node) {
32353                         if (context.tracker.trackSymbol && ts.isComputedPropertyName(node) && isLateBindableName(node)) {
32354                             trackComputedName(node.expression, context.enclosingDeclaration, context);
32355                         }
32356                         var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, undefined, elideInitializerAndSetEmitFlags);
32357                         var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited);
32358                         if (clone.kind === 191) {
32359                             clone.initializer = undefined;
32360                         }
32361                         return ts.setEmitFlags(clone, 1 | 16777216);
32362                     }
32363                 }
32364             }
32365             function trackComputedName(accessExpression, enclosingDeclaration, context) {
32366                 if (!context.tracker.trackSymbol)
32367                     return;
32368                 var firstIdentifier = ts.getFirstIdentifier(accessExpression);
32369                 var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 | 1048576, undefined, undefined, true);
32370                 if (name) {
32371                     context.tracker.trackSymbol(name, enclosingDeclaration, 111551);
32372                 }
32373             }
32374             function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) {
32375                 context.tracker.trackSymbol(symbol, context.enclosingDeclaration, meaning);
32376                 return lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol);
32377             }
32378             function lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol) {
32379                 var chain;
32380                 var isTypeParameter = symbol.flags & 262144;
32381                 if (!isTypeParameter && (context.enclosingDeclaration || context.flags & 64) && !(context.flags & 134217728)) {
32382                     chain = ts.Debug.checkDefined(getSymbolChain(symbol, meaning, true));
32383                     ts.Debug.assert(chain && chain.length > 0);
32384                 }
32385                 else {
32386                     chain = [symbol];
32387                 }
32388                 return chain;
32389                 function getSymbolChain(symbol, meaning, endOfChain) {
32390                     var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & 128));
32391                     var parentSpecifiers;
32392                     if (!accessibleSymbolChain ||
32393                         needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) {
32394                         var parents_1 = getContainersOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol, context.enclosingDeclaration);
32395                         if (ts.length(parents_1)) {
32396                             parentSpecifiers = parents_1.map(function (symbol) {
32397                                 return ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)
32398                                     ? getSpecifierForModuleSymbol(symbol, context)
32399                                     : undefined;
32400                             });
32401                             var indices = parents_1.map(function (_, i) { return i; });
32402                             indices.sort(sortByBestName);
32403                             var sortedParents = indices.map(function (i) { return parents_1[i]; });
32404                             for (var _i = 0, sortedParents_1 = sortedParents; _i < sortedParents_1.length; _i++) {
32405                                 var parent = sortedParents_1[_i];
32406                                 var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), false);
32407                                 if (parentChain) {
32408                                     if (parent.exports && parent.exports.get("export=") &&
32409                                         getSymbolIfSameReference(parent.exports.get("export="), symbol)) {
32410                                         accessibleSymbolChain = parentChain;
32411                                         break;
32412                                     }
32413                                     accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]);
32414                                     break;
32415                                 }
32416                             }
32417                         }
32418                     }
32419                     if (accessibleSymbolChain) {
32420                         return accessibleSymbolChain;
32421                     }
32422                     if (endOfChain ||
32423                         !(symbol.flags & (2048 | 4096))) {
32424                         if (!endOfChain && !yieldModuleSymbol && !!ts.forEach(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
32425                             return;
32426                         }
32427                         return [symbol];
32428                     }
32429                     function sortByBestName(a, b) {
32430                         var specifierA = parentSpecifiers[a];
32431                         var specifierB = parentSpecifiers[b];
32432                         if (specifierA && specifierB) {
32433                             var isBRelative = ts.pathIsRelative(specifierB);
32434                             if (ts.pathIsRelative(specifierA) === isBRelative) {
32435                                 return ts.moduleSpecifiers.countPathComponents(specifierA) - ts.moduleSpecifiers.countPathComponents(specifierB);
32436                             }
32437                             if (isBRelative) {
32438                                 return -1;
32439                             }
32440                             return 1;
32441                         }
32442                         return 0;
32443                     }
32444                 }
32445             }
32446             function typeParametersToTypeParameterDeclarations(symbol, context) {
32447                 var typeParameterNodes;
32448                 var targetSymbol = getTargetSymbol(symbol);
32449                 if (targetSymbol.flags & (32 | 64 | 524288)) {
32450                     typeParameterNodes = ts.createNodeArray(ts.map(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), function (tp) { return typeParameterToDeclaration(tp, context); }));
32451                 }
32452                 return typeParameterNodes;
32453             }
32454             function lookupTypeParameterNodes(chain, index, context) {
32455                 ts.Debug.assert(chain && 0 <= index && index < chain.length);
32456                 var symbol = chain[index];
32457                 var symbolId = "" + getSymbolId(symbol);
32458                 if (context.typeParameterSymbolList && context.typeParameterSymbolList.get(symbolId)) {
32459                     return undefined;
32460                 }
32461                 (context.typeParameterSymbolList || (context.typeParameterSymbolList = ts.createMap())).set(symbolId, true);
32462                 var typeParameterNodes;
32463                 if (context.flags & 512 && index < (chain.length - 1)) {
32464                     var parentSymbol = symbol;
32465                     var nextSymbol_1 = chain[index + 1];
32466                     if (ts.getCheckFlags(nextSymbol_1) & 1) {
32467                         var params = getTypeParametersOfClassOrInterface(parentSymbol.flags & 2097152 ? resolveAlias(parentSymbol) : parentSymbol);
32468                         typeParameterNodes = mapToTypeNodes(ts.map(params, function (t) { return getMappedType(t, nextSymbol_1.mapper); }), context);
32469                     }
32470                     else {
32471                         typeParameterNodes = typeParametersToTypeParameterDeclarations(symbol, context);
32472                     }
32473                 }
32474                 return typeParameterNodes;
32475             }
32476             function getTopmostIndexedAccessType(top) {
32477                 if (ts.isIndexedAccessTypeNode(top.objectType)) {
32478                     return getTopmostIndexedAccessType(top.objectType);
32479                 }
32480                 return top;
32481             }
32482             function getSpecifierForModuleSymbol(symbol, context) {
32483                 var file = ts.getDeclarationOfKind(symbol, 290);
32484                 if (!file) {
32485                     var equivalentFileSymbol = ts.firstDefined(symbol.declarations, function (d) { return getFileSymbolIfFileSymbolExportEqualsContainer(d, symbol); });
32486                     if (equivalentFileSymbol) {
32487                         file = ts.getDeclarationOfKind(equivalentFileSymbol, 290);
32488                     }
32489                 }
32490                 if (file && file.moduleName !== undefined) {
32491                     return file.moduleName;
32492                 }
32493                 if (!file) {
32494                     if (context.tracker.trackReferencedAmbientModule) {
32495                         var ambientDecls = ts.filter(symbol.declarations, ts.isAmbientModule);
32496                         if (ts.length(ambientDecls)) {
32497                             for (var _i = 0, ambientDecls_1 = ambientDecls; _i < ambientDecls_1.length; _i++) {
32498                                 var decl = ambientDecls_1[_i];
32499                                 context.tracker.trackReferencedAmbientModule(decl, symbol);
32500                             }
32501                         }
32502                     }
32503                     if (ambientModuleSymbolRegex.test(symbol.escapedName)) {
32504                         return symbol.escapedName.substring(1, symbol.escapedName.length - 1);
32505                     }
32506                 }
32507                 if (!context.enclosingDeclaration || !context.tracker.moduleResolverHost) {
32508                     if (ambientModuleSymbolRegex.test(symbol.escapedName)) {
32509                         return symbol.escapedName.substring(1, symbol.escapedName.length - 1);
32510                     }
32511                     return ts.getSourceFileOfNode(ts.getNonAugmentationDeclaration(symbol)).fileName;
32512                 }
32513                 var contextFile = ts.getSourceFileOfNode(ts.getOriginalNode(context.enclosingDeclaration));
32514                 var links = getSymbolLinks(symbol);
32515                 var specifier = links.specifierCache && links.specifierCache.get(contextFile.path);
32516                 if (!specifier) {
32517                     var isBundle_1 = (compilerOptions.out || compilerOptions.outFile);
32518                     var moduleResolverHost = context.tracker.moduleResolverHost;
32519                     var specifierCompilerOptions = isBundle_1 ? __assign(__assign({}, compilerOptions), { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions;
32520                     specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, specifierCompilerOptions, contextFile, moduleResolverHost, { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "relative" }));
32521                     links.specifierCache = links.specifierCache || ts.createMap();
32522                     links.specifierCache.set(contextFile.path, specifier);
32523                 }
32524                 return specifier;
32525             }
32526             function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) {
32527                 var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384));
32528                 var isTypeOf = meaning === 111551;
32529                 if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
32530                     var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined;
32531                     var typeParameterNodes = overrideTypeArguments || lookupTypeParameterNodes(chain, 0, context);
32532                     var specifier = getSpecifierForModuleSymbol(chain[0], context);
32533                     if (!(context.flags & 67108864) && ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs && specifier.indexOf("/node_modules/") >= 0) {
32534                         context.encounteredError = true;
32535                         if (context.tracker.reportLikelyUnsafeImportRequiredError) {
32536                             context.tracker.reportLikelyUnsafeImportRequiredError(specifier);
32537                         }
32538                     }
32539                     var lit = ts.createLiteralTypeNode(ts.createLiteral(specifier));
32540                     if (context.tracker.trackExternalModuleSymbolOfImportTypeNode)
32541                         context.tracker.trackExternalModuleSymbolOfImportTypeNode(chain[0]);
32542                     context.approximateLength += specifier.length + 10;
32543                     if (!nonRootParts || ts.isEntityName(nonRootParts)) {
32544                         if (nonRootParts) {
32545                             var lastId = ts.isIdentifier(nonRootParts) ? nonRootParts : nonRootParts.right;
32546                             lastId.typeArguments = undefined;
32547                         }
32548                         return ts.createImportTypeNode(lit, nonRootParts, typeParameterNodes, isTypeOf);
32549                     }
32550                     else {
32551                         var splitNode = getTopmostIndexedAccessType(nonRootParts);
32552                         var qualifier = splitNode.objectType.typeName;
32553                         return ts.createIndexedAccessTypeNode(ts.createImportTypeNode(lit, qualifier, typeParameterNodes, isTypeOf), splitNode.indexType);
32554                     }
32555                 }
32556                 var entityName = createAccessFromSymbolChain(chain, chain.length - 1, 0);
32557                 if (ts.isIndexedAccessTypeNode(entityName)) {
32558                     return entityName;
32559                 }
32560                 if (isTypeOf) {
32561                     return ts.createTypeQueryNode(entityName);
32562                 }
32563                 else {
32564                     var lastId = ts.isIdentifier(entityName) ? entityName : entityName.right;
32565                     var lastTypeArgs = lastId.typeArguments;
32566                     lastId.typeArguments = undefined;
32567                     return ts.createTypeReferenceNode(entityName, lastTypeArgs);
32568                 }
32569                 function createAccessFromSymbolChain(chain, index, stopper) {
32570                     var typeParameterNodes = index === (chain.length - 1) ? overrideTypeArguments : lookupTypeParameterNodes(chain, index, context);
32571                     var symbol = chain[index];
32572                     var parent = chain[index - 1];
32573                     var symbolName;
32574                     if (index === 0) {
32575                         context.flags |= 16777216;
32576                         symbolName = getNameOfSymbolAsWritten(symbol, context);
32577                         context.approximateLength += (symbolName ? symbolName.length : 0) + 1;
32578                         context.flags ^= 16777216;
32579                     }
32580                     else {
32581                         if (parent && getExportsOfSymbol(parent)) {
32582                             var exports_1 = getExportsOfSymbol(parent);
32583                             ts.forEachEntry(exports_1, function (ex, name) {
32584                                 if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=") {
32585                                     symbolName = ts.unescapeLeadingUnderscores(name);
32586                                     return true;
32587                                 }
32588                             });
32589                         }
32590                     }
32591                     if (!symbolName) {
32592                         symbolName = getNameOfSymbolAsWritten(symbol, context);
32593                     }
32594                     context.approximateLength += symbolName.length + 1;
32595                     if (!(context.flags & 16) && parent &&
32596                         getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) &&
32597                         getSymbolIfSameReference(getMembersOfSymbol(parent).get(symbol.escapedName), symbol)) {
32598                         var LHS = createAccessFromSymbolChain(chain, index - 1, stopper);
32599                         if (ts.isIndexedAccessTypeNode(LHS)) {
32600                             return ts.createIndexedAccessTypeNode(LHS, ts.createLiteralTypeNode(ts.createLiteral(symbolName)));
32601                         }
32602                         else {
32603                             return ts.createIndexedAccessTypeNode(ts.createTypeReferenceNode(LHS, typeParameterNodes), ts.createLiteralTypeNode(ts.createLiteral(symbolName)));
32604                         }
32605                     }
32606                     var identifier = ts.setEmitFlags(ts.createIdentifier(symbolName, typeParameterNodes), 16777216);
32607                     identifier.symbol = symbol;
32608                     if (index > stopper) {
32609                         var LHS = createAccessFromSymbolChain(chain, index - 1, stopper);
32610                         if (!ts.isEntityName(LHS)) {
32611                             return ts.Debug.fail("Impossible construct - an export of an indexed access cannot be reachable");
32612                         }
32613                         return ts.createQualifiedName(LHS, identifier);
32614                     }
32615                     return identifier;
32616                 }
32617             }
32618             function typeParameterShadowsNameInScope(escapedName, context, type) {
32619                 var result = resolveName(context.enclosingDeclaration, escapedName, 788968, undefined, escapedName, false);
32620                 if (result) {
32621                     if (result.flags & 262144 && result === type.symbol) {
32622                         return false;
32623                     }
32624                     return true;
32625                 }
32626                 return false;
32627             }
32628             function typeParameterToName(type, context) {
32629                 if (context.flags & 4 && context.typeParameterNames) {
32630                     var cached = context.typeParameterNames.get("" + getTypeId(type));
32631                     if (cached) {
32632                         return cached;
32633                     }
32634                 }
32635                 var result = symbolToName(type.symbol, context, 788968, true);
32636                 if (!(result.kind & 75)) {
32637                     return ts.createIdentifier("(Missing type parameter)");
32638                 }
32639                 if (context.flags & 4) {
32640                     var rawtext = result.escapedText;
32641                     var i = 0;
32642                     var text = rawtext;
32643                     while ((context.typeParameterNamesByText && context.typeParameterNamesByText.get(text)) || typeParameterShadowsNameInScope(text, context, type)) {
32644                         i++;
32645                         text = rawtext + "_" + i;
32646                     }
32647                     if (text !== rawtext) {
32648                         result = ts.createIdentifier(text, result.typeArguments);
32649                     }
32650                     (context.typeParameterNames || (context.typeParameterNames = ts.createMap())).set("" + getTypeId(type), result);
32651                     (context.typeParameterNamesByText || (context.typeParameterNamesByText = ts.createMap())).set(result.escapedText, true);
32652                 }
32653                 return result;
32654             }
32655             function symbolToName(symbol, context, meaning, expectsIdentifier) {
32656                 var chain = lookupSymbolChain(symbol, context, meaning);
32657                 if (expectsIdentifier && chain.length !== 1
32658                     && !context.encounteredError
32659                     && !(context.flags & 65536)) {
32660                     context.encounteredError = true;
32661                 }
32662                 return createEntityNameFromSymbolChain(chain, chain.length - 1);
32663                 function createEntityNameFromSymbolChain(chain, index) {
32664                     var typeParameterNodes = lookupTypeParameterNodes(chain, index, context);
32665                     var symbol = chain[index];
32666                     if (index === 0) {
32667                         context.flags |= 16777216;
32668                     }
32669                     var symbolName = getNameOfSymbolAsWritten(symbol, context);
32670                     if (index === 0) {
32671                         context.flags ^= 16777216;
32672                     }
32673                     var identifier = ts.setEmitFlags(ts.createIdentifier(symbolName, typeParameterNodes), 16777216);
32674                     identifier.symbol = symbol;
32675                     return index > 0 ? ts.createQualifiedName(createEntityNameFromSymbolChain(chain, index - 1), identifier) : identifier;
32676                 }
32677             }
32678             function symbolToExpression(symbol, context, meaning) {
32679                 var chain = lookupSymbolChain(symbol, context, meaning);
32680                 return createExpressionFromSymbolChain(chain, chain.length - 1);
32681                 function createExpressionFromSymbolChain(chain, index) {
32682                     var typeParameterNodes = lookupTypeParameterNodes(chain, index, context);
32683                     var symbol = chain[index];
32684                     if (index === 0) {
32685                         context.flags |= 16777216;
32686                     }
32687                     var symbolName = getNameOfSymbolAsWritten(symbol, context);
32688                     if (index === 0) {
32689                         context.flags ^= 16777216;
32690                     }
32691                     var firstChar = symbolName.charCodeAt(0);
32692                     if (ts.isSingleOrDoubleQuote(firstChar) && ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
32693                         return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context));
32694                     }
32695                     var canUsePropertyAccess = firstChar === 35 ?
32696                         symbolName.length > 1 && ts.isIdentifierStart(symbolName.charCodeAt(1), languageVersion) :
32697                         ts.isIdentifierStart(firstChar, languageVersion);
32698                     if (index === 0 || canUsePropertyAccess) {
32699                         var identifier = ts.setEmitFlags(ts.createIdentifier(symbolName, typeParameterNodes), 16777216);
32700                         identifier.symbol = symbol;
32701                         return index > 0 ? ts.createPropertyAccess(createExpressionFromSymbolChain(chain, index - 1), identifier) : identifier;
32702                     }
32703                     else {
32704                         if (firstChar === 91) {
32705                             symbolName = symbolName.substring(1, symbolName.length - 1);
32706                             firstChar = symbolName.charCodeAt(0);
32707                         }
32708                         var expression = void 0;
32709                         if (ts.isSingleOrDoubleQuote(firstChar)) {
32710                             expression = ts.createLiteral(symbolName.substring(1, symbolName.length - 1).replace(/\\./g, function (s) { return s.substring(1); }));
32711                             expression.singleQuote = firstChar === 39;
32712                         }
32713                         else if (("" + +symbolName) === symbolName) {
32714                             expression = ts.createLiteral(+symbolName);
32715                         }
32716                         if (!expression) {
32717                             expression = ts.setEmitFlags(ts.createIdentifier(symbolName, typeParameterNodes), 16777216);
32718                             expression.symbol = symbol;
32719                         }
32720                         return ts.createElementAccess(createExpressionFromSymbolChain(chain, index - 1), expression);
32721                     }
32722                 }
32723             }
32724             function isSingleQuotedStringNamed(d) {
32725                 var name = ts.getNameOfDeclaration(d);
32726                 if (name && ts.isStringLiteral(name) && (name.singleQuote ||
32727                     (!ts.nodeIsSynthesized(name) && ts.startsWith(ts.getTextOfNode(name, false), "'")))) {
32728                     return true;
32729                 }
32730                 return false;
32731             }
32732             function getPropertyNameNodeForSymbol(symbol, context) {
32733                 var singleQuote = !!ts.length(symbol.declarations) && ts.every(symbol.declarations, isSingleQuotedStringNamed);
32734                 var fromNameType = getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote);
32735                 if (fromNameType) {
32736                     return fromNameType;
32737                 }
32738                 if (ts.isKnownSymbol(symbol)) {
32739                     return ts.createComputedPropertyName(ts.createPropertyAccess(ts.createIdentifier("Symbol"), symbol.escapedName.substr(3)));
32740                 }
32741                 var rawName = ts.unescapeLeadingUnderscores(symbol.escapedName);
32742                 return createPropertyNameNodeForIdentifierOrLiteral(rawName, singleQuote);
32743             }
32744             function getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote) {
32745                 var nameType = getSymbolLinks(symbol).nameType;
32746                 if (nameType) {
32747                     if (nameType.flags & 384) {
32748                         var name = "" + nameType.value;
32749                         if (!ts.isIdentifierText(name, compilerOptions.target) && !isNumericLiteralName(name)) {
32750                             return ts.createLiteral(name, !!singleQuote);
32751                         }
32752                         if (isNumericLiteralName(name) && ts.startsWith(name, "-")) {
32753                             return ts.createComputedPropertyName(ts.createLiteral(+name));
32754                         }
32755                         return createPropertyNameNodeForIdentifierOrLiteral(name);
32756                     }
32757                     if (nameType.flags & 8192) {
32758                         return ts.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551));
32759                     }
32760                 }
32761             }
32762             function createPropertyNameNodeForIdentifierOrLiteral(name, singleQuote) {
32763                 return ts.isIdentifierText(name, compilerOptions.target) ? ts.createIdentifier(name) : ts.createLiteral(isNumericLiteralName(name) && +name >= 0 ? +name : name, !!singleQuote);
32764             }
32765             function cloneNodeBuilderContext(context) {
32766                 var initial = __assign({}, context);
32767                 if (initial.typeParameterNames) {
32768                     initial.typeParameterNames = ts.cloneMap(initial.typeParameterNames);
32769                 }
32770                 if (initial.typeParameterNamesByText) {
32771                     initial.typeParameterNamesByText = ts.cloneMap(initial.typeParameterNamesByText);
32772                 }
32773                 if (initial.typeParameterSymbolList) {
32774                     initial.typeParameterSymbolList = ts.cloneMap(initial.typeParameterSymbolList);
32775                 }
32776                 return initial;
32777             }
32778             function getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration) {
32779                 return symbol.declarations && ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && (!enclosingDeclaration || !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; })); });
32780             }
32781             function existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) {
32782                 return !(ts.getObjectFlags(type) & 4) || !ts.isTypeReferenceNode(existing) || ts.length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters);
32783             }
32784             function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled) {
32785                 if (type !== errorType && enclosingDeclaration) {
32786                     var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration);
32787                     if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) {
32788                         var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation);
32789                         if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
32790                             var result_4 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled);
32791                             if (result_4) {
32792                                 return result_4;
32793                             }
32794                         }
32795                     }
32796                 }
32797                 var oldFlags = context.flags;
32798                 if (type.flags & 8192 &&
32799                     type.symbol === symbol) {
32800                     context.flags |= 1048576;
32801                 }
32802                 var result = typeToTypeNodeHelper(type, context);
32803                 context.flags = oldFlags;
32804                 return result;
32805             }
32806             function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) {
32807                 if (type !== errorType && context.enclosingDeclaration) {
32808                     var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration);
32809                     if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) {
32810                         var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled);
32811                         if (result) {
32812                             return result;
32813                         }
32814                     }
32815                 }
32816                 return typeToTypeNodeHelper(type, context);
32817             }
32818             function serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled) {
32819                 if (cancellationToken && cancellationToken.throwIfCancellationRequested) {
32820                     cancellationToken.throwIfCancellationRequested();
32821                 }
32822                 var hadError = false;
32823                 var transformed = ts.visitNode(existing, visitExistingNodeTreeSymbols);
32824                 if (hadError) {
32825                     return undefined;
32826                 }
32827                 return transformed === existing ? ts.getMutableClone(existing) : transformed;
32828                 function visitExistingNodeTreeSymbols(node) {
32829                     var _a, _b;
32830                     if (ts.isJSDocAllType(node) || node.kind === 302) {
32831                         return ts.createKeywordTypeNode(125);
32832                     }
32833                     if (ts.isJSDocUnknownType(node)) {
32834                         return ts.createKeywordTypeNode(148);
32835                     }
32836                     if (ts.isJSDocNullableType(node)) {
32837                         return ts.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.createKeywordTypeNode(100)]);
32838                     }
32839                     if (ts.isJSDocOptionalType(node)) {
32840                         return ts.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.createKeywordTypeNode(146)]);
32841                     }
32842                     if (ts.isJSDocNonNullableType(node)) {
32843                         return ts.visitNode(node.type, visitExistingNodeTreeSymbols);
32844                     }
32845                     if (ts.isJSDocVariadicType(node)) {
32846                         return ts.createArrayTypeNode(ts.visitNode(node.type, visitExistingNodeTreeSymbols));
32847                     }
32848                     if (ts.isJSDocTypeLiteral(node)) {
32849                         return ts.createTypeLiteralNode(ts.map(node.jsDocPropertyTags, function (t) {
32850                             var name = ts.isIdentifier(t.name) ? t.name : t.name.right;
32851                             var typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode(node), name.escapedText);
32852                             var overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode(t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : undefined;
32853                             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);
32854                         }));
32855                     }
32856                     if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") {
32857                         return ts.setOriginalNode(ts.createKeywordTypeNode(125), node);
32858                     }
32859                     if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) {
32860                         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))]);
32861                     }
32862                     if (ts.isJSDocFunctionType(node)) {
32863                         if (ts.isJSDocConstructSignature(node)) {
32864                             var newTypeNode_1;
32865                             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));
32866                         }
32867                         else {
32868                             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));
32869                         }
32870                     }
32871                     if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(getTypeReferenceName(node), 788968, true))) {
32872                         return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node);
32873                     }
32874                     if (ts.isLiteralImportTypeNode(node)) {
32875                         return ts.updateImportTypeNode(node, ts.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)), node.qualifier, ts.visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, ts.isTypeNode), node.isTypeOf);
32876                     }
32877                     if (ts.isEntityName(node) || ts.isEntityNameExpression(node)) {
32878                         var leftmost = ts.getFirstIdentifier(node);
32879                         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)))) {
32880                             hadError = true;
32881                             return node;
32882                         }
32883                         var sym = resolveEntityName(leftmost, 67108863, true, true);
32884                         if (sym) {
32885                             if (isSymbolAccessible(sym, context.enclosingDeclaration, 67108863, false).accessibility !== 0) {
32886                                 hadError = true;
32887                             }
32888                             else {
32889                                 (_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);
32890                                 includePrivateSymbol === null || includePrivateSymbol === void 0 ? void 0 : includePrivateSymbol(sym);
32891                             }
32892                             if (ts.isIdentifier(node)) {
32893                                 var name = sym.flags & 262144 ? typeParameterToName(getDeclaredTypeOfSymbol(sym), context) : ts.getMutableClone(node);
32894                                 name.symbol = sym;
32895                                 return ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216);
32896                             }
32897                         }
32898                     }
32899                     return ts.visitEachChild(node, visitExistingNodeTreeSymbols, ts.nullTransformationContext);
32900                     function getEffectiveDotDotDotForParameter(p) {
32901                         return p.dotDotDotToken || (p.type && ts.isJSDocVariadicType(p.type) ? ts.createToken(25) : undefined);
32902                     }
32903                     function rewriteModuleSpecifier(parent, lit) {
32904                         if (bundled) {
32905                             if (context.tracker && context.tracker.moduleResolverHost) {
32906                                 var targetFile = getExternalModuleFileFromDeclaration(parent);
32907                                 if (targetFile) {
32908                                     var getCanonicalFileName = ts.createGetCanonicalFileName(!!host.useCaseSensitiveFileNames);
32909                                     var resolverHost = {
32910                                         getCanonicalFileName: getCanonicalFileName,
32911                                         getCurrentDirectory: function () { return context.tracker.moduleResolverHost.getCurrentDirectory(); },
32912                                         getCommonSourceDirectory: function () { return context.tracker.moduleResolverHost.getCommonSourceDirectory(); }
32913                                     };
32914                                     var newName = ts.getResolvedExternalModuleName(resolverHost, targetFile);
32915                                     return ts.createLiteral(newName);
32916                                 }
32917                             }
32918                         }
32919                         else {
32920                             if (context.tracker && context.tracker.trackExternalModuleSymbolOfImportTypeNode) {
32921                                 var moduleSym = resolveExternalModuleNameWorker(lit, lit, undefined);
32922                                 if (moduleSym) {
32923                                     context.tracker.trackExternalModuleSymbolOfImportTypeNode(moduleSym);
32924                                 }
32925                             }
32926                         }
32927                         return lit;
32928                     }
32929                 }
32930             }
32931             function symbolTableToDeclarationStatements(symbolTable, context, bundled) {
32932                 var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.createProperty, 161, true);
32933                 var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type, initializer) { return ts.createPropertySignature(mods, name, question, type, initializer); }, 160, false);
32934                 var enclosingDeclaration = context.enclosingDeclaration;
32935                 var results = [];
32936                 var visitedSymbols = ts.createMap();
32937                 var deferredPrivates;
32938                 var oldcontext = context;
32939                 context = __assign(__assign({}, oldcontext), { usedSymbolNames: ts.createMap(), remappedSymbolNames: ts.createMap(), tracker: __assign(__assign({}, oldcontext.tracker), { trackSymbol: function (sym, decl, meaning) {
32940                             var accessibleResult = isSymbolAccessible(sym, decl, meaning, false);
32941                             if (accessibleResult.accessibility === 0) {
32942                                 var chain = lookupSymbolChainWorker(sym, context, meaning);
32943                                 if (!(sym.flags & 4)) {
32944                                     includePrivateSymbol(chain[0]);
32945                                 }
32946                             }
32947                             else if (oldcontext.tracker && oldcontext.tracker.trackSymbol) {
32948                                 oldcontext.tracker.trackSymbol(sym, decl, meaning);
32949                             }
32950                         } }) });
32951                 if (oldcontext.usedSymbolNames) {
32952                     oldcontext.usedSymbolNames.forEach(function (_, name) {
32953                         context.usedSymbolNames.set(name, true);
32954                     });
32955                 }
32956                 ts.forEachEntry(symbolTable, function (symbol, name) {
32957                     var baseName = ts.unescapeLeadingUnderscores(name);
32958                     void getInternalSymbolName(symbol, baseName);
32959                 });
32960                 var addingDeclare = !bundled;
32961                 var exportEquals = symbolTable.get("export=");
32962                 if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152) {
32963                     symbolTable = ts.createSymbolTable();
32964                     symbolTable.set("export=", exportEquals);
32965                 }
32966                 visitSymbolTable(symbolTable);
32967                 return mergeRedundantStatements(results);
32968                 function isIdentifierAndNotUndefined(node) {
32969                     return !!node && node.kind === 75;
32970                 }
32971                 function getNamesOfDeclaration(statement) {
32972                     if (ts.isVariableStatement(statement)) {
32973                         return ts.filter(ts.map(statement.declarationList.declarations, ts.getNameOfDeclaration), isIdentifierAndNotUndefined);
32974                     }
32975                     return ts.filter([ts.getNameOfDeclaration(statement)], isIdentifierAndNotUndefined);
32976                 }
32977                 function flattenExportAssignedNamespace(statements) {
32978                     var exportAssignment = ts.find(statements, ts.isExportAssignment);
32979                     var ns = ts.find(statements, ts.isModuleDeclaration);
32980                     if (ns && exportAssignment && exportAssignment.isExportEquals &&
32981                         ts.isIdentifier(exportAssignment.expression) && ts.isIdentifier(ns.name) && ts.idText(ns.name) === ts.idText(exportAssignment.expression) &&
32982                         ns.body && ts.isModuleBlock(ns.body)) {
32983                         var excessExports = ts.filter(statements, function (s) { return !!(ts.getModifierFlags(s) & 1); });
32984                         if (ts.length(excessExports)) {
32985                             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)]));
32986                         }
32987                         if (!ts.find(statements, function (s) { return s !== ns && ts.nodeHasName(s, ns.name); })) {
32988                             results = [];
32989                             ts.forEach(ns.body.statements, function (s) {
32990                                 addResult(s, 0);
32991                             });
32992                             statements = __spreadArrays(ts.filter(statements, function (s) { return s !== ns && s !== exportAssignment; }), results);
32993                         }
32994                     }
32995                     return statements;
32996                 }
32997                 function mergeExportDeclarations(statements) {
32998                     var exports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause && ts.isNamedExports(d.exportClause); });
32999                     if (ts.length(exports) > 1) {
33000                         var nonExports = ts.filter(statements, function (d) { return !ts.isExportDeclaration(d) || !!d.moduleSpecifier || !d.exportClause; });
33001                         statements = __spreadArrays(nonExports, [ts.createExportDeclaration(undefined, undefined, ts.createNamedExports(ts.flatMap(exports, function (e) { return ts.cast(e.exportClause, ts.isNamedExports).elements; })), undefined)]);
33002                     }
33003                     var reexports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !!d.moduleSpecifier && !!d.exportClause && ts.isNamedExports(d.exportClause); });
33004                     if (ts.length(reexports) > 1) {
33005                         var groups = ts.group(reexports, function (decl) { return ts.isStringLiteral(decl.moduleSpecifier) ? ">" + decl.moduleSpecifier.text : ">"; });
33006                         if (groups.length !== reexports.length) {
33007                             var _loop_8 = function (group_1) {
33008                                 if (group_1.length > 1) {
33009                                     statements = __spreadArrays(ts.filter(statements, function (s) { return group_1.indexOf(s) === -1; }), [
33010                                         ts.createExportDeclaration(undefined, undefined, ts.createNamedExports(ts.flatMap(group_1, function (e) { return ts.cast(e.exportClause, ts.isNamedExports).elements; })), group_1[0].moduleSpecifier)
33011                                     ]);
33012                                 }
33013                             };
33014                             for (var _i = 0, groups_1 = groups; _i < groups_1.length; _i++) {
33015                                 var group_1 = groups_1[_i];
33016                                 _loop_8(group_1);
33017                             }
33018                         }
33019                     }
33020                     return statements;
33021                 }
33022                 function inlineExportModifiers(statements) {
33023                     var exportDecl = ts.find(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause; });
33024                     if (exportDecl && exportDecl.exportClause && ts.isNamedExports(exportDecl.exportClause)) {
33025                         var replacements = ts.mapDefined(exportDecl.exportClause.elements, function (e) {
33026                             if (!e.propertyName) {
33027                                 var associated = ts.filter(statements, function (s) { return ts.nodeHasName(s, e.name); });
33028                                 if (ts.length(associated) && ts.every(associated, canHaveExportModifier)) {
33029                                     ts.forEach(associated, addExportModifier);
33030                                     return undefined;
33031                                 }
33032                             }
33033                             return e;
33034                         });
33035                         if (!ts.length(replacements)) {
33036                             statements = ts.filter(statements, function (s) { return s !== exportDecl; });
33037                         }
33038                         else {
33039                             exportDecl.exportClause.elements = ts.createNodeArray(replacements);
33040                         }
33041                     }
33042                     return statements;
33043                 }
33044                 function mergeRedundantStatements(statements) {
33045                     statements = flattenExportAssignedNamespace(statements);
33046                     statements = mergeExportDeclarations(statements);
33047                     statements = inlineExportModifiers(statements);
33048                     if (enclosingDeclaration &&
33049                         ((ts.isSourceFile(enclosingDeclaration) && ts.isExternalOrCommonJsModule(enclosingDeclaration)) || ts.isModuleDeclaration(enclosingDeclaration)) &&
33050                         (!ts.some(statements, ts.isExternalModuleIndicator) || (!ts.hasScopeMarker(statements) && ts.some(statements, ts.needsScopeMarker)))) {
33051                         statements.push(ts.createEmptyExports());
33052                     }
33053                     return statements;
33054                 }
33055                 function canHaveExportModifier(node) {
33056                     return ts.isEnumDeclaration(node) ||
33057                         ts.isVariableStatement(node) ||
33058                         ts.isFunctionDeclaration(node) ||
33059                         ts.isClassDeclaration(node) ||
33060                         (ts.isModuleDeclaration(node) && !ts.isExternalModuleAugmentation(node) && !ts.isGlobalScopeAugmentation(node)) ||
33061                         ts.isInterfaceDeclaration(node) ||
33062                         isTypeDeclaration(node);
33063                 }
33064                 function addExportModifier(statement) {
33065                     var flags = (ts.getModifierFlags(statement) | 1) & ~2;
33066                     statement.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(flags));
33067                     statement.modifierFlagsCache = 0;
33068                 }
33069                 function visitSymbolTable(symbolTable, suppressNewPrivateContext, propertyAsAlias) {
33070                     var oldDeferredPrivates = deferredPrivates;
33071                     if (!suppressNewPrivateContext) {
33072                         deferredPrivates = ts.createMap();
33073                     }
33074                     symbolTable.forEach(function (symbol) {
33075                         serializeSymbol(symbol, false, !!propertyAsAlias);
33076                     });
33077                     if (!suppressNewPrivateContext) {
33078                         deferredPrivates.forEach(function (symbol) {
33079                             serializeSymbol(symbol, true, !!propertyAsAlias);
33080                         });
33081                     }
33082                     deferredPrivates = oldDeferredPrivates;
33083                 }
33084                 function serializeSymbol(symbol, isPrivate, propertyAsAlias) {
33085                     var visitedSym = getMergedSymbol(symbol);
33086                     if (visitedSymbols.has("" + getSymbolId(visitedSym))) {
33087                         return;
33088                     }
33089                     visitedSymbols.set("" + getSymbolId(visitedSym), true);
33090                     var skipMembershipCheck = !isPrivate;
33091                     if (skipMembershipCheck || (!!ts.length(symbol.declarations) && ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, function (n) { return n === enclosingDeclaration; }); }))) {
33092                         var oldContext = context;
33093                         context = cloneNodeBuilderContext(context);
33094                         var result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias);
33095                         context = oldContext;
33096                         return result;
33097                     }
33098                 }
33099                 function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) {
33100                     var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName);
33101                     var isDefault = symbol.escapedName === "default";
33102                     if (!(context.flags & 131072) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) {
33103                         context.encounteredError = true;
33104                         return;
33105                     }
33106                     var needsPostExportDefault = isDefault && !!(symbol.flags & -113
33107                         || (symbol.flags & 16 && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152);
33108                     if (needsPostExportDefault) {
33109                         isPrivate = true;
33110                     }
33111                     var modifierFlags = (!isPrivate ? 1 : 0) | (isDefault && !needsPostExportDefault ? 512 : 0);
33112                     var isConstMergedWithNS = symbol.flags & 1536 &&
33113                         symbol.flags & (2 | 1 | 4) &&
33114                         symbol.escapedName !== "export=";
33115                     var isConstMergedWithNSPrintableAsSignatureMerge = isConstMergedWithNS && isTypeRepresentableAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol);
33116                     if (symbol.flags & (16 | 8192) || isConstMergedWithNSPrintableAsSignatureMerge) {
33117                         serializeAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol, getInternalSymbolName(symbol, symbolName), modifierFlags);
33118                     }
33119                     if (symbol.flags & 524288) {
33120                         serializeTypeAlias(symbol, symbolName, modifierFlags);
33121                     }
33122                     if (symbol.flags & (2 | 1 | 4)
33123                         && symbol.escapedName !== "export="
33124                         && !(symbol.flags & 4194304)
33125                         && !(symbol.flags & 32)
33126                         && !isConstMergedWithNSPrintableAsSignatureMerge) {
33127                         serializeVariableOrProperty(symbol, symbolName, isPrivate, needsPostExportDefault, propertyAsAlias, modifierFlags);
33128                     }
33129                     if (symbol.flags & 384) {
33130                         serializeEnum(symbol, symbolName, modifierFlags);
33131                     }
33132                     if (symbol.flags & 32) {
33133                         if (symbol.flags & 4 && ts.isBinaryExpression(symbol.valueDeclaration.parent) && ts.isClassExpression(symbol.valueDeclaration.parent.right)) {
33134                             serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags);
33135                         }
33136                         else {
33137                             serializeAsClass(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags);
33138                         }
33139                     }
33140                     if ((symbol.flags & (512 | 1024) && (!isConstMergedWithNS || isTypeOnlyNamespace(symbol))) || isConstMergedWithNSPrintableAsSignatureMerge) {
33141                         serializeModule(symbol, symbolName, modifierFlags);
33142                     }
33143                     if (symbol.flags & 64) {
33144                         serializeInterface(symbol, symbolName, modifierFlags);
33145                     }
33146                     if (symbol.flags & 2097152) {
33147                         serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags);
33148                     }
33149                     if (symbol.flags & 4 && symbol.escapedName === "export=") {
33150                         serializeMaybeAliasAssignment(symbol);
33151                     }
33152                     if (symbol.flags & 8388608) {
33153                         for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
33154                             var node = _a[_i];
33155                             var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier);
33156                             if (!resolvedModule)
33157                                 continue;
33158                             addResult(ts.createExportDeclaration(undefined, undefined, undefined, ts.createLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0);
33159                         }
33160                     }
33161                     if (needsPostExportDefault) {
33162                         addResult(ts.createExportAssignment(undefined, undefined, false, ts.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0);
33163                     }
33164                 }
33165                 function includePrivateSymbol(symbol) {
33166                     if (ts.some(symbol.declarations, ts.isParameterDeclaration))
33167                         return;
33168                     ts.Debug.assertIsDefined(deferredPrivates);
33169                     getUnusedName(ts.unescapeLeadingUnderscores(symbol.escapedName), symbol);
33170                     deferredPrivates.set("" + getSymbolId(symbol), symbol);
33171                 }
33172                 function isExportingScope(enclosingDeclaration) {
33173                     return ((ts.isSourceFile(enclosingDeclaration) && (ts.isExternalOrCommonJsModule(enclosingDeclaration) || ts.isJsonSourceFile(enclosingDeclaration))) ||
33174                         (ts.isAmbientModule(enclosingDeclaration) && !ts.isGlobalScopeAugmentation(enclosingDeclaration)));
33175                 }
33176                 function addResult(node, additionalModifierFlags) {
33177                     var newModifierFlags = 0;
33178                     if (additionalModifierFlags & 1 &&
33179                         enclosingDeclaration &&
33180                         isExportingScope(enclosingDeclaration) &&
33181                         canHaveExportModifier(node)) {
33182                         newModifierFlags |= 1;
33183                     }
33184                     if (addingDeclare && !(newModifierFlags & 1) &&
33185                         (!enclosingDeclaration || !(enclosingDeclaration.flags & 8388608)) &&
33186                         (ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) {
33187                         newModifierFlags |= 2;
33188                     }
33189                     if ((additionalModifierFlags & 512) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) {
33190                         newModifierFlags |= 512;
33191                     }
33192                     if (newModifierFlags) {
33193                         node.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(newModifierFlags | ts.getModifierFlags(node)));
33194                         node.modifierFlagsCache = 0;
33195                     }
33196                     results.push(node);
33197                 }
33198                 function serializeTypeAlias(symbol, symbolName, modifierFlags) {
33199                     var aliasType = getDeclaredTypeOfTypeAlias(symbol);
33200                     var typeParams = getSymbolLinks(symbol).typeParameters;
33201                     var typeParamDecls = ts.map(typeParams, function (p) { return typeParameterToDeclaration(p, context); });
33202                     var jsdocAliasDecl = ts.find(symbol.declarations, ts.isJSDocTypeAlias);
33203                     var commentText = jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined;
33204                     var oldFlags = context.flags;
33205                     context.flags |= 8388608;
33206                     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);
33207                     context.flags = oldFlags;
33208                 }
33209                 function serializeInterface(symbol, symbolName, modifierFlags) {
33210                     var interfaceType = getDeclaredTypeOfClassOrInterface(symbol);
33211                     var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
33212                     var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); });
33213                     var baseTypes = getBaseTypes(interfaceType);
33214                     var baseType = ts.length(baseTypes) ? getIntersectionType(baseTypes) : undefined;
33215                     var members = ts.flatMap(getPropertiesOfType(interfaceType), function (p) { return serializePropertySymbolForInterface(p, baseType); });
33216                     var callSignatures = serializeSignatures(0, interfaceType, baseType, 165);
33217                     var constructSignatures = serializeSignatures(1, interfaceType, baseType, 166);
33218                     var indexSignatures = serializeIndexSignatures(interfaceType, baseType);
33219                     var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.createHeritageClause(90, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b); }))];
33220                     addResult(ts.createInterfaceDeclaration(undefined, undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArrays(indexSignatures, constructSignatures, callSignatures, members)), modifierFlags);
33221                 }
33222                 function getNamespaceMembersForSerialization(symbol) {
33223                     return !symbol.exports ? [] : ts.filter(ts.arrayFrom(symbol.exports.values()), isNamespaceMember);
33224                 }
33225                 function isTypeOnlyNamespace(symbol) {
33226                     return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551); });
33227                 }
33228                 function serializeModule(symbol, symbolName, modifierFlags) {
33229                     var members = getNamespaceMembersForSerialization(symbol);
33230                     var locationMap = ts.arrayToMultiMap(members, function (m) { return m.parent && m.parent === symbol ? "real" : "merged"; });
33231                     var realMembers = locationMap.get("real") || ts.emptyArray;
33232                     var mergedMembers = locationMap.get("merged") || ts.emptyArray;
33233                     if (ts.length(realMembers)) {
33234                         var localName = getInternalSymbolName(symbol, symbolName);
33235                         serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 | 67108864)));
33236                     }
33237                     if (ts.length(mergedMembers)) {
33238                         var containingFile_1 = ts.getSourceFileOfNode(context.enclosingDeclaration);
33239                         var localName = getInternalSymbolName(symbol, symbolName);
33240                         var nsBody = ts.createModuleBlock([ts.createExportDeclaration(undefined, undefined, ts.createNamedExports(ts.mapDefined(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export="; }), function (s) {
33241                                 var _a, _b;
33242                                 var name = ts.unescapeLeadingUnderscores(s.escapedName);
33243                                 var localName = getInternalSymbolName(s, name);
33244                                 var aliasDecl = s.declarations && getDeclarationOfAliasSymbol(s);
33245                                 if (containingFile_1 && (aliasDecl ? containingFile_1 !== ts.getSourceFileOfNode(aliasDecl) : !ts.some(s.declarations, function (d) { return ts.getSourceFileOfNode(d) === containingFile_1; }))) {
33246                                     (_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);
33247                                     return undefined;
33248                                 }
33249                                 var target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, true);
33250                                 includePrivateSymbol(target || s);
33251                                 var targetName = target ? getInternalSymbolName(target, ts.unescapeLeadingUnderscores(target.escapedName)) : localName;
33252                                 return ts.createExportSpecifier(name === targetName ? undefined : targetName, name);
33253                             })))]);
33254                         addResult(ts.createModuleDeclaration(undefined, undefined, ts.createIdentifier(localName), nsBody, 16), 0);
33255                     }
33256                 }
33257                 function serializeEnum(symbol, symbolName, modifierFlags) {
33258                     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) {
33259                         var initializedValue = p.declarations && p.declarations[0] && ts.isEnumMember(p.declarations[0]) && getConstantValue(p.declarations[0]);
33260                         return ts.createEnumMember(ts.unescapeLeadingUnderscores(p.escapedName), initializedValue === undefined ? undefined : ts.createLiteral(initializedValue));
33261                     })), modifierFlags);
33262                 }
33263                 function serializeVariableOrProperty(symbol, symbolName, isPrivate, needsPostExportDefault, propertyAsAlias, modifierFlags) {
33264                     if (propertyAsAlias) {
33265                         serializeMaybeAliasAssignment(symbol);
33266                     }
33267                     else {
33268                         var type = getTypeOfSymbol(symbol);
33269                         var localName = getInternalSymbolName(symbol, symbolName);
33270                         if (!(symbol.flags & 16) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) {
33271                             serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags);
33272                         }
33273                         else {
33274                             var flags = !(symbol.flags & 2) ? undefined
33275                                 : isConstVariable(symbol) ? 2
33276                                     : 1;
33277                             var name = (needsPostExportDefault || !(symbol.flags & 4)) ? localName : getUnusedName(localName, symbol);
33278                             var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); });
33279                             if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) {
33280                                 textRange = textRange.parent.parent;
33281                             }
33282                             var statement = ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
33283                                 ts.createVariableDeclaration(name, serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled))
33284                             ], flags)), textRange);
33285                             addResult(statement, name !== localName ? modifierFlags & ~1 : modifierFlags);
33286                             if (name !== localName && !isPrivate) {
33287                                 addResult(ts.createExportDeclaration(undefined, undefined, ts.createNamedExports([ts.createExportSpecifier(name, localName)])), 0);
33288                             }
33289                         }
33290                     }
33291                 }
33292                 function serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags) {
33293                     var signatures = getSignaturesOfType(type, 0);
33294                     for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) {
33295                         var sig = signatures_2[_i];
33296                         var decl = signatureToSignatureDeclarationHelper(sig, 244, context, includePrivateSymbol, bundled);
33297                         decl.name = ts.createIdentifier(localName);
33298                         addResult(ts.setTextRange(decl, sig.declaration && ts.isVariableDeclaration(sig.declaration.parent) && sig.declaration.parent.parent || sig.declaration), modifierFlags);
33299                     }
33300                     if (!(symbol.flags & (512 | 1024) && !!symbol.exports && !!symbol.exports.size)) {
33301                         var props = ts.filter(getPropertiesOfType(type), isNamespaceMember);
33302                         serializeAsNamespaceDeclaration(props, localName, modifierFlags, true);
33303                     }
33304                 }
33305                 function serializeAsNamespaceDeclaration(props, localName, modifierFlags, suppressNewPrivateContext) {
33306                     if (ts.length(props)) {
33307                         var localVsRemoteMap = ts.arrayToMultiMap(props, function (p) {
33308                             return !ts.length(p.declarations) || ts.some(p.declarations, function (d) {
33309                                 return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(context.enclosingDeclaration);
33310                             }) ? "local" : "remote";
33311                         });
33312                         var localProps = localVsRemoteMap.get("local") || ts.emptyArray;
33313                         var fakespace = ts.createModuleDeclaration(undefined, undefined, ts.createIdentifier(localName), ts.createModuleBlock([]), 16);
33314                         fakespace.flags ^= 8;
33315                         fakespace.parent = enclosingDeclaration;
33316                         fakespace.locals = ts.createSymbolTable(props);
33317                         fakespace.symbol = props[0].parent;
33318                         var oldResults = results;
33319                         results = [];
33320                         var oldAddingDeclare = addingDeclare;
33321                         addingDeclare = false;
33322                         var subcontext = __assign(__assign({}, context), { enclosingDeclaration: fakespace });
33323                         var oldContext = context;
33324                         context = subcontext;
33325                         visitSymbolTable(ts.createSymbolTable(localProps), suppressNewPrivateContext, true);
33326                         context = oldContext;
33327                         addingDeclare = oldAddingDeclare;
33328                         var declarations = results;
33329                         results = oldResults;
33330                         fakespace.flags ^= 8;
33331                         fakespace.parent = undefined;
33332                         fakespace.locals = undefined;
33333                         fakespace.symbol = undefined;
33334                         fakespace.body = ts.createModuleBlock(declarations);
33335                         addResult(fakespace, modifierFlags);
33336                     }
33337                 }
33338                 function isNamespaceMember(p) {
33339                     return !(p.flags & 4194304 || p.escapedName === "prototype" || p.valueDeclaration && ts.isClassLike(p.valueDeclaration.parent));
33340                 }
33341                 function serializeAsClass(symbol, localName, modifierFlags) {
33342                     var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
33343                     var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); });
33344                     var classType = getDeclaredTypeOfClassOrInterface(symbol);
33345                     var baseTypes = getBaseTypes(classType);
33346                     var implementsTypes = getImplementsTypes(classType);
33347                     var staticType = getTypeOfSymbol(symbol);
33348                     var staticBaseType = getBaseConstructorTypeOfClass(staticType);
33349                     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); }))]);
33350                     var symbolProps = getNonInterhitedProperties(classType, baseTypes, getPropertiesOfType(classType));
33351                     var publicSymbolProps = ts.filter(symbolProps, function (s) {
33352                         var valueDecl = s.valueDeclaration;
33353                         return valueDecl && !(ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name));
33354                     });
33355                     var hasPrivateIdentifier = ts.some(symbolProps, function (s) {
33356                         var valueDecl = s.valueDeclaration;
33357                         return valueDecl && ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name);
33358                     });
33359                     var privateProperties = hasPrivateIdentifier ?
33360                         [ts.createProperty(undefined, undefined, ts.createPrivateIdentifier("#private"), undefined, undefined, undefined)] :
33361                         ts.emptyArray;
33362                     var publicProperties = ts.flatMap(publicSymbolProps, function (p) { return serializePropertySymbolForClass(p, false, baseTypes[0]); });
33363                     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); });
33364                     var constructors = serializeSignatures(1, staticType, baseTypes[0], 162);
33365                     for (var _i = 0, constructors_1 = constructors; _i < constructors_1.length; _i++) {
33366                         var c = constructors_1[_i];
33367                         c.type = undefined;
33368                         c.typeParameters = undefined;
33369                     }
33370                     var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]);
33371                     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);
33372                 }
33373                 function serializeAsAlias(symbol, localName, modifierFlags) {
33374                     var node = getDeclarationOfAliasSymbol(symbol);
33375                     if (!node)
33376                         return ts.Debug.fail();
33377                     var target = getMergedSymbol(getTargetOfAliasDeclaration(node, true));
33378                     if (!target) {
33379                         return;
33380                     }
33381                     var verbatimTargetName = ts.unescapeLeadingUnderscores(target.escapedName);
33382                     if (verbatimTargetName === "export=" && (compilerOptions.esModuleInterop || compilerOptions.allowSyntheticDefaultImports)) {
33383                         verbatimTargetName = "default";
33384                     }
33385                     var targetName = getInternalSymbolName(target, verbatimTargetName);
33386                     includePrivateSymbol(target);
33387                     switch (node.kind) {
33388                         case 253:
33389                             var isLocalImport = !(target.flags & 512);
33390                             addResult(ts.createImportEqualsDeclaration(undefined, undefined, ts.createIdentifier(localName), isLocalImport
33391                                 ? symbolToName(target, context, 67108863, false)
33392                                 : ts.createExternalModuleReference(ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)))), isLocalImport ? modifierFlags : 0);
33393                             break;
33394                         case 252:
33395                             addResult(ts.createNamespaceExportDeclaration(ts.idText(node.name)), 0);
33396                             break;
33397                         case 255:
33398                             addResult(ts.createImportDeclaration(undefined, undefined, ts.createImportClause(ts.createIdentifier(localName), undefined), ts.createLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0);
33399                             break;
33400                         case 256:
33401                             addResult(ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamespaceImport(ts.createIdentifier(localName))), ts.createLiteral(getSpecifierForModuleSymbol(target, context))), 0);
33402                             break;
33403                         case 262:
33404                             addResult(ts.createExportDeclaration(undefined, undefined, ts.createNamespaceExport(ts.createIdentifier(localName)), ts.createLiteral(getSpecifierForModuleSymbol(target, context))), 0);
33405                             break;
33406                         case 258:
33407                             addResult(ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamedImports([
33408                                 ts.createImportSpecifier(localName !== verbatimTargetName ? ts.createIdentifier(verbatimTargetName) : undefined, ts.createIdentifier(localName))
33409                             ])), ts.createLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0);
33410                             break;
33411                         case 263:
33412                             var specifier = node.parent.parent.moduleSpecifier;
33413                             serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.createLiteral(specifier.text) : undefined);
33414                             break;
33415                         case 259:
33416                             serializeMaybeAliasAssignment(symbol);
33417                             break;
33418                         case 209:
33419                         case 194:
33420                             if (symbol.escapedName === "default" || symbol.escapedName === "export=") {
33421                                 serializeMaybeAliasAssignment(symbol);
33422                             }
33423                             else {
33424                                 serializeExportSpecifier(localName, targetName);
33425                             }
33426                             break;
33427                         default:
33428                             return ts.Debug.failBadSyntaxKind(node, "Unhandled alias declaration kind in symbol serializer!");
33429                     }
33430                 }
33431                 function serializeExportSpecifier(localName, targetName, specifier) {
33432                     addResult(ts.createExportDeclaration(undefined, undefined, ts.createNamedExports([ts.createExportSpecifier(localName !== targetName ? targetName : undefined, localName)]), specifier), 0);
33433                 }
33434                 function serializeMaybeAliasAssignment(symbol) {
33435                     if (symbol.flags & 4194304) {
33436                         return;
33437                     }
33438                     var name = ts.unescapeLeadingUnderscores(symbol.escapedName);
33439                     var isExportEquals = name === "export=";
33440                     var isDefault = name === "default";
33441                     var isExportAssignment = isExportEquals || isDefault;
33442                     var aliasDecl = symbol.declarations && getDeclarationOfAliasSymbol(symbol);
33443                     var target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, true);
33444                     if (target && ts.length(target.declarations) && ts.some(target.declarations, function (d) { return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(enclosingDeclaration); })) {
33445                         var expr = isExportAssignment ? ts.getExportAssignmentExpression(aliasDecl) : ts.getPropertyAssignmentAliasLikeExpression(aliasDecl);
33446                         var first_1 = ts.isEntityNameExpression(expr) ? getFirstNonModuleExportsIdentifier(expr) : undefined;
33447                         var referenced = first_1 && resolveEntityName(first_1, 67108863, true, true, enclosingDeclaration);
33448                         if (referenced || target) {
33449                             includePrivateSymbol(referenced || target);
33450                         }
33451                         var oldTrack = context.tracker.trackSymbol;
33452                         context.tracker.trackSymbol = ts.noop;
33453                         if (isExportAssignment) {
33454                             results.push(ts.createExportAssignment(undefined, undefined, isExportEquals, symbolToExpression(target, context, 67108863)));
33455                         }
33456                         else {
33457                             if (first_1 === expr) {
33458                                 serializeExportSpecifier(name, ts.idText(first_1));
33459                             }
33460                             else if (ts.isClassExpression(expr)) {
33461                                 serializeExportSpecifier(name, getInternalSymbolName(target, ts.symbolName(target)));
33462                             }
33463                             else {
33464                                 var varName = getUnusedName(name, symbol);
33465                                 addResult(ts.createImportEqualsDeclaration(undefined, undefined, ts.createIdentifier(varName), symbolToName(target, context, 67108863, false)), 0);
33466                                 serializeExportSpecifier(name, varName);
33467                             }
33468                         }
33469                         context.tracker.trackSymbol = oldTrack;
33470                     }
33471                     else {
33472                         var varName = getUnusedName(name, symbol);
33473                         var typeToSerialize = getWidenedType(getTypeOfSymbol(getMergedSymbol(symbol)));
33474                         if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) {
33475                             serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignment ? 0 : 1);
33476                         }
33477                         else {
33478                             var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
33479                                 ts.createVariableDeclaration(varName, serializeTypeForDeclaration(context, typeToSerialize, symbol, enclosingDeclaration, includePrivateSymbol, bundled))
33480                             ], 2));
33481                             addResult(statement, name === varName ? 1 : 0);
33482                         }
33483                         if (isExportAssignment) {
33484                             results.push(ts.createExportAssignment(undefined, undefined, isExportEquals, ts.createIdentifier(varName)));
33485                         }
33486                         else if (name !== varName) {
33487                             serializeExportSpecifier(name, varName);
33488                         }
33489                     }
33490                 }
33491                 function isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, hostSymbol) {
33492                     var ctxSrc = ts.getSourceFileOfNode(context.enclosingDeclaration);
33493                     return ts.getObjectFlags(typeToSerialize) & (16 | 32) &&
33494                         !getIndexInfoOfType(typeToSerialize, 0) &&
33495                         !getIndexInfoOfType(typeToSerialize, 1) &&
33496                         !!(ts.length(getPropertiesOfType(typeToSerialize)) || ts.length(getSignaturesOfType(typeToSerialize, 0))) &&
33497                         !ts.length(getSignaturesOfType(typeToSerialize, 1)) &&
33498                         !getDeclarationWithTypeAnnotation(hostSymbol, enclosingDeclaration) &&
33499                         !(typeToSerialize.symbol && ts.some(typeToSerialize.symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; })) &&
33500                         !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return isLateBoundName(p.escapedName); }) &&
33501                         !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return ts.some(p.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; }); }) &&
33502                         ts.every(getPropertiesOfType(typeToSerialize), function (p) { return ts.isIdentifierText(ts.symbolName(p), languageVersion) && !ts.isStringAKeyword(ts.symbolName(p)); });
33503                 }
33504                 function makeSerializePropertySymbol(createProperty, methodKind, useAccessors) {
33505                     return function serializePropertySymbol(p, isStatic, baseType) {
33506                         var modifierFlags = ts.getDeclarationModifierFlagsFromSymbol(p);
33507                         var isPrivate = !!(modifierFlags & 8);
33508                         if (isStatic && (p.flags & (788968 | 1920 | 2097152))) {
33509                             return [];
33510                         }
33511                         if (p.flags & 4194304 ||
33512                             (baseType && getPropertyOfType(baseType, p.escapedName)
33513                                 && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p)
33514                                 && (p.flags & 16777216) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216)
33515                                 && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) {
33516                             return [];
33517                         }
33518                         var flag = (modifierFlags & ~256) | (isStatic ? 32 : 0);
33519                         var name = getPropertyNameNodeForSymbol(p, context);
33520                         var firstPropertyLikeDecl = ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression));
33521                         if (p.flags & 98304 && useAccessors) {
33522                             var result = [];
33523                             if (p.flags & 65536) {
33524                                 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));
33525                             }
33526                             if (p.flags & 32768) {
33527                                 var isPrivate_1 = modifierFlags & 8;
33528                                 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));
33529                             }
33530                             return result;
33531                         }
33532                         else if (p.flags & (4 | 3)) {
33533                             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);
33534                         }
33535                         if (p.flags & (8192 | 16)) {
33536                             var type = getTypeOfSymbol(p);
33537                             var signatures = getSignaturesOfType(type, 0);
33538                             if (flag & 8) {
33539                                 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]);
33540                             }
33541                             var results_1 = [];
33542                             for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) {
33543                                 var sig = signatures_3[_i];
33544                                 var decl = signatureToSignatureDeclarationHelper(sig, methodKind, context);
33545                                 decl.name = name;
33546                                 if (flag) {
33547                                     decl.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(flag));
33548                                 }
33549                                 if (p.flags & 16777216) {
33550                                     decl.questionToken = ts.createToken(57);
33551                                 }
33552                                 results_1.push(ts.setTextRange(decl, sig.declaration));
33553                             }
33554                             return results_1;
33555                         }
33556                         return ts.Debug.fail("Unhandled class member kind! " + (p.__debugFlags || p.flags));
33557                     };
33558                 }
33559                 function serializePropertySymbolForInterface(p, baseType) {
33560                     return serializePropertySymbolForInterfaceWorker(p, false, baseType);
33561                 }
33562                 function serializeSignatures(kind, input, baseType, outputKind) {
33563                     var signatures = getSignaturesOfType(input, kind);
33564                     if (kind === 1) {
33565                         if (!baseType && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) {
33566                             return [];
33567                         }
33568                         if (baseType) {
33569                             var baseSigs = getSignaturesOfType(baseType, 1);
33570                             if (!ts.length(baseSigs) && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) {
33571                                 return [];
33572                             }
33573                             if (baseSigs.length === signatures.length) {
33574                                 var failed = false;
33575                                 for (var i = 0; i < baseSigs.length; i++) {
33576                                     if (!compareSignaturesIdentical(signatures[i], baseSigs[i], false, false, true, compareTypesIdentical)) {
33577                                         failed = true;
33578                                         break;
33579                                     }
33580                                 }
33581                                 if (!failed) {
33582                                     return [];
33583                                 }
33584                             }
33585                         }
33586                         var privateProtected = 0;
33587                         for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) {
33588                             var s = signatures_4[_i];
33589                             if (s.declaration) {
33590                                 privateProtected |= ts.getSelectedModifierFlags(s.declaration, 8 | 16);
33591                             }
33592                         }
33593                         if (privateProtected) {
33594                             return [ts.setTextRange(ts.createConstructor(undefined, ts.createModifiersFromModifierFlags(privateProtected), [], undefined), signatures[0].declaration)];
33595                         }
33596                     }
33597                     var results = [];
33598                     for (var _a = 0, signatures_5 = signatures; _a < signatures_5.length; _a++) {
33599                         var sig = signatures_5[_a];
33600                         var decl = signatureToSignatureDeclarationHelper(sig, outputKind, context);
33601                         results.push(ts.setTextRange(decl, sig.declaration));
33602                     }
33603                     return results;
33604                 }
33605                 function serializeIndexSignatures(input, baseType) {
33606                     var results = [];
33607                     for (var _i = 0, _a = [0, 1]; _i < _a.length; _i++) {
33608                         var type = _a[_i];
33609                         var info = getIndexInfoOfType(input, type);
33610                         if (info) {
33611                             if (baseType) {
33612                                 var baseInfo = getIndexInfoOfType(baseType, type);
33613                                 if (baseInfo) {
33614                                     if (isTypeIdenticalTo(info.type, baseInfo.type)) {
33615                                         continue;
33616                                     }
33617                                 }
33618                             }
33619                             results.push(indexInfoToIndexSignatureDeclarationHelper(info, type, context));
33620                         }
33621                     }
33622                     return results;
33623                 }
33624                 function serializeBaseType(t, staticType, rootName) {
33625                     var ref = trySerializeAsTypeReference(t);
33626                     if (ref) {
33627                         return ref;
33628                     }
33629                     var tempName = getUnusedName(rootName + "_base");
33630                     var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
33631                         ts.createVariableDeclaration(tempName, typeToTypeNodeHelper(staticType, context))
33632                     ], 2));
33633                     addResult(statement, 0);
33634                     return ts.createExpressionWithTypeArguments(undefined, ts.createIdentifier(tempName));
33635                 }
33636                 function trySerializeAsTypeReference(t) {
33637                     var typeArgs;
33638                     var reference;
33639                     if (t.target && getAccessibleSymbolChain(t.target.symbol, enclosingDeclaration, 111551, false)) {
33640                         typeArgs = ts.map(getTypeArguments(t), function (t) { return typeToTypeNodeHelper(t, context); });
33641                         reference = symbolToExpression(t.target.symbol, context, 788968);
33642                     }
33643                     else if (t.symbol && getAccessibleSymbolChain(t.symbol, enclosingDeclaration, 111551, false)) {
33644                         reference = symbolToExpression(t.symbol, context, 788968);
33645                     }
33646                     if (reference) {
33647                         return ts.createExpressionWithTypeArguments(typeArgs, reference);
33648                     }
33649                 }
33650                 function getUnusedName(input, symbol) {
33651                     if (symbol) {
33652                         if (context.remappedSymbolNames.has("" + getSymbolId(symbol))) {
33653                             return context.remappedSymbolNames.get("" + getSymbolId(symbol));
33654                         }
33655                     }
33656                     if (symbol) {
33657                         input = getNameCandidateWorker(symbol, input);
33658                     }
33659                     var i = 0;
33660                     var original = input;
33661                     while (context.usedSymbolNames.has(input)) {
33662                         i++;
33663                         input = original + "_" + i;
33664                     }
33665                     context.usedSymbolNames.set(input, true);
33666                     if (symbol) {
33667                         context.remappedSymbolNames.set("" + getSymbolId(symbol), input);
33668                     }
33669                     return input;
33670                 }
33671                 function getNameCandidateWorker(symbol, localName) {
33672                     if (localName === "default" || localName === "__class" || localName === "__function") {
33673                         var flags = context.flags;
33674                         context.flags |= 16777216;
33675                         var nameCandidate = getNameOfSymbolAsWritten(symbol, context);
33676                         context.flags = flags;
33677                         localName = nameCandidate.length > 0 && ts.isSingleOrDoubleQuote(nameCandidate.charCodeAt(0)) ? ts.stripQuotes(nameCandidate) : nameCandidate;
33678                     }
33679                     if (localName === "default") {
33680                         localName = "_default";
33681                     }
33682                     else if (localName === "export=") {
33683                         localName = "_exports";
33684                     }
33685                     localName = ts.isIdentifierText(localName, languageVersion) && !ts.isStringANonContextualKeyword(localName) ? localName : "_" + localName.replace(/[^a-zA-Z0-9]/g, "_");
33686                     return localName;
33687                 }
33688                 function getInternalSymbolName(symbol, localName) {
33689                     if (context.remappedSymbolNames.has("" + getSymbolId(symbol))) {
33690                         return context.remappedSymbolNames.get("" + getSymbolId(symbol));
33691                     }
33692                     localName = getNameCandidateWorker(symbol, localName);
33693                     context.remappedSymbolNames.set("" + getSymbolId(symbol), localName);
33694                     return localName;
33695                 }
33696             }
33697         }
33698         function typePredicateToString(typePredicate, enclosingDeclaration, flags, writer) {
33699             if (flags === void 0) { flags = 16384; }
33700             return writer ? typePredicateToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(typePredicateToStringWorker);
33701             function typePredicateToStringWorker(writer) {
33702                 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));
33703                 var printer = ts.createPrinter({ removeComments: true });
33704                 var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration);
33705                 printer.writeNode(4, predicate, sourceFile, writer);
33706                 return writer;
33707             }
33708         }
33709         function formatUnionTypes(types) {
33710             var result = [];
33711             var flags = 0;
33712             for (var i = 0; i < types.length; i++) {
33713                 var t = types[i];
33714                 flags |= t.flags;
33715                 if (!(t.flags & 98304)) {
33716                     if (t.flags & (512 | 1024)) {
33717                         var baseType = t.flags & 512 ? booleanType : getBaseTypeOfEnumLiteralType(t);
33718                         if (baseType.flags & 1048576) {
33719                             var count = baseType.types.length;
33720                             if (i + count <= types.length && getRegularTypeOfLiteralType(types[i + count - 1]) === getRegularTypeOfLiteralType(baseType.types[count - 1])) {
33721                                 result.push(baseType);
33722                                 i += count - 1;
33723                                 continue;
33724                             }
33725                         }
33726                     }
33727                     result.push(t);
33728                 }
33729             }
33730             if (flags & 65536)
33731                 result.push(nullType);
33732             if (flags & 32768)
33733                 result.push(undefinedType);
33734             return result || types;
33735         }
33736         function visibilityToString(flags) {
33737             if (flags === 8) {
33738                 return "private";
33739             }
33740             if (flags === 16) {
33741                 return "protected";
33742             }
33743             return "public";
33744         }
33745         function getTypeAliasForTypeLiteral(type) {
33746             if (type.symbol && type.symbol.flags & 2048) {
33747                 var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 182; });
33748                 if (node.kind === 247) {
33749                     return getSymbolOfNode(node);
33750                 }
33751             }
33752             return undefined;
33753         }
33754         function isTopLevelInExternalModuleAugmentation(node) {
33755             return node && node.parent &&
33756                 node.parent.kind === 250 &&
33757                 ts.isExternalModuleAugmentation(node.parent.parent);
33758         }
33759         function isDefaultBindingContext(location) {
33760             return location.kind === 290 || ts.isAmbientModule(location);
33761         }
33762         function getNameOfSymbolFromNameType(symbol, context) {
33763             var nameType = getSymbolLinks(symbol).nameType;
33764             if (nameType) {
33765                 if (nameType.flags & 384) {
33766                     var name = "" + nameType.value;
33767                     if (!ts.isIdentifierText(name, compilerOptions.target) && !isNumericLiteralName(name)) {
33768                         return "\"" + ts.escapeString(name, 34) + "\"";
33769                     }
33770                     if (isNumericLiteralName(name) && ts.startsWith(name, "-")) {
33771                         return "[" + name + "]";
33772                     }
33773                     return name;
33774                 }
33775                 if (nameType.flags & 8192) {
33776                     return "[" + getNameOfSymbolAsWritten(nameType.symbol, context) + "]";
33777                 }
33778             }
33779         }
33780         function getNameOfSymbolAsWritten(symbol, context) {
33781             if (context && symbol.escapedName === "default" && !(context.flags & 16384) &&
33782                 (!(context.flags & 16777216) ||
33783                     !symbol.declarations ||
33784                     (context.enclosingDeclaration && ts.findAncestor(symbol.declarations[0], isDefaultBindingContext) !== ts.findAncestor(context.enclosingDeclaration, isDefaultBindingContext)))) {
33785                 return "default";
33786             }
33787             if (symbol.declarations && symbol.declarations.length) {
33788                 var declaration = ts.firstDefined(symbol.declarations, function (d) { return ts.getNameOfDeclaration(d) ? d : undefined; });
33789                 var name_2 = declaration && ts.getNameOfDeclaration(declaration);
33790                 if (declaration && name_2) {
33791                     if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) {
33792                         return ts.symbolName(symbol);
33793                     }
33794                     if (ts.isComputedPropertyName(name_2) && !(ts.getCheckFlags(symbol) & 4096)) {
33795                         var nameType = getSymbolLinks(symbol).nameType;
33796                         if (nameType && nameType.flags & 384) {
33797                             var result = getNameOfSymbolFromNameType(symbol, context);
33798                             if (result !== undefined) {
33799                                 return result;
33800                             }
33801                         }
33802                     }
33803                     return ts.declarationNameToString(name_2);
33804                 }
33805                 if (!declaration) {
33806                     declaration = symbol.declarations[0];
33807                 }
33808                 if (declaration.parent && declaration.parent.kind === 242) {
33809                     return ts.declarationNameToString(declaration.parent.name);
33810                 }
33811                 switch (declaration.kind) {
33812                     case 214:
33813                     case 201:
33814                     case 202:
33815                         if (context && !context.encounteredError && !(context.flags & 131072)) {
33816                             context.encounteredError = true;
33817                         }
33818                         return declaration.kind === 214 ? "(Anonymous class)" : "(Anonymous function)";
33819                 }
33820             }
33821             var name = getNameOfSymbolFromNameType(symbol, context);
33822             return name !== undefined ? name : ts.symbolName(symbol);
33823         }
33824         function isDeclarationVisible(node) {
33825             if (node) {
33826                 var links = getNodeLinks(node);
33827                 if (links.isVisible === undefined) {
33828                     links.isVisible = !!determineIfDeclarationIsVisible();
33829                 }
33830                 return links.isVisible;
33831             }
33832             return false;
33833             function determineIfDeclarationIsVisible() {
33834                 switch (node.kind) {
33835                     case 315:
33836                     case 322:
33837                     case 316:
33838                         return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent));
33839                     case 191:
33840                         return isDeclarationVisible(node.parent.parent);
33841                     case 242:
33842                         if (ts.isBindingPattern(node.name) &&
33843                             !node.name.elements.length) {
33844                             return false;
33845                         }
33846                     case 249:
33847                     case 245:
33848                     case 246:
33849                     case 247:
33850                     case 244:
33851                     case 248:
33852                     case 253:
33853                         if (ts.isExternalModuleAugmentation(node)) {
33854                             return true;
33855                         }
33856                         var parent = getDeclarationContainer(node);
33857                         if (!(ts.getCombinedModifierFlags(node) & 1) &&
33858                             !(node.kind !== 253 && parent.kind !== 290 && parent.flags & 8388608)) {
33859                             return isGlobalSourceFile(parent);
33860                         }
33861                         return isDeclarationVisible(parent);
33862                     case 159:
33863                     case 158:
33864                     case 163:
33865                     case 164:
33866                     case 161:
33867                     case 160:
33868                         if (ts.hasModifier(node, 8 | 16)) {
33869                             return false;
33870                         }
33871                     case 162:
33872                     case 166:
33873                     case 165:
33874                     case 167:
33875                     case 156:
33876                     case 250:
33877                     case 170:
33878                     case 171:
33879                     case 173:
33880                     case 169:
33881                     case 174:
33882                     case 175:
33883                     case 178:
33884                     case 179:
33885                     case 182:
33886                         return isDeclarationVisible(node.parent);
33887                     case 255:
33888                     case 256:
33889                     case 258:
33890                         return false;
33891                     case 155:
33892                     case 290:
33893                     case 252:
33894                         return true;
33895                     case 259:
33896                         return false;
33897                     default:
33898                         return false;
33899                 }
33900             }
33901         }
33902         function collectLinkedAliases(node, setVisibility) {
33903             var exportSymbol;
33904             if (node.parent && node.parent.kind === 259) {
33905                 exportSymbol = resolveName(node, node.escapedText, 111551 | 788968 | 1920 | 2097152, undefined, node, false);
33906             }
33907             else if (node.parent.kind === 263) {
33908                 exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 | 788968 | 1920 | 2097152);
33909             }
33910             var result;
33911             var visited;
33912             if (exportSymbol) {
33913                 visited = ts.createMap();
33914                 visited.set("" + getSymbolId(exportSymbol), true);
33915                 buildVisibleNodeList(exportSymbol.declarations);
33916             }
33917             return result;
33918             function buildVisibleNodeList(declarations) {
33919                 ts.forEach(declarations, function (declaration) {
33920                     var resultNode = getAnyImportSyntax(declaration) || declaration;
33921                     if (setVisibility) {
33922                         getNodeLinks(declaration).isVisible = true;
33923                     }
33924                     else {
33925                         result = result || [];
33926                         ts.pushIfUnique(result, resultNode);
33927                     }
33928                     if (ts.isInternalModuleImportEqualsDeclaration(declaration)) {
33929                         var internalModuleReference = declaration.moduleReference;
33930                         var firstIdentifier = ts.getFirstIdentifier(internalModuleReference);
33931                         var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 | 788968 | 1920, undefined, undefined, false);
33932                         var id = importSymbol && "" + getSymbolId(importSymbol);
33933                         if (importSymbol && !visited.has(id)) {
33934                             visited.set(id, true);
33935                             buildVisibleNodeList(importSymbol.declarations);
33936                         }
33937                     }
33938                 });
33939             }
33940         }
33941         function pushTypeResolution(target, propertyName) {
33942             var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName);
33943             if (resolutionCycleStartIndex >= 0) {
33944                 var length_3 = resolutionTargets.length;
33945                 for (var i = resolutionCycleStartIndex; i < length_3; i++) {
33946                     resolutionResults[i] = false;
33947                 }
33948                 return false;
33949             }
33950             resolutionTargets.push(target);
33951             resolutionResults.push(true);
33952             resolutionPropertyNames.push(propertyName);
33953             return true;
33954         }
33955         function findResolutionCycleStartIndex(target, propertyName) {
33956             for (var i = resolutionTargets.length - 1; i >= 0; i--) {
33957                 if (hasType(resolutionTargets[i], resolutionPropertyNames[i])) {
33958                     return -1;
33959                 }
33960                 if (resolutionTargets[i] === target && resolutionPropertyNames[i] === propertyName) {
33961                     return i;
33962                 }
33963             }
33964             return -1;
33965         }
33966         function hasType(target, propertyName) {
33967             switch (propertyName) {
33968                 case 0:
33969                     return !!getSymbolLinks(target).type;
33970                 case 5:
33971                     return !!(getNodeLinks(target).resolvedEnumType);
33972                 case 2:
33973                     return !!getSymbolLinks(target).declaredType;
33974                 case 1:
33975                     return !!target.resolvedBaseConstructorType;
33976                 case 3:
33977                     return !!target.resolvedReturnType;
33978                 case 4:
33979                     return !!target.immediateBaseConstraint;
33980                 case 6:
33981                     return !!target.resolvedTypeArguments;
33982             }
33983             return ts.Debug.assertNever(propertyName);
33984         }
33985         function popTypeResolution() {
33986             resolutionTargets.pop();
33987             resolutionPropertyNames.pop();
33988             return resolutionResults.pop();
33989         }
33990         function getDeclarationContainer(node) {
33991             return ts.findAncestor(ts.getRootDeclaration(node), function (node) {
33992                 switch (node.kind) {
33993                     case 242:
33994                     case 243:
33995                     case 258:
33996                     case 257:
33997                     case 256:
33998                     case 255:
33999                         return false;
34000                     default:
34001                         return true;
34002                 }
34003             }).parent;
34004         }
34005         function getTypeOfPrototypeProperty(prototype) {
34006             var classType = getDeclaredTypeOfSymbol(getParentOfSymbol(prototype));
34007             return classType.typeParameters ? createTypeReference(classType, ts.map(classType.typeParameters, function (_) { return anyType; })) : classType;
34008         }
34009         function getTypeOfPropertyOfType(type, name) {
34010             var prop = getPropertyOfType(type, name);
34011             return prop ? getTypeOfSymbol(prop) : undefined;
34012         }
34013         function getTypeOfPropertyOrIndexSignature(type, name) {
34014             return getTypeOfPropertyOfType(type, name) || isNumericLiteralName(name) && getIndexTypeOfType(type, 1) || getIndexTypeOfType(type, 0) || unknownType;
34015         }
34016         function isTypeAny(type) {
34017             return type && (type.flags & 1) !== 0;
34018         }
34019         function getTypeForBindingElementParent(node) {
34020             var symbol = getSymbolOfNode(node);
34021             return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false);
34022         }
34023         function getRestType(source, properties, symbol) {
34024             source = filterType(source, function (t) { return !(t.flags & 98304); });
34025             if (source.flags & 131072) {
34026                 return emptyObjectType;
34027             }
34028             if (source.flags & 1048576) {
34029                 return mapType(source, function (t) { return getRestType(t, properties, symbol); });
34030             }
34031             var omitKeyType = getUnionType(ts.map(properties, getLiteralTypeFromPropertyName));
34032             if (isGenericObjectType(source) || isGenericIndexType(omitKeyType)) {
34033                 if (omitKeyType.flags & 131072) {
34034                     return source;
34035                 }
34036                 var omitTypeAlias = getGlobalOmitSymbol();
34037                 if (!omitTypeAlias) {
34038                     return errorType;
34039                 }
34040                 return getTypeAliasInstantiation(omitTypeAlias, [source, omitKeyType]);
34041             }
34042             var members = ts.createSymbolTable();
34043             for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) {
34044                 var prop = _a[_i];
34045                 if (!isTypeAssignableTo(getLiteralTypeFromProperty(prop, 8576), omitKeyType)
34046                     && !(ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 | 16))
34047                     && isSpreadableProperty(prop)) {
34048                     members.set(prop.escapedName, getSpreadSymbol(prop, false));
34049                 }
34050             }
34051             var stringIndexInfo = getIndexInfoOfType(source, 0);
34052             var numberIndexInfo = getIndexInfoOfType(source, 1);
34053             var result = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo);
34054             result.objectFlags |= 131072;
34055             return result;
34056         }
34057         function getFlowTypeOfDestructuring(node, declaredType) {
34058             var reference = getSyntheticElementAccess(node);
34059             return reference ? getFlowTypeOfReference(reference, declaredType) : declaredType;
34060         }
34061         function getSyntheticElementAccess(node) {
34062             var parentAccess = getParentElementAccess(node);
34063             if (parentAccess && parentAccess.flowNode) {
34064                 var propName = getDestructuringPropertyName(node);
34065                 if (propName) {
34066                     var result = ts.createNode(195, node.pos, node.end);
34067                     result.parent = node;
34068                     result.expression = parentAccess;
34069                     var literal = ts.createNode(10, node.pos, node.end);
34070                     literal.parent = result;
34071                     literal.text = propName;
34072                     result.argumentExpression = literal;
34073                     result.flowNode = parentAccess.flowNode;
34074                     return result;
34075                 }
34076             }
34077         }
34078         function getParentElementAccess(node) {
34079             var ancestor = node.parent.parent;
34080             switch (ancestor.kind) {
34081                 case 191:
34082                 case 281:
34083                     return getSyntheticElementAccess(ancestor);
34084                 case 192:
34085                     return getSyntheticElementAccess(node.parent);
34086                 case 242:
34087                     return ancestor.initializer;
34088                 case 209:
34089                     return ancestor.right;
34090             }
34091         }
34092         function getDestructuringPropertyName(node) {
34093             var parent = node.parent;
34094             if (node.kind === 191 && parent.kind === 189) {
34095                 return getLiteralPropertyNameText(node.propertyName || node.name);
34096             }
34097             if (node.kind === 281 || node.kind === 282) {
34098                 return getLiteralPropertyNameText(node.name);
34099             }
34100             return "" + parent.elements.indexOf(node);
34101         }
34102         function getLiteralPropertyNameText(name) {
34103             var type = getLiteralTypeFromPropertyName(name);
34104             return type.flags & (128 | 256) ? "" + type.value : undefined;
34105         }
34106         function getTypeForBindingElement(declaration) {
34107             var pattern = declaration.parent;
34108             var parentType = getTypeForBindingElementParent(pattern.parent);
34109             if (!parentType || isTypeAny(parentType)) {
34110                 return parentType;
34111             }
34112             if (strictNullChecks && declaration.flags & 8388608 && ts.isParameterDeclaration(declaration)) {
34113                 parentType = getNonNullableType(parentType);
34114             }
34115             else if (strictNullChecks && pattern.parent.initializer && !(getTypeFacts(getTypeOfInitializer(pattern.parent.initializer)) & 65536)) {
34116                 parentType = getTypeWithFacts(parentType, 524288);
34117             }
34118             var type;
34119             if (pattern.kind === 189) {
34120                 if (declaration.dotDotDotToken) {
34121                     parentType = getReducedType(parentType);
34122                     if (parentType.flags & 2 || !isValidSpreadType(parentType)) {
34123                         error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types);
34124                         return errorType;
34125                     }
34126                     var literalMembers = [];
34127                     for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
34128                         var element = _a[_i];
34129                         if (!element.dotDotDotToken) {
34130                             literalMembers.push(element.propertyName || element.name);
34131                         }
34132                     }
34133                     type = getRestType(parentType, literalMembers, declaration.symbol);
34134                 }
34135                 else {
34136                     var name = declaration.propertyName || declaration.name;
34137                     var indexType = getLiteralTypeFromPropertyName(name);
34138                     var declaredType = getConstraintForLocation(getIndexedAccessType(parentType, indexType, name), declaration.name);
34139                     type = getFlowTypeOfDestructuring(declaration, declaredType);
34140                 }
34141             }
34142             else {
34143                 var elementType = checkIteratedTypeOrElementType(65, parentType, undefinedType, pattern);
34144                 var index_1 = pattern.elements.indexOf(declaration);
34145                 if (declaration.dotDotDotToken) {
34146                     type = everyType(parentType, isTupleType) ?
34147                         mapType(parentType, function (t) { return sliceTupleType(t, index_1); }) :
34148                         createArrayType(elementType);
34149                 }
34150                 else if (isArrayLikeType(parentType)) {
34151                     var indexType = getLiteralType(index_1);
34152                     var accessFlags = hasDefaultValue(declaration) ? 8 : 0;
34153                     var declaredType = getConstraintForLocation(getIndexedAccessTypeOrUndefined(parentType, indexType, declaration.name, accessFlags) || errorType, declaration.name);
34154                     type = getFlowTypeOfDestructuring(declaration, declaredType);
34155                 }
34156                 else {
34157                     type = elementType;
34158                 }
34159             }
34160             if (!declaration.initializer) {
34161                 return type;
34162             }
34163             if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) {
34164                 return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768) ?
34165                     getTypeWithFacts(type, 524288) :
34166                     type;
34167             }
34168             return widenTypeInferredFromInitializer(declaration, getUnionType([getTypeWithFacts(type, 524288), checkDeclarationInitializer(declaration)], 2));
34169         }
34170         function getTypeForDeclarationFromJSDocComment(declaration) {
34171             var jsdocType = ts.getJSDocType(declaration);
34172             if (jsdocType) {
34173                 return getTypeFromTypeNode(jsdocType);
34174             }
34175             return undefined;
34176         }
34177         function isNullOrUndefined(node) {
34178             var expr = ts.skipParentheses(node);
34179             return expr.kind === 100 || expr.kind === 75 && getResolvedSymbol(expr) === undefinedSymbol;
34180         }
34181         function isEmptyArrayLiteral(node) {
34182             var expr = ts.skipParentheses(node);
34183             return expr.kind === 192 && expr.elements.length === 0;
34184         }
34185         function addOptionality(type, optional) {
34186             if (optional === void 0) { optional = true; }
34187             return strictNullChecks && optional ? getOptionalType(type) : type;
34188         }
34189         function getTypeForVariableLikeDeclaration(declaration, includeOptionality) {
34190             if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 231) {
34191                 var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression)));
34192                 return indexType.flags & (262144 | 4194304) ? getExtractStringType(indexType) : stringType;
34193             }
34194             if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 232) {
34195                 var forOfStatement = declaration.parent.parent;
34196                 return checkRightHandSideOfForOf(forOfStatement) || anyType;
34197             }
34198             if (ts.isBindingPattern(declaration.parent)) {
34199                 return getTypeForBindingElement(declaration);
34200             }
34201             var isOptional = includeOptionality && (ts.isParameter(declaration) && isJSDocOptionalParameter(declaration)
34202                 || !ts.isBindingElement(declaration) && !ts.isVariableDeclaration(declaration) && !!declaration.questionToken);
34203             var declaredType = tryGetTypeFromEffectiveTypeNode(declaration);
34204             if (declaredType) {
34205                 return addOptionality(declaredType, isOptional);
34206             }
34207             if ((noImplicitAny || ts.isInJSFile(declaration)) &&
34208                 declaration.kind === 242 && !ts.isBindingPattern(declaration.name) &&
34209                 !(ts.getCombinedModifierFlags(declaration) & 1) && !(declaration.flags & 8388608)) {
34210                 if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) {
34211                     return autoType;
34212                 }
34213                 if (declaration.initializer && isEmptyArrayLiteral(declaration.initializer)) {
34214                     return autoArrayType;
34215                 }
34216             }
34217             if (declaration.kind === 156) {
34218                 var func = declaration.parent;
34219                 if (func.kind === 164 && !hasNonBindableDynamicName(func)) {
34220                     var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 163);
34221                     if (getter) {
34222                         var getterSignature = getSignatureFromDeclaration(getter);
34223                         var thisParameter = getAccessorThisParameter(func);
34224                         if (thisParameter && declaration === thisParameter) {
34225                             ts.Debug.assert(!thisParameter.type);
34226                             return getTypeOfSymbol(getterSignature.thisParameter);
34227                         }
34228                         return getReturnTypeOfSignature(getterSignature);
34229                     }
34230                 }
34231                 if (ts.isInJSFile(declaration)) {
34232                     var typeTag = ts.getJSDocType(func);
34233                     if (typeTag && ts.isFunctionTypeNode(typeTag)) {
34234                         return getTypeAtPosition(getSignatureFromDeclaration(typeTag), func.parameters.indexOf(declaration));
34235                     }
34236                 }
34237                 var type = declaration.symbol.escapedName === "this" ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration);
34238                 if (type) {
34239                     return addOptionality(type, isOptional);
34240                 }
34241             }
34242             else if (ts.isInJSFile(declaration)) {
34243                 var containerObjectType = getJSContainerObjectType(declaration, getSymbolOfNode(declaration), ts.getDeclaredExpandoInitializer(declaration));
34244                 if (containerObjectType) {
34245                     return containerObjectType;
34246                 }
34247             }
34248             if (declaration.initializer) {
34249                 var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration));
34250                 return addOptionality(type, isOptional);
34251             }
34252             if (ts.isJsxAttribute(declaration)) {
34253                 return trueType;
34254             }
34255             if (ts.isBindingPattern(declaration.name)) {
34256                 return getTypeFromBindingPattern(declaration.name, false, true);
34257             }
34258             return undefined;
34259         }
34260         function getWidenedTypeForAssignmentDeclaration(symbol, resolvedSymbol) {
34261             var container = ts.getAssignedExpandoInitializer(symbol.valueDeclaration);
34262             if (container) {
34263                 var tag = ts.getJSDocTypeTag(container);
34264                 if (tag && tag.typeExpression) {
34265                     return getTypeFromTypeNode(tag.typeExpression);
34266                 }
34267                 var containerObjectType = getJSContainerObjectType(symbol.valueDeclaration, symbol, container);
34268                 return containerObjectType || getWidenedLiteralType(checkExpressionCached(container));
34269             }
34270             var definedInConstructor = false;
34271             var definedInMethod = false;
34272             var jsdocType;
34273             var types;
34274             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
34275                 var declaration = _a[_i];
34276                 var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration :
34277                     ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration :
34278                         undefined;
34279                 if (!expression) {
34280                     continue;
34281                 }
34282                 var kind = ts.isAccessExpression(expression)
34283                     ? ts.getAssignmentDeclarationPropertyAccessKind(expression)
34284                     : ts.getAssignmentDeclarationKind(expression);
34285                 if (kind === 4) {
34286                     if (isDeclarationInConstructor(expression)) {
34287                         definedInConstructor = true;
34288                     }
34289                     else {
34290                         definedInMethod = true;
34291                     }
34292                 }
34293                 if (!ts.isCallExpression(expression)) {
34294                     jsdocType = getAnnotatedTypeForAssignmentDeclaration(jsdocType, expression, symbol, declaration);
34295                 }
34296                 if (!jsdocType) {
34297                     (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType);
34298                 }
34299             }
34300             var type = jsdocType;
34301             if (!type) {
34302                 if (!ts.length(types)) {
34303                     return errorType;
34304                 }
34305                 var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined;
34306                 if (definedInMethod) {
34307                     var propType = getTypeOfAssignmentDeclarationPropertyOfBaseType(symbol);
34308                     if (propType) {
34309                         (constructorTypes || (constructorTypes = [])).push(propType);
34310                         definedInConstructor = true;
34311                     }
34312                 }
34313                 var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304); }) ? constructorTypes : types;
34314                 type = getUnionType(sourceTypes, 2);
34315             }
34316             var widened = getWidenedType(addOptionality(type, definedInMethod && !definedInConstructor));
34317             if (filterType(widened, function (t) { return !!(t.flags & ~98304); }) === neverType) {
34318                 reportImplicitAny(symbol.valueDeclaration, anyType);
34319                 return anyType;
34320             }
34321             return widened;
34322         }
34323         function getJSContainerObjectType(decl, symbol, init) {
34324             if (!ts.isInJSFile(decl) || !init || !ts.isObjectLiteralExpression(init) || init.properties.length) {
34325                 return undefined;
34326             }
34327             var exports = ts.createSymbolTable();
34328             while (ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl)) {
34329                 var s_2 = getSymbolOfNode(decl);
34330                 if (s_2 && ts.hasEntries(s_2.exports)) {
34331                     mergeSymbolTable(exports, s_2.exports);
34332                 }
34333                 decl = ts.isBinaryExpression(decl) ? decl.parent : decl.parent.parent;
34334             }
34335             var s = getSymbolOfNode(decl);
34336             if (s && ts.hasEntries(s.exports)) {
34337                 mergeSymbolTable(exports, s.exports);
34338             }
34339             var type = createAnonymousType(symbol, exports, ts.emptyArray, ts.emptyArray, undefined, undefined);
34340             type.objectFlags |= 16384;
34341             return type;
34342         }
34343         function getAnnotatedTypeForAssignmentDeclaration(declaredType, expression, symbol, declaration) {
34344             var typeNode = ts.getEffectiveTypeAnnotationNode(expression.parent);
34345             if (typeNode) {
34346                 var type = getWidenedType(getTypeFromTypeNode(typeNode));
34347                 if (!declaredType) {
34348                     return type;
34349                 }
34350                 else if (declaredType !== errorType && type !== errorType && !isTypeIdenticalTo(declaredType, type)) {
34351                     errorNextVariableOrPropertyDeclarationMustHaveSameType(undefined, declaredType, declaration, type);
34352                 }
34353             }
34354             if (symbol.parent) {
34355                 var typeNode_2 = ts.getEffectiveTypeAnnotationNode(symbol.parent.valueDeclaration);
34356                 if (typeNode_2) {
34357                     return getTypeOfPropertyOfType(getTypeFromTypeNode(typeNode_2), symbol.escapedName);
34358                 }
34359             }
34360             return declaredType;
34361         }
34362         function getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) {
34363             if (ts.isCallExpression(expression)) {
34364                 if (resolvedSymbol) {
34365                     return getTypeOfSymbol(resolvedSymbol);
34366                 }
34367                 var objectLitType = checkExpressionCached(expression.arguments[2]);
34368                 var valueType = getTypeOfPropertyOfType(objectLitType, "value");
34369                 if (valueType) {
34370                     return valueType;
34371                 }
34372                 var getFunc = getTypeOfPropertyOfType(objectLitType, "get");
34373                 if (getFunc) {
34374                     var getSig = getSingleCallSignature(getFunc);
34375                     if (getSig) {
34376                         return getReturnTypeOfSignature(getSig);
34377                     }
34378                 }
34379                 var setFunc = getTypeOfPropertyOfType(objectLitType, "set");
34380                 if (setFunc) {
34381                     var setSig = getSingleCallSignature(setFunc);
34382                     if (setSig) {
34383                         return getTypeOfFirstParameterOfSignature(setSig);
34384                     }
34385                 }
34386                 return anyType;
34387             }
34388             if (containsSameNamedThisProperty(expression.left, expression.right)) {
34389                 return anyType;
34390             }
34391             var type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol) : getWidenedLiteralType(checkExpressionCached(expression.right));
34392             if (type.flags & 524288 &&
34393                 kind === 2 &&
34394                 symbol.escapedName === "export=") {
34395                 var exportedType = resolveStructuredTypeMembers(type);
34396                 var members_4 = ts.createSymbolTable();
34397                 ts.copyEntries(exportedType.members, members_4);
34398                 if (resolvedSymbol && !resolvedSymbol.exports) {
34399                     resolvedSymbol.exports = ts.createSymbolTable();
34400                 }
34401                 (resolvedSymbol || symbol).exports.forEach(function (s, name) {
34402                     var _a;
34403                     var exportedMember = members_4.get(name);
34404                     if (exportedMember && exportedMember !== s) {
34405                         if (s.flags & 111551) {
34406                             if (ts.getSourceFileOfNode(s.valueDeclaration) !== ts.getSourceFileOfNode(exportedMember.valueDeclaration)) {
34407                                 var unescapedName = ts.unescapeLeadingUnderscores(s.escapedName);
34408                                 var exportedMemberName = ((_a = ts.tryCast(exportedMember.valueDeclaration, ts.isNamedDeclaration)) === null || _a === void 0 ? void 0 : _a.name) || exportedMember.valueDeclaration;
34409                                 ts.addRelatedInfo(error(s.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, unescapedName), ts.createDiagnosticForNode(exportedMemberName, ts.Diagnostics._0_was_also_declared_here, unescapedName));
34410                                 ts.addRelatedInfo(error(exportedMemberName, ts.Diagnostics.Duplicate_identifier_0, unescapedName), ts.createDiagnosticForNode(s.valueDeclaration, ts.Diagnostics._0_was_also_declared_here, unescapedName));
34411                             }
34412                             var union = createSymbol(s.flags | exportedMember.flags, name);
34413                             union.type = getUnionType([getTypeOfSymbol(s), getTypeOfSymbol(exportedMember)]);
34414                             union.valueDeclaration = exportedMember.valueDeclaration;
34415                             union.declarations = ts.concatenate(exportedMember.declarations, s.declarations);
34416                             members_4.set(name, union);
34417                         }
34418                         else {
34419                             members_4.set(name, mergeSymbol(s, exportedMember));
34420                         }
34421                     }
34422                     else {
34423                         members_4.set(name, s);
34424                     }
34425                 });
34426                 var result = createAnonymousType(exportedType.symbol, members_4, exportedType.callSignatures, exportedType.constructSignatures, exportedType.stringIndexInfo, exportedType.numberIndexInfo);
34427                 result.objectFlags |= (ts.getObjectFlags(type) & 16384);
34428                 return result;
34429             }
34430             if (isEmptyArrayLiteralType(type)) {
34431                 reportImplicitAny(expression, anyArrayType);
34432                 return anyArrayType;
34433             }
34434             return type;
34435         }
34436         function containsSameNamedThisProperty(thisProperty, expression) {
34437             return ts.isPropertyAccessExpression(thisProperty)
34438                 && thisProperty.expression.kind === 104
34439                 && ts.forEachChildRecursively(expression, function (n) { return isMatchingReference(thisProperty, n); });
34440         }
34441         function isDeclarationInConstructor(expression) {
34442             var thisContainer = ts.getThisContainer(expression, false);
34443             return thisContainer.kind === 162 ||
34444                 thisContainer.kind === 244 ||
34445                 (thisContainer.kind === 201 && !ts.isPrototypePropertyAssignment(thisContainer.parent));
34446         }
34447         function getConstructorDefinedThisAssignmentTypes(types, declarations) {
34448             ts.Debug.assert(types.length === declarations.length);
34449             return types.filter(function (_, i) {
34450                 var declaration = declarations[i];
34451                 var expression = ts.isBinaryExpression(declaration) ? declaration :
34452                     ts.isBinaryExpression(declaration.parent) ? declaration.parent : undefined;
34453                 return expression && isDeclarationInConstructor(expression);
34454             });
34455         }
34456         function getTypeOfAssignmentDeclarationPropertyOfBaseType(property) {
34457             var parentDeclaration = ts.forEach(property.declarations, function (d) {
34458                 var parent = ts.getThisContainer(d, false).parent;
34459                 return ts.isClassLike(parent) && parent;
34460             });
34461             if (parentDeclaration) {
34462                 var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(parentDeclaration));
34463                 var baseClassType = classType && getBaseTypes(classType)[0];
34464                 if (baseClassType) {
34465                     return getTypeOfPropertyOfType(baseClassType, property.escapedName);
34466                 }
34467             }
34468         }
34469         function getTypeFromBindingElement(element, includePatternInType, reportErrors) {
34470             if (element.initializer) {
34471                 var contextualType = ts.isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, true, false) : unknownType;
34472                 return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, contextualType)));
34473             }
34474             if (ts.isBindingPattern(element.name)) {
34475                 return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors);
34476             }
34477             if (reportErrors && !declarationBelongsToPrivateAmbientMember(element)) {
34478                 reportImplicitAny(element, anyType);
34479             }
34480             return includePatternInType ? nonInferrableAnyType : anyType;
34481         }
34482         function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) {
34483             var members = ts.createSymbolTable();
34484             var stringIndexInfo;
34485             var objectFlags = 128 | 1048576;
34486             ts.forEach(pattern.elements, function (e) {
34487                 var name = e.propertyName || e.name;
34488                 if (e.dotDotDotToken) {
34489                     stringIndexInfo = createIndexInfo(anyType, false);
34490                     return;
34491                 }
34492                 var exprType = getLiteralTypeFromPropertyName(name);
34493                 if (!isTypeUsableAsPropertyName(exprType)) {
34494                     objectFlags |= 512;
34495                     return;
34496                 }
34497                 var text = getPropertyNameFromType(exprType);
34498                 var flags = 4 | (e.initializer ? 16777216 : 0);
34499                 var symbol = createSymbol(flags, text);
34500                 symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors);
34501                 symbol.bindingElement = e;
34502                 members.set(symbol.escapedName, symbol);
34503             });
34504             var result = createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined);
34505             result.objectFlags |= objectFlags;
34506             if (includePatternInType) {
34507                 result.pattern = pattern;
34508                 result.objectFlags |= 1048576;
34509             }
34510             return result;
34511         }
34512         function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) {
34513             var elements = pattern.elements;
34514             var lastElement = ts.lastOrUndefined(elements);
34515             var hasRestElement = !!(lastElement && lastElement.kind === 191 && lastElement.dotDotDotToken);
34516             if (elements.length === 0 || elements.length === 1 && hasRestElement) {
34517                 return languageVersion >= 2 ? createIterableType(anyType) : anyArrayType;
34518             }
34519             var elementTypes = ts.map(elements, function (e) { return ts.isOmittedExpression(e) ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors); });
34520             var minLength = ts.findLastIndex(elements, function (e) { return !ts.isOmittedExpression(e) && !hasDefaultValue(e); }, elements.length - (hasRestElement ? 2 : 1)) + 1;
34521             var result = createTupleType(elementTypes, minLength, hasRestElement);
34522             if (includePatternInType) {
34523                 result = cloneTypeReference(result);
34524                 result.pattern = pattern;
34525                 result.objectFlags |= 1048576;
34526             }
34527             return result;
34528         }
34529         function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) {
34530             if (includePatternInType === void 0) { includePatternInType = false; }
34531             if (reportErrors === void 0) { reportErrors = false; }
34532             return pattern.kind === 189
34533                 ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors)
34534                 : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors);
34535         }
34536         function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) {
34537             return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, true), declaration, reportErrors);
34538         }
34539         function widenTypeForVariableLikeDeclaration(type, declaration, reportErrors) {
34540             if (type) {
34541                 if (reportErrors) {
34542                     reportErrorsFromWidening(declaration, type);
34543                 }
34544                 if (type.flags & 8192 && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) {
34545                     type = esSymbolType;
34546                 }
34547                 return getWidenedType(type);
34548             }
34549             type = ts.isParameter(declaration) && declaration.dotDotDotToken ? anyArrayType : anyType;
34550             if (reportErrors) {
34551                 if (!declarationBelongsToPrivateAmbientMember(declaration)) {
34552                     reportImplicitAny(declaration, type);
34553                 }
34554             }
34555             return type;
34556         }
34557         function declarationBelongsToPrivateAmbientMember(declaration) {
34558             var root = ts.getRootDeclaration(declaration);
34559             var memberDeclaration = root.kind === 156 ? root.parent : root;
34560             return isPrivateWithinAmbient(memberDeclaration);
34561         }
34562         function tryGetTypeFromEffectiveTypeNode(declaration) {
34563             var typeNode = ts.getEffectiveTypeAnnotationNode(declaration);
34564             if (typeNode) {
34565                 return getTypeFromTypeNode(typeNode);
34566             }
34567         }
34568         function getTypeOfVariableOrParameterOrProperty(symbol) {
34569             var links = getSymbolLinks(symbol);
34570             if (!links.type) {
34571                 var type = getTypeOfVariableOrParameterOrPropertyWorker(symbol);
34572                 if (!links.type) {
34573                     links.type = type;
34574                 }
34575             }
34576             return links.type;
34577         }
34578         function getTypeOfVariableOrParameterOrPropertyWorker(symbol) {
34579             if (symbol.flags & 4194304) {
34580                 return getTypeOfPrototypeProperty(symbol);
34581             }
34582             if (symbol === requireSymbol) {
34583                 return anyType;
34584             }
34585             if (symbol.flags & 134217728) {
34586                 var fileSymbol = getSymbolOfNode(ts.getSourceFileOfNode(symbol.valueDeclaration));
34587                 var members = ts.createSymbolTable();
34588                 members.set("exports", fileSymbol);
34589                 return createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, undefined, undefined);
34590             }
34591             var declaration = symbol.valueDeclaration;
34592             if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) {
34593                 return anyType;
34594             }
34595             if (ts.isSourceFile(declaration) && ts.isJsonSourceFile(declaration)) {
34596                 if (!declaration.statements.length) {
34597                     return emptyObjectType;
34598                 }
34599                 return getWidenedType(getWidenedLiteralType(checkExpression(declaration.statements[0].expression)));
34600             }
34601             if (!pushTypeResolution(symbol, 0)) {
34602                 if (symbol.flags & 512 && !(symbol.flags & 67108864)) {
34603                     return getTypeOfFuncClassEnumModule(symbol);
34604                 }
34605                 return reportCircularityError(symbol);
34606             }
34607             var type;
34608             if (declaration.kind === 259) {
34609                 type = widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration);
34610             }
34611             else if (ts.isBinaryExpression(declaration) ||
34612                 (ts.isInJSFile(declaration) &&
34613                     (ts.isCallExpression(declaration) || (ts.isPropertyAccessExpression(declaration) || ts.isBindableStaticElementAccessExpression(declaration)) && ts.isBinaryExpression(declaration.parent)))) {
34614                 type = getWidenedTypeForAssignmentDeclaration(symbol);
34615             }
34616             else if (ts.isJSDocPropertyLikeTag(declaration)
34617                 || ts.isPropertyAccessExpression(declaration)
34618                 || ts.isElementAccessExpression(declaration)
34619                 || ts.isIdentifier(declaration)
34620                 || ts.isStringLiteralLike(declaration)
34621                 || ts.isNumericLiteral(declaration)
34622                 || ts.isClassDeclaration(declaration)
34623                 || ts.isFunctionDeclaration(declaration)
34624                 || (ts.isMethodDeclaration(declaration) && !ts.isObjectLiteralMethod(declaration))
34625                 || ts.isMethodSignature(declaration)
34626                 || ts.isSourceFile(declaration)) {
34627                 if (symbol.flags & (16 | 8192 | 32 | 384 | 512)) {
34628                     return getTypeOfFuncClassEnumModule(symbol);
34629                 }
34630                 type = ts.isBinaryExpression(declaration.parent) ?
34631                     getWidenedTypeForAssignmentDeclaration(symbol) :
34632                     tryGetTypeFromEffectiveTypeNode(declaration) || anyType;
34633             }
34634             else if (ts.isPropertyAssignment(declaration)) {
34635                 type = tryGetTypeFromEffectiveTypeNode(declaration) || checkPropertyAssignment(declaration);
34636             }
34637             else if (ts.isJsxAttribute(declaration)) {
34638                 type = tryGetTypeFromEffectiveTypeNode(declaration) || checkJsxAttribute(declaration);
34639             }
34640             else if (ts.isShorthandPropertyAssignment(declaration)) {
34641                 type = tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionForMutableLocation(declaration.name, 0);
34642             }
34643             else if (ts.isObjectLiteralMethod(declaration)) {
34644                 type = tryGetTypeFromEffectiveTypeNode(declaration) || checkObjectLiteralMethod(declaration, 0);
34645             }
34646             else if (ts.isParameter(declaration)
34647                 || ts.isPropertyDeclaration(declaration)
34648                 || ts.isPropertySignature(declaration)
34649                 || ts.isVariableDeclaration(declaration)
34650                 || ts.isBindingElement(declaration)) {
34651                 type = getWidenedTypeForVariableLikeDeclaration(declaration, true);
34652             }
34653             else if (ts.isEnumDeclaration(declaration)) {
34654                 type = getTypeOfFuncClassEnumModule(symbol);
34655             }
34656             else if (ts.isEnumMember(declaration)) {
34657                 type = getTypeOfEnumMember(symbol);
34658             }
34659             else if (ts.isAccessor(declaration)) {
34660                 type = resolveTypeOfAccessors(symbol);
34661             }
34662             else {
34663                 return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol));
34664             }
34665             if (!popTypeResolution()) {
34666                 if (symbol.flags & 512 && !(symbol.flags & 67108864)) {
34667                     return getTypeOfFuncClassEnumModule(symbol);
34668                 }
34669                 return reportCircularityError(symbol);
34670             }
34671             return type;
34672         }
34673         function getAnnotatedAccessorTypeNode(accessor) {
34674             if (accessor) {
34675                 if (accessor.kind === 163) {
34676                     var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor);
34677                     return getterTypeAnnotation;
34678                 }
34679                 else {
34680                     var setterTypeAnnotation = ts.getEffectiveSetAccessorTypeAnnotationNode(accessor);
34681                     return setterTypeAnnotation;
34682                 }
34683             }
34684             return undefined;
34685         }
34686         function getAnnotatedAccessorType(accessor) {
34687             var node = getAnnotatedAccessorTypeNode(accessor);
34688             return node && getTypeFromTypeNode(node);
34689         }
34690         function getAnnotatedAccessorThisParameter(accessor) {
34691             var parameter = getAccessorThisParameter(accessor);
34692             return parameter && parameter.symbol;
34693         }
34694         function getThisTypeOfDeclaration(declaration) {
34695             return getThisTypeOfSignature(getSignatureFromDeclaration(declaration));
34696         }
34697         function getTypeOfAccessors(symbol) {
34698             var links = getSymbolLinks(symbol);
34699             return links.type || (links.type = getTypeOfAccessorsWorker(symbol));
34700         }
34701         function getTypeOfAccessorsWorker(symbol) {
34702             if (!pushTypeResolution(symbol, 0)) {
34703                 return errorType;
34704             }
34705             var type = resolveTypeOfAccessors(symbol);
34706             if (!popTypeResolution()) {
34707                 type = anyType;
34708                 if (noImplicitAny) {
34709                     var getter = ts.getDeclarationOfKind(symbol, 163);
34710                     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));
34711                 }
34712             }
34713             return type;
34714         }
34715         function resolveTypeOfAccessors(symbol) {
34716             var getter = ts.getDeclarationOfKind(symbol, 163);
34717             var setter = ts.getDeclarationOfKind(symbol, 164);
34718             if (getter && ts.isInJSFile(getter)) {
34719                 var jsDocType = getTypeForDeclarationFromJSDocComment(getter);
34720                 if (jsDocType) {
34721                     return jsDocType;
34722                 }
34723             }
34724             var getterReturnType = getAnnotatedAccessorType(getter);
34725             if (getterReturnType) {
34726                 return getterReturnType;
34727             }
34728             else {
34729                 var setterParameterType = getAnnotatedAccessorType(setter);
34730                 if (setterParameterType) {
34731                     return setterParameterType;
34732                 }
34733                 else {
34734                     if (getter && getter.body) {
34735                         return getReturnTypeFromBody(getter);
34736                     }
34737                     else {
34738                         if (setter) {
34739                             if (!isPrivateWithinAmbient(setter)) {
34740                                 errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol));
34741                             }
34742                         }
34743                         else {
34744                             ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function");
34745                             if (!isPrivateWithinAmbient(getter)) {
34746                                 errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol));
34747                             }
34748                         }
34749                         return anyType;
34750                     }
34751                 }
34752             }
34753         }
34754         function getBaseTypeVariableOfClass(symbol) {
34755             var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol));
34756             return baseConstructorType.flags & 8650752 ? baseConstructorType :
34757                 baseConstructorType.flags & 2097152 ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752); }) :
34758                     undefined;
34759         }
34760         function getTypeOfFuncClassEnumModule(symbol) {
34761             var links = getSymbolLinks(symbol);
34762             var originalLinks = links;
34763             if (!links.type) {
34764                 var jsDeclaration = symbol.valueDeclaration && ts.getDeclarationOfExpando(symbol.valueDeclaration);
34765                 if (jsDeclaration) {
34766                     var merged = mergeJSSymbols(symbol, getSymbolOfNode(jsDeclaration));
34767                     if (merged) {
34768                         symbol = links = merged;
34769                     }
34770                 }
34771                 originalLinks.type = links.type = getTypeOfFuncClassEnumModuleWorker(symbol);
34772             }
34773             return links.type;
34774         }
34775         function getTypeOfFuncClassEnumModuleWorker(symbol) {
34776             var declaration = symbol.valueDeclaration;
34777             if (symbol.flags & 1536 && ts.isShorthandAmbientModuleSymbol(symbol)) {
34778                 return anyType;
34779             }
34780             else if (declaration && (declaration.kind === 209 ||
34781                 ts.isAccessExpression(declaration) &&
34782                     declaration.parent.kind === 209)) {
34783                 return getWidenedTypeForAssignmentDeclaration(symbol);
34784             }
34785             else if (symbol.flags & 512 && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) {
34786                 var resolvedModule = resolveExternalModuleSymbol(symbol);
34787                 if (resolvedModule !== symbol) {
34788                     if (!pushTypeResolution(symbol, 0)) {
34789                         return errorType;
34790                     }
34791                     var exportEquals = getMergedSymbol(symbol.exports.get("export="));
34792                     var type_1 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
34793                     if (!popTypeResolution()) {
34794                         return reportCircularityError(symbol);
34795                     }
34796                     return type_1;
34797                 }
34798             }
34799             var type = createObjectType(16, symbol);
34800             if (symbol.flags & 32) {
34801                 var baseTypeVariable = getBaseTypeVariableOfClass(symbol);
34802                 return baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type;
34803             }
34804             else {
34805                 return strictNullChecks && symbol.flags & 16777216 ? getOptionalType(type) : type;
34806             }
34807         }
34808         function getTypeOfEnumMember(symbol) {
34809             var links = getSymbolLinks(symbol);
34810             return links.type || (links.type = getDeclaredTypeOfEnumMember(symbol));
34811         }
34812         function getTypeOfAlias(symbol) {
34813             var links = getSymbolLinks(symbol);
34814             if (!links.type) {
34815                 var targetSymbol = resolveAlias(symbol);
34816                 links.type = targetSymbol.flags & 111551
34817                     ? getTypeOfSymbol(targetSymbol)
34818                     : errorType;
34819             }
34820             return links.type;
34821         }
34822         function getTypeOfInstantiatedSymbol(symbol) {
34823             var links = getSymbolLinks(symbol);
34824             if (!links.type) {
34825                 if (!pushTypeResolution(symbol, 0)) {
34826                     return links.type = errorType;
34827                 }
34828                 var type = instantiateType(getTypeOfSymbol(links.target), links.mapper);
34829                 if (!popTypeResolution()) {
34830                     type = reportCircularityError(symbol);
34831                 }
34832                 links.type = type;
34833             }
34834             return links.type;
34835         }
34836         function reportCircularityError(symbol) {
34837             var declaration = symbol.valueDeclaration;
34838             if (ts.getEffectiveTypeAnnotationNode(declaration)) {
34839                 error(symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
34840                 return errorType;
34841             }
34842             if (noImplicitAny && (declaration.kind !== 156 || declaration.initializer)) {
34843                 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));
34844             }
34845             return anyType;
34846         }
34847         function getTypeOfSymbolWithDeferredType(symbol) {
34848             var links = getSymbolLinks(symbol);
34849             if (!links.type) {
34850                 ts.Debug.assertIsDefined(links.deferralParent);
34851                 ts.Debug.assertIsDefined(links.deferralConstituents);
34852                 links.type = links.deferralParent.flags & 1048576 ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents);
34853             }
34854             return links.type;
34855         }
34856         function getTypeOfSymbol(symbol) {
34857             var checkFlags = ts.getCheckFlags(symbol);
34858             if (checkFlags & 65536) {
34859                 return getTypeOfSymbolWithDeferredType(symbol);
34860             }
34861             if (checkFlags & 1) {
34862                 return getTypeOfInstantiatedSymbol(symbol);
34863             }
34864             if (checkFlags & 262144) {
34865                 return getTypeOfMappedSymbol(symbol);
34866             }
34867             if (checkFlags & 8192) {
34868                 return getTypeOfReverseMappedSymbol(symbol);
34869             }
34870             if (symbol.flags & (3 | 4)) {
34871                 return getTypeOfVariableOrParameterOrProperty(symbol);
34872             }
34873             if (symbol.flags & (16 | 8192 | 32 | 384 | 512)) {
34874                 return getTypeOfFuncClassEnumModule(symbol);
34875             }
34876             if (symbol.flags & 8) {
34877                 return getTypeOfEnumMember(symbol);
34878             }
34879             if (symbol.flags & 98304) {
34880                 return getTypeOfAccessors(symbol);
34881             }
34882             if (symbol.flags & 2097152) {
34883                 return getTypeOfAlias(symbol);
34884             }
34885             return errorType;
34886         }
34887         function isReferenceToType(type, target) {
34888             return type !== undefined
34889                 && target !== undefined
34890                 && (ts.getObjectFlags(type) & 4) !== 0
34891                 && type.target === target;
34892         }
34893         function getTargetType(type) {
34894             return ts.getObjectFlags(type) & 4 ? type.target : type;
34895         }
34896         function hasBaseType(type, checkBase) {
34897             return check(type);
34898             function check(type) {
34899                 if (ts.getObjectFlags(type) & (3 | 4)) {
34900                     var target = getTargetType(type);
34901                     return target === checkBase || ts.some(getBaseTypes(target), check);
34902                 }
34903                 else if (type.flags & 2097152) {
34904                     return ts.some(type.types, check);
34905                 }
34906                 return false;
34907             }
34908         }
34909         function appendTypeParameters(typeParameters, declarations) {
34910             for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) {
34911                 var declaration = declarations_2[_i];
34912                 typeParameters = ts.appendIfUnique(typeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)));
34913             }
34914             return typeParameters;
34915         }
34916         function getOuterTypeParameters(node, includeThisTypes) {
34917             while (true) {
34918                 node = node.parent;
34919                 if (node && ts.isBinaryExpression(node)) {
34920                     var assignmentKind = ts.getAssignmentDeclarationKind(node);
34921                     if (assignmentKind === 6 || assignmentKind === 3) {
34922                         var symbol = getSymbolOfNode(node.left);
34923                         if (symbol && symbol.parent && !ts.findAncestor(symbol.parent.valueDeclaration, function (d) { return node === d; })) {
34924                             node = symbol.parent.valueDeclaration;
34925                         }
34926                     }
34927                 }
34928                 if (!node) {
34929                     return undefined;
34930                 }
34931                 switch (node.kind) {
34932                     case 225:
34933                     case 245:
34934                     case 214:
34935                     case 246:
34936                     case 165:
34937                     case 166:
34938                     case 160:
34939                     case 170:
34940                     case 171:
34941                     case 300:
34942                     case 244:
34943                     case 161:
34944                     case 201:
34945                     case 202:
34946                     case 247:
34947                     case 321:
34948                     case 322:
34949                     case 316:
34950                     case 315:
34951                     case 186:
34952                     case 180:
34953                         var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes);
34954                         if (node.kind === 186) {
34955                             return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter)));
34956                         }
34957                         else if (node.kind === 180) {
34958                             return ts.concatenate(outerTypeParameters, getInferTypeParameters(node));
34959                         }
34960                         else if (node.kind === 225 && !ts.isInJSFile(node)) {
34961                             break;
34962                         }
34963                         var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node));
34964                         var thisType = includeThisTypes &&
34965                             (node.kind === 245 || node.kind === 214 || node.kind === 246 || isJSConstructor(node)) &&
34966                             getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType;
34967                         return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters;
34968                 }
34969             }
34970         }
34971         function getOuterTypeParametersOfClassOrInterface(symbol) {
34972             var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 246);
34973             ts.Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations");
34974             return getOuterTypeParameters(declaration);
34975         }
34976         function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) {
34977             var result;
34978             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
34979                 var node = _a[_i];
34980                 if (node.kind === 246 ||
34981                     node.kind === 245 ||
34982                     node.kind === 214 ||
34983                     isJSConstructor(node) ||
34984                     ts.isTypeAlias(node)) {
34985                     var declaration = node;
34986                     result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration));
34987                 }
34988             }
34989             return result;
34990         }
34991         function getTypeParametersOfClassOrInterface(symbol) {
34992             return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol));
34993         }
34994         function isMixinConstructorType(type) {
34995             var signatures = getSignaturesOfType(type, 1);
34996             if (signatures.length === 1) {
34997                 var s = signatures[0];
34998                 return !s.typeParameters && s.parameters.length === 1 && signatureHasRestParameter(s) && getElementTypeOfArrayType(getTypeOfParameter(s.parameters[0])) === anyType;
34999             }
35000             return false;
35001         }
35002         function isConstructorType(type) {
35003             if (getSignaturesOfType(type, 1).length > 0) {
35004                 return true;
35005             }
35006             if (type.flags & 8650752) {
35007                 var constraint = getBaseConstraintOfType(type);
35008                 return !!constraint && isMixinConstructorType(constraint);
35009             }
35010             return false;
35011         }
35012         function getBaseTypeNodeOfClass(type) {
35013             return ts.getEffectiveBaseTypeNode(type.symbol.valueDeclaration);
35014         }
35015         function getConstructorsForTypeArguments(type, typeArgumentNodes, location) {
35016             var typeArgCount = ts.length(typeArgumentNodes);
35017             var isJavascript = ts.isInJSFile(location);
35018             return ts.filter(getSignaturesOfType(type, 1), function (sig) { return (isJavascript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= ts.length(sig.typeParameters); });
35019         }
35020         function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes, location) {
35021             var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes, location);
35022             var typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode);
35023             return ts.sameMap(signatures, function (sig) { return ts.some(sig.typeParameters) ? getSignatureInstantiation(sig, typeArguments, ts.isInJSFile(location)) : sig; });
35024         }
35025         function getBaseConstructorTypeOfClass(type) {
35026             if (!type.resolvedBaseConstructorType) {
35027                 var decl = type.symbol.valueDeclaration;
35028                 var extended = ts.getEffectiveBaseTypeNode(decl);
35029                 var baseTypeNode = getBaseTypeNodeOfClass(type);
35030                 if (!baseTypeNode) {
35031                     return type.resolvedBaseConstructorType = undefinedType;
35032                 }
35033                 if (!pushTypeResolution(type, 1)) {
35034                     return errorType;
35035                 }
35036                 var baseConstructorType = checkExpression(baseTypeNode.expression);
35037                 if (extended && baseTypeNode !== extended) {
35038                     ts.Debug.assert(!extended.typeArguments);
35039                     checkExpression(extended.expression);
35040                 }
35041                 if (baseConstructorType.flags & (524288 | 2097152)) {
35042                     resolveStructuredTypeMembers(baseConstructorType);
35043                 }
35044                 if (!popTypeResolution()) {
35045                     error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol));
35046                     return type.resolvedBaseConstructorType = errorType;
35047                 }
35048                 if (!(baseConstructorType.flags & 1) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) {
35049                     var err = error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType));
35050                     if (baseConstructorType.flags & 262144) {
35051                         var constraint = getConstraintFromTypeParameter(baseConstructorType);
35052                         var ctorReturn = unknownType;
35053                         if (constraint) {
35054                             var ctorSig = getSignaturesOfType(constraint, 1);
35055                             if (ctorSig[0]) {
35056                                 ctorReturn = getReturnTypeOfSignature(ctorSig[0]);
35057                             }
35058                         }
35059                         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)));
35060                     }
35061                     return type.resolvedBaseConstructorType = errorType;
35062                 }
35063                 type.resolvedBaseConstructorType = baseConstructorType;
35064             }
35065             return type.resolvedBaseConstructorType;
35066         }
35067         function getImplementsTypes(type) {
35068             var resolvedImplementsTypes = ts.emptyArray;
35069             for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) {
35070                 var declaration = _a[_i];
35071                 var implementsTypeNodes = ts.getEffectiveImplementsTypeNodes(declaration);
35072                 if (!implementsTypeNodes)
35073                     continue;
35074                 for (var _b = 0, implementsTypeNodes_1 = implementsTypeNodes; _b < implementsTypeNodes_1.length; _b++) {
35075                     var node = implementsTypeNodes_1[_b];
35076                     var implementsType = getTypeFromTypeNode(node);
35077                     if (implementsType !== errorType) {
35078                         if (resolvedImplementsTypes === ts.emptyArray) {
35079                             resolvedImplementsTypes = [implementsType];
35080                         }
35081                         else {
35082                             resolvedImplementsTypes.push(implementsType);
35083                         }
35084                     }
35085                 }
35086             }
35087             return resolvedImplementsTypes;
35088         }
35089         function getBaseTypes(type) {
35090             if (!type.resolvedBaseTypes) {
35091                 if (type.objectFlags & 8) {
35092                     type.resolvedBaseTypes = [createArrayType(getUnionType(type.typeParameters || ts.emptyArray), type.readonly)];
35093                 }
35094                 else if (type.symbol.flags & (32 | 64)) {
35095                     if (type.symbol.flags & 32) {
35096                         resolveBaseTypesOfClass(type);
35097                     }
35098                     if (type.symbol.flags & 64) {
35099                         resolveBaseTypesOfInterface(type);
35100                     }
35101                 }
35102                 else {
35103                     ts.Debug.fail("type must be class or interface");
35104                 }
35105             }
35106             return type.resolvedBaseTypes;
35107         }
35108         function resolveBaseTypesOfClass(type) {
35109             type.resolvedBaseTypes = ts.resolvingEmptyArray;
35110             var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type));
35111             if (!(baseConstructorType.flags & (524288 | 2097152 | 1))) {
35112                 return type.resolvedBaseTypes = ts.emptyArray;
35113             }
35114             var baseTypeNode = getBaseTypeNodeOfClass(type);
35115             var baseType;
35116             var originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined;
35117             if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 &&
35118                 areAllOuterTypeParametersApplied(originalBaseType)) {
35119                 baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol);
35120             }
35121             else if (baseConstructorType.flags & 1) {
35122                 baseType = baseConstructorType;
35123             }
35124             else {
35125                 var constructors = getInstantiatedConstructorsForTypeArguments(baseConstructorType, baseTypeNode.typeArguments, baseTypeNode);
35126                 if (!constructors.length) {
35127                     error(baseTypeNode.expression, ts.Diagnostics.No_base_constructor_has_the_specified_number_of_type_arguments);
35128                     return type.resolvedBaseTypes = ts.emptyArray;
35129                 }
35130                 baseType = getReturnTypeOfSignature(constructors[0]);
35131             }
35132             if (baseType === errorType) {
35133                 return type.resolvedBaseTypes = ts.emptyArray;
35134             }
35135             var reducedBaseType = getReducedType(baseType);
35136             if (!isValidBaseType(reducedBaseType)) {
35137                 var elaboration = elaborateNeverIntersection(undefined, baseType);
35138                 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));
35139                 diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(baseTypeNode.expression, diagnostic));
35140                 return type.resolvedBaseTypes = ts.emptyArray;
35141             }
35142             if (type === reducedBaseType || hasBaseType(reducedBaseType, type)) {
35143                 error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 2));
35144                 return type.resolvedBaseTypes = ts.emptyArray;
35145             }
35146             if (type.resolvedBaseTypes === ts.resolvingEmptyArray) {
35147                 type.members = undefined;
35148             }
35149             return type.resolvedBaseTypes = [reducedBaseType];
35150         }
35151         function areAllOuterTypeParametersApplied(type) {
35152             var outerTypeParameters = type.outerTypeParameters;
35153             if (outerTypeParameters) {
35154                 var last_1 = outerTypeParameters.length - 1;
35155                 var typeArguments = getTypeArguments(type);
35156                 return outerTypeParameters[last_1].symbol !== typeArguments[last_1].symbol;
35157             }
35158             return true;
35159         }
35160         function isValidBaseType(type) {
35161             if (type.flags & 262144) {
35162                 var constraint = getBaseConstraintOfType(type);
35163                 if (constraint) {
35164                     return isValidBaseType(constraint);
35165                 }
35166             }
35167             return !!(type.flags & (524288 | 67108864 | 1) && !isGenericMappedType(type) ||
35168                 type.flags & 2097152 && ts.every(type.types, isValidBaseType));
35169         }
35170         function resolveBaseTypesOfInterface(type) {
35171             type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray;
35172             for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) {
35173                 var declaration = _a[_i];
35174                 if (declaration.kind === 246 && ts.getInterfaceBaseTypeNodes(declaration)) {
35175                     for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) {
35176                         var node = _c[_b];
35177                         var baseType = getReducedType(getTypeFromTypeNode(node));
35178                         if (baseType !== errorType) {
35179                             if (isValidBaseType(baseType)) {
35180                                 if (type !== baseType && !hasBaseType(baseType, type)) {
35181                                     if (type.resolvedBaseTypes === ts.emptyArray) {
35182                                         type.resolvedBaseTypes = [baseType];
35183                                     }
35184                                     else {
35185                                         type.resolvedBaseTypes.push(baseType);
35186                                     }
35187                                 }
35188                                 else {
35189                                     error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 2));
35190                                 }
35191                             }
35192                             else {
35193                                 error(node, ts.Diagnostics.An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members);
35194                             }
35195                         }
35196                     }
35197                 }
35198             }
35199         }
35200         function isThislessInterface(symbol) {
35201             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
35202                 var declaration = _a[_i];
35203                 if (declaration.kind === 246) {
35204                     if (declaration.flags & 128) {
35205                         return false;
35206                     }
35207                     var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration);
35208                     if (baseTypeNodes) {
35209                         for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) {
35210                             var node = baseTypeNodes_1[_b];
35211                             if (ts.isEntityNameExpression(node.expression)) {
35212                                 var baseSymbol = resolveEntityName(node.expression, 788968, true);
35213                                 if (!baseSymbol || !(baseSymbol.flags & 64) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) {
35214                                     return false;
35215                                 }
35216                             }
35217                         }
35218                     }
35219                 }
35220             }
35221             return true;
35222         }
35223         function getDeclaredTypeOfClassOrInterface(symbol) {
35224             var links = getSymbolLinks(symbol);
35225             var originalLinks = links;
35226             if (!links.declaredType) {
35227                 var kind = symbol.flags & 32 ? 1 : 2;
35228                 var merged = mergeJSSymbols(symbol, getAssignedClassSymbol(symbol.valueDeclaration));
35229                 if (merged) {
35230                     symbol = links = merged;
35231                 }
35232                 var type = originalLinks.declaredType = links.declaredType = createObjectType(kind, symbol);
35233                 var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol);
35234                 var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
35235                 if (outerTypeParameters || localTypeParameters || kind === 1 || !isThislessInterface(symbol)) {
35236                     type.objectFlags |= 4;
35237                     type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters);
35238                     type.outerTypeParameters = outerTypeParameters;
35239                     type.localTypeParameters = localTypeParameters;
35240                     type.instantiations = ts.createMap();
35241                     type.instantiations.set(getTypeListId(type.typeParameters), type);
35242                     type.target = type;
35243                     type.resolvedTypeArguments = type.typeParameters;
35244                     type.thisType = createTypeParameter(symbol);
35245                     type.thisType.isThisType = true;
35246                     type.thisType.constraint = type;
35247                 }
35248             }
35249             return links.declaredType;
35250         }
35251         function getDeclaredTypeOfTypeAlias(symbol) {
35252             var links = getSymbolLinks(symbol);
35253             if (!links.declaredType) {
35254                 if (!pushTypeResolution(symbol, 2)) {
35255                     return errorType;
35256                 }
35257                 var declaration = ts.Debug.checkDefined(ts.find(symbol.declarations, ts.isTypeAlias), "Type alias symbol with no valid declaration found");
35258                 var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type;
35259                 var type = typeNode ? getTypeFromTypeNode(typeNode) : errorType;
35260                 if (popTypeResolution()) {
35261                     var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
35262                     if (typeParameters) {
35263                         links.typeParameters = typeParameters;
35264                         links.instantiations = ts.createMap();
35265                         links.instantiations.set(getTypeListId(typeParameters), type);
35266                     }
35267                 }
35268                 else {
35269                     type = errorType;
35270                     error(ts.isNamedDeclaration(declaration) ? declaration.name : declaration || declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
35271                 }
35272                 links.declaredType = type;
35273             }
35274             return links.declaredType;
35275         }
35276         function isStringConcatExpression(expr) {
35277             if (ts.isStringLiteralLike(expr)) {
35278                 return true;
35279             }
35280             else if (expr.kind === 209) {
35281                 return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right);
35282             }
35283             return false;
35284         }
35285         function isLiteralEnumMember(member) {
35286             var expr = member.initializer;
35287             if (!expr) {
35288                 return !(member.flags & 8388608);
35289             }
35290             switch (expr.kind) {
35291                 case 10:
35292                 case 8:
35293                 case 14:
35294                     return true;
35295                 case 207:
35296                     return expr.operator === 40 &&
35297                         expr.operand.kind === 8;
35298                 case 75:
35299                     return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText);
35300                 case 209:
35301                     return isStringConcatExpression(expr);
35302                 default:
35303                     return false;
35304             }
35305         }
35306         function getEnumKind(symbol) {
35307             var links = getSymbolLinks(symbol);
35308             if (links.enumKind !== undefined) {
35309                 return links.enumKind;
35310             }
35311             var hasNonLiteralMember = false;
35312             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
35313                 var declaration = _a[_i];
35314                 if (declaration.kind === 248) {
35315                     for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) {
35316                         var member = _c[_b];
35317                         if (member.initializer && ts.isStringLiteralLike(member.initializer)) {
35318                             return links.enumKind = 1;
35319                         }
35320                         if (!isLiteralEnumMember(member)) {
35321                             hasNonLiteralMember = true;
35322                         }
35323                     }
35324                 }
35325             }
35326             return links.enumKind = hasNonLiteralMember ? 0 : 1;
35327         }
35328         function getBaseTypeOfEnumLiteralType(type) {
35329             return type.flags & 1024 && !(type.flags & 1048576) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type;
35330         }
35331         function getDeclaredTypeOfEnum(symbol) {
35332             var links = getSymbolLinks(symbol);
35333             if (links.declaredType) {
35334                 return links.declaredType;
35335             }
35336             if (getEnumKind(symbol) === 1) {
35337                 enumCount++;
35338                 var memberTypeList = [];
35339                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
35340                     var declaration = _a[_i];
35341                     if (declaration.kind === 248) {
35342                         for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) {
35343                             var member = _c[_b];
35344                             var value = getEnumMemberValue(member);
35345                             var memberType = getFreshTypeOfLiteralType(getLiteralType(value !== undefined ? value : 0, enumCount, getSymbolOfNode(member)));
35346                             getSymbolLinks(getSymbolOfNode(member)).declaredType = memberType;
35347                             memberTypeList.push(getRegularTypeOfLiteralType(memberType));
35348                         }
35349                     }
35350                 }
35351                 if (memberTypeList.length) {
35352                     var enumType_1 = getUnionType(memberTypeList, 1, symbol, undefined);
35353                     if (enumType_1.flags & 1048576) {
35354                         enumType_1.flags |= 1024;
35355                         enumType_1.symbol = symbol;
35356                     }
35357                     return links.declaredType = enumType_1;
35358                 }
35359             }
35360             var enumType = createType(32);
35361             enumType.symbol = symbol;
35362             return links.declaredType = enumType;
35363         }
35364         function getDeclaredTypeOfEnumMember(symbol) {
35365             var links = getSymbolLinks(symbol);
35366             if (!links.declaredType) {
35367                 var enumType = getDeclaredTypeOfEnum(getParentOfSymbol(symbol));
35368                 if (!links.declaredType) {
35369                     links.declaredType = enumType;
35370                 }
35371             }
35372             return links.declaredType;
35373         }
35374         function getDeclaredTypeOfTypeParameter(symbol) {
35375             var links = getSymbolLinks(symbol);
35376             return links.declaredType || (links.declaredType = createTypeParameter(symbol));
35377         }
35378         function getDeclaredTypeOfAlias(symbol) {
35379             var links = getSymbolLinks(symbol);
35380             return links.declaredType || (links.declaredType = getDeclaredTypeOfSymbol(resolveAlias(symbol)));
35381         }
35382         function getDeclaredTypeOfSymbol(symbol) {
35383             return tryGetDeclaredTypeOfSymbol(symbol) || errorType;
35384         }
35385         function tryGetDeclaredTypeOfSymbol(symbol) {
35386             if (symbol.flags & (32 | 64)) {
35387                 return getDeclaredTypeOfClassOrInterface(symbol);
35388             }
35389             if (symbol.flags & 524288) {
35390                 return getDeclaredTypeOfTypeAlias(symbol);
35391             }
35392             if (symbol.flags & 262144) {
35393                 return getDeclaredTypeOfTypeParameter(symbol);
35394             }
35395             if (symbol.flags & 384) {
35396                 return getDeclaredTypeOfEnum(symbol);
35397             }
35398             if (symbol.flags & 8) {
35399                 return getDeclaredTypeOfEnumMember(symbol);
35400             }
35401             if (symbol.flags & 2097152) {
35402                 return getDeclaredTypeOfAlias(symbol);
35403             }
35404             return undefined;
35405         }
35406         function isThislessType(node) {
35407             switch (node.kind) {
35408                 case 125:
35409                 case 148:
35410                 case 143:
35411                 case 140:
35412                 case 151:
35413                 case 128:
35414                 case 144:
35415                 case 141:
35416                 case 110:
35417                 case 146:
35418                 case 100:
35419                 case 137:
35420                 case 187:
35421                     return true;
35422                 case 174:
35423                     return isThislessType(node.elementType);
35424                 case 169:
35425                     return !node.typeArguments || node.typeArguments.every(isThislessType);
35426             }
35427             return false;
35428         }
35429         function isThislessTypeParameter(node) {
35430             var constraint = ts.getEffectiveConstraintOfTypeParameter(node);
35431             return !constraint || isThislessType(constraint);
35432         }
35433         function isThislessVariableLikeDeclaration(node) {
35434             var typeNode = ts.getEffectiveTypeAnnotationNode(node);
35435             return typeNode ? isThislessType(typeNode) : !ts.hasInitializer(node);
35436         }
35437         function isThislessFunctionLikeDeclaration(node) {
35438             var returnType = ts.getEffectiveReturnTypeNode(node);
35439             var typeParameters = ts.getEffectiveTypeParameterDeclarations(node);
35440             return (node.kind === 162 || (!!returnType && isThislessType(returnType))) &&
35441                 node.parameters.every(isThislessVariableLikeDeclaration) &&
35442                 typeParameters.every(isThislessTypeParameter);
35443         }
35444         function isThisless(symbol) {
35445             if (symbol.declarations && symbol.declarations.length === 1) {
35446                 var declaration = symbol.declarations[0];
35447                 if (declaration) {
35448                     switch (declaration.kind) {
35449                         case 159:
35450                         case 158:
35451                             return isThislessVariableLikeDeclaration(declaration);
35452                         case 161:
35453                         case 160:
35454                         case 162:
35455                         case 163:
35456                         case 164:
35457                             return isThislessFunctionLikeDeclaration(declaration);
35458                     }
35459                 }
35460             }
35461             return false;
35462         }
35463         function createInstantiatedSymbolTable(symbols, mapper, mappingThisOnly) {
35464             var result = ts.createSymbolTable();
35465             for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) {
35466                 var symbol = symbols_2[_i];
35467                 result.set(symbol.escapedName, mappingThisOnly && isThisless(symbol) ? symbol : instantiateSymbol(symbol, mapper));
35468             }
35469             return result;
35470         }
35471         function addInheritedMembers(symbols, baseSymbols) {
35472             for (var _i = 0, baseSymbols_1 = baseSymbols; _i < baseSymbols_1.length; _i++) {
35473                 var s = baseSymbols_1[_i];
35474                 if (!symbols.has(s.escapedName) && !isStaticPrivateIdentifierProperty(s)) {
35475                     symbols.set(s.escapedName, s);
35476                 }
35477             }
35478         }
35479         function isStaticPrivateIdentifierProperty(s) {
35480             return !!s.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(s.valueDeclaration) && ts.hasModifier(s.valueDeclaration, 32);
35481         }
35482         function resolveDeclaredMembers(type) {
35483             if (!type.declaredProperties) {
35484                 var symbol = type.symbol;
35485                 var members = getMembersOfSymbol(symbol);
35486                 type.declaredProperties = getNamedMembers(members);
35487                 type.declaredCallSignatures = ts.emptyArray;
35488                 type.declaredConstructSignatures = ts.emptyArray;
35489                 type.declaredCallSignatures = getSignaturesOfSymbol(members.get("__call"));
35490                 type.declaredConstructSignatures = getSignaturesOfSymbol(members.get("__new"));
35491                 type.declaredStringIndexInfo = getIndexInfoOfSymbol(symbol, 0);
35492                 type.declaredNumberIndexInfo = getIndexInfoOfSymbol(symbol, 1);
35493             }
35494             return type;
35495         }
35496         function isTypeUsableAsPropertyName(type) {
35497             return !!(type.flags & 8576);
35498         }
35499         function isLateBindableName(node) {
35500             if (!ts.isComputedPropertyName(node) && !ts.isElementAccessExpression(node)) {
35501                 return false;
35502             }
35503             var expr = ts.isComputedPropertyName(node) ? node.expression : node.argumentExpression;
35504             return ts.isEntityNameExpression(expr)
35505                 && isTypeUsableAsPropertyName(ts.isComputedPropertyName(node) ? checkComputedPropertyName(node) : checkExpressionCached(expr));
35506         }
35507         function isLateBoundName(name) {
35508             return name.charCodeAt(0) === 95 &&
35509                 name.charCodeAt(1) === 95 &&
35510                 name.charCodeAt(2) === 64;
35511         }
35512         function hasLateBindableName(node) {
35513             var name = ts.getNameOfDeclaration(node);
35514             return !!name && isLateBindableName(name);
35515         }
35516         function hasNonBindableDynamicName(node) {
35517             return ts.hasDynamicName(node) && !hasLateBindableName(node);
35518         }
35519         function isNonBindableDynamicName(node) {
35520             return ts.isDynamicName(node) && !isLateBindableName(node);
35521         }
35522         function getPropertyNameFromType(type) {
35523             if (type.flags & 8192) {
35524                 return type.escapedName;
35525             }
35526             if (type.flags & (128 | 256)) {
35527                 return ts.escapeLeadingUnderscores("" + type.value);
35528             }
35529             return ts.Debug.fail();
35530         }
35531         function addDeclarationToLateBoundSymbol(symbol, member, symbolFlags) {
35532             ts.Debug.assert(!!(ts.getCheckFlags(symbol) & 4096), "Expected a late-bound symbol.");
35533             symbol.flags |= symbolFlags;
35534             getSymbolLinks(member.symbol).lateSymbol = symbol;
35535             if (!symbol.declarations) {
35536                 symbol.declarations = [member];
35537             }
35538             else {
35539                 symbol.declarations.push(member);
35540             }
35541             if (symbolFlags & 111551) {
35542                 if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) {
35543                     symbol.valueDeclaration = member;
35544                 }
35545             }
35546         }
35547         function lateBindMember(parent, earlySymbols, lateSymbols, decl) {
35548             ts.Debug.assert(!!decl.symbol, "The member is expected to have a symbol.");
35549             var links = getNodeLinks(decl);
35550             if (!links.resolvedSymbol) {
35551                 links.resolvedSymbol = decl.symbol;
35552                 var declName = ts.isBinaryExpression(decl) ? decl.left : decl.name;
35553                 var type = ts.isElementAccessExpression(declName) ? checkExpressionCached(declName.argumentExpression) : checkComputedPropertyName(declName);
35554                 if (isTypeUsableAsPropertyName(type)) {
35555                     var memberName = getPropertyNameFromType(type);
35556                     var symbolFlags = decl.symbol.flags;
35557                     var lateSymbol = lateSymbols.get(memberName);
35558                     if (!lateSymbol)
35559                         lateSymbols.set(memberName, lateSymbol = createSymbol(0, memberName, 4096));
35560                     var earlySymbol = earlySymbols && earlySymbols.get(memberName);
35561                     if (lateSymbol.flags & getExcludedSymbolFlags(symbolFlags) || earlySymbol) {
35562                         var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations;
35563                         var name_3 = !(type.flags & 8192) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName);
35564                         ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Property_0_was_also_declared_here, name_3); });
35565                         error(declName || decl, ts.Diagnostics.Duplicate_property_0, name_3);
35566                         lateSymbol = createSymbol(0, memberName, 4096);
35567                     }
35568                     lateSymbol.nameType = type;
35569                     addDeclarationToLateBoundSymbol(lateSymbol, decl, symbolFlags);
35570                     if (lateSymbol.parent) {
35571                         ts.Debug.assert(lateSymbol.parent === parent, "Existing symbol parent should match new one");
35572                     }
35573                     else {
35574                         lateSymbol.parent = parent;
35575                     }
35576                     return links.resolvedSymbol = lateSymbol;
35577                 }
35578             }
35579             return links.resolvedSymbol;
35580         }
35581         function getResolvedMembersOrExportsOfSymbol(symbol, resolutionKind) {
35582             var links = getSymbolLinks(symbol);
35583             if (!links[resolutionKind]) {
35584                 var isStatic = resolutionKind === "resolvedExports";
35585                 var earlySymbols = !isStatic ? symbol.members :
35586                     symbol.flags & 1536 ? getExportsOfModuleWorker(symbol) :
35587                         symbol.exports;
35588                 links[resolutionKind] = earlySymbols || emptySymbols;
35589                 var lateSymbols = ts.createSymbolTable();
35590                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
35591                     var decl = _a[_i];
35592                     var members = ts.getMembersOfDeclaration(decl);
35593                     if (members) {
35594                         for (var _b = 0, members_5 = members; _b < members_5.length; _b++) {
35595                             var member = members_5[_b];
35596                             if (isStatic === ts.hasStaticModifier(member) && hasLateBindableName(member)) {
35597                                 lateBindMember(symbol, earlySymbols, lateSymbols, member);
35598                             }
35599                         }
35600                     }
35601                 }
35602                 var assignments = symbol.assignmentDeclarationMembers;
35603                 if (assignments) {
35604                     var decls = ts.arrayFrom(assignments.values());
35605                     for (var _c = 0, decls_1 = decls; _c < decls_1.length; _c++) {
35606                         var member = decls_1[_c];
35607                         var assignmentKind = ts.getAssignmentDeclarationKind(member);
35608                         var isInstanceMember = assignmentKind === 3
35609                             || assignmentKind === 4
35610                             || assignmentKind === 9
35611                             || assignmentKind === 6;
35612                         if (isStatic === !isInstanceMember && hasLateBindableName(member)) {
35613                             lateBindMember(symbol, earlySymbols, lateSymbols, member);
35614                         }
35615                     }
35616                 }
35617                 links[resolutionKind] = combineSymbolTables(earlySymbols, lateSymbols) || emptySymbols;
35618             }
35619             return links[resolutionKind];
35620         }
35621         function getMembersOfSymbol(symbol) {
35622             return symbol.flags & 6256
35623                 ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers")
35624                 : symbol.members || emptySymbols;
35625         }
35626         function getLateBoundSymbol(symbol) {
35627             if (symbol.flags & 106500 && symbol.escapedName === "__computed") {
35628                 var links = getSymbolLinks(symbol);
35629                 if (!links.lateSymbol && ts.some(symbol.declarations, hasLateBindableName)) {
35630                     var parent = getMergedSymbol(symbol.parent);
35631                     if (ts.some(symbol.declarations, ts.hasStaticModifier)) {
35632                         getExportsOfSymbol(parent);
35633                     }
35634                     else {
35635                         getMembersOfSymbol(parent);
35636                     }
35637                 }
35638                 return links.lateSymbol || (links.lateSymbol = symbol);
35639             }
35640             return symbol;
35641         }
35642         function getTypeWithThisArgument(type, thisArgument, needApparentType) {
35643             if (ts.getObjectFlags(type) & 4) {
35644                 var target = type.target;
35645                 var typeArguments = getTypeArguments(type);
35646                 if (ts.length(target.typeParameters) === ts.length(typeArguments)) {
35647                     var ref = createTypeReference(target, ts.concatenate(typeArguments, [thisArgument || target.thisType]));
35648                     return needApparentType ? getApparentType(ref) : ref;
35649                 }
35650             }
35651             else if (type.flags & 2097152) {
35652                 return getIntersectionType(ts.map(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument, needApparentType); }));
35653             }
35654             return needApparentType ? getApparentType(type) : type;
35655         }
35656         function resolveObjectTypeMembers(type, source, typeParameters, typeArguments) {
35657             var mapper;
35658             var members;
35659             var callSignatures;
35660             var constructSignatures;
35661             var stringIndexInfo;
35662             var numberIndexInfo;
35663             if (ts.rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) {
35664                 members = source.symbol ? getMembersOfSymbol(source.symbol) : ts.createSymbolTable(source.declaredProperties);
35665                 callSignatures = source.declaredCallSignatures;
35666                 constructSignatures = source.declaredConstructSignatures;
35667                 stringIndexInfo = source.declaredStringIndexInfo;
35668                 numberIndexInfo = source.declaredNumberIndexInfo;
35669             }
35670             else {
35671                 mapper = createTypeMapper(typeParameters, typeArguments);
35672                 members = createInstantiatedSymbolTable(source.declaredProperties, mapper, typeParameters.length === 1);
35673                 callSignatures = instantiateSignatures(source.declaredCallSignatures, mapper);
35674                 constructSignatures = instantiateSignatures(source.declaredConstructSignatures, mapper);
35675                 stringIndexInfo = instantiateIndexInfo(source.declaredStringIndexInfo, mapper);
35676                 numberIndexInfo = instantiateIndexInfo(source.declaredNumberIndexInfo, mapper);
35677             }
35678             var baseTypes = getBaseTypes(source);
35679             if (baseTypes.length) {
35680                 if (source.symbol && members === getMembersOfSymbol(source.symbol)) {
35681                     members = ts.createSymbolTable(source.declaredProperties);
35682                 }
35683                 setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
35684                 var thisArgument = ts.lastOrUndefined(typeArguments);
35685                 for (var _i = 0, baseTypes_1 = baseTypes; _i < baseTypes_1.length; _i++) {
35686                     var baseType = baseTypes_1[_i];
35687                     var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType;
35688                     addInheritedMembers(members, getPropertiesOfType(instantiatedBaseType));
35689                     callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0));
35690                     constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1));
35691                     if (!stringIndexInfo) {
35692                         stringIndexInfo = instantiatedBaseType === anyType ?
35693                             createIndexInfo(anyType, false) :
35694                             getIndexInfoOfType(instantiatedBaseType, 0);
35695                     }
35696                     numberIndexInfo = numberIndexInfo || getIndexInfoOfType(instantiatedBaseType, 1);
35697                 }
35698             }
35699             setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
35700         }
35701         function resolveClassOrInterfaceMembers(type) {
35702             resolveObjectTypeMembers(type, resolveDeclaredMembers(type), ts.emptyArray, ts.emptyArray);
35703         }
35704         function resolveTypeReferenceMembers(type) {
35705             var source = resolveDeclaredMembers(type.target);
35706             var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]);
35707             var typeArguments = getTypeArguments(type);
35708             var paddedTypeArguments = typeArguments.length === typeParameters.length ? typeArguments : ts.concatenate(typeArguments, [type]);
35709             resolveObjectTypeMembers(type, source, typeParameters, paddedTypeArguments);
35710         }
35711         function createSignature(declaration, typeParameters, thisParameter, parameters, resolvedReturnType, resolvedTypePredicate, minArgumentCount, flags) {
35712             var sig = new Signature(checker, flags);
35713             sig.declaration = declaration;
35714             sig.typeParameters = typeParameters;
35715             sig.parameters = parameters;
35716             sig.thisParameter = thisParameter;
35717             sig.resolvedReturnType = resolvedReturnType;
35718             sig.resolvedTypePredicate = resolvedTypePredicate;
35719             sig.minArgumentCount = minArgumentCount;
35720             sig.target = undefined;
35721             sig.mapper = undefined;
35722             sig.unionSignatures = undefined;
35723             return sig;
35724         }
35725         function cloneSignature(sig) {
35726             var result = createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, undefined, undefined, sig.minArgumentCount, sig.flags & 3);
35727             result.target = sig.target;
35728             result.mapper = sig.mapper;
35729             result.unionSignatures = sig.unionSignatures;
35730             return result;
35731         }
35732         function createUnionSignature(signature, unionSignatures) {
35733             var result = cloneSignature(signature);
35734             result.unionSignatures = unionSignatures;
35735             result.target = undefined;
35736             result.mapper = undefined;
35737             return result;
35738         }
35739         function getOptionalCallSignature(signature, callChainFlags) {
35740             if ((signature.flags & 12) === callChainFlags) {
35741                 return signature;
35742             }
35743             if (!signature.optionalCallSignatureCache) {
35744                 signature.optionalCallSignatureCache = {};
35745             }
35746             var key = callChainFlags === 4 ? "inner" : "outer";
35747             return signature.optionalCallSignatureCache[key]
35748                 || (signature.optionalCallSignatureCache[key] = createOptionalCallSignature(signature, callChainFlags));
35749         }
35750         function createOptionalCallSignature(signature, callChainFlags) {
35751             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.");
35752             var result = cloneSignature(signature);
35753             result.flags |= callChainFlags;
35754             return result;
35755         }
35756         function getExpandedParameters(sig) {
35757             if (signatureHasRestParameter(sig)) {
35758                 var restIndex_1 = sig.parameters.length - 1;
35759                 var restParameter = sig.parameters[restIndex_1];
35760                 var restType = getTypeOfSymbol(restParameter);
35761                 if (isTupleType(restType)) {
35762                     var elementTypes = getTypeArguments(restType);
35763                     var minLength_1 = restType.target.minLength;
35764                     var tupleRestIndex_1 = restType.target.hasRestElement ? elementTypes.length - 1 : -1;
35765                     var restParams = ts.map(elementTypes, function (t, i) {
35766                         var name = getParameterNameAtPosition(sig, restIndex_1 + i);
35767                         var checkFlags = i === tupleRestIndex_1 ? 32768 :
35768                             i >= minLength_1 ? 16384 : 0;
35769                         var symbol = createSymbol(1, name, checkFlags);
35770                         symbol.type = i === tupleRestIndex_1 ? createArrayType(t) : t;
35771                         return symbol;
35772                     });
35773                     return ts.concatenate(sig.parameters.slice(0, restIndex_1), restParams);
35774                 }
35775             }
35776             return sig.parameters;
35777         }
35778         function getDefaultConstructSignatures(classType) {
35779             var baseConstructorType = getBaseConstructorTypeOfClass(classType);
35780             var baseSignatures = getSignaturesOfType(baseConstructorType, 1);
35781             if (baseSignatures.length === 0) {
35782                 return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, undefined, 0, 0)];
35783             }
35784             var baseTypeNode = getBaseTypeNodeOfClass(classType);
35785             var isJavaScript = ts.isInJSFile(baseTypeNode);
35786             var typeArguments = typeArgumentsFromTypeReferenceNode(baseTypeNode);
35787             var typeArgCount = ts.length(typeArguments);
35788             var result = [];
35789             for (var _i = 0, baseSignatures_1 = baseSignatures; _i < baseSignatures_1.length; _i++) {
35790                 var baseSig = baseSignatures_1[_i];
35791                 var minTypeArgumentCount = getMinTypeArgumentCount(baseSig.typeParameters);
35792                 var typeParamCount = ts.length(baseSig.typeParameters);
35793                 if (isJavaScript || typeArgCount >= minTypeArgumentCount && typeArgCount <= typeParamCount) {
35794                     var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, isJavaScript)) : cloneSignature(baseSig);
35795                     sig.typeParameters = classType.localTypeParameters;
35796                     sig.resolvedReturnType = classType;
35797                     result.push(sig);
35798                 }
35799             }
35800             return result;
35801         }
35802         function findMatchingSignature(signatureList, signature, partialMatch, ignoreThisTypes, ignoreReturnTypes) {
35803             for (var _i = 0, signatureList_1 = signatureList; _i < signatureList_1.length; _i++) {
35804                 var s = signatureList_1[_i];
35805                 if (compareSignaturesIdentical(s, signature, partialMatch, ignoreThisTypes, ignoreReturnTypes, partialMatch ? compareTypesSubtypeOf : compareTypesIdentical)) {
35806                     return s;
35807                 }
35808             }
35809         }
35810         function findMatchingSignatures(signatureLists, signature, listIndex) {
35811             if (signature.typeParameters) {
35812                 if (listIndex > 0) {
35813                     return undefined;
35814                 }
35815                 for (var i = 1; i < signatureLists.length; i++) {
35816                     if (!findMatchingSignature(signatureLists[i], signature, false, false, false)) {
35817                         return undefined;
35818                     }
35819                 }
35820                 return [signature];
35821             }
35822             var result;
35823             for (var i = 0; i < signatureLists.length; i++) {
35824                 var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, true, false, true);
35825                 if (!match) {
35826                     return undefined;
35827                 }
35828                 result = ts.appendIfUnique(result, match);
35829             }
35830             return result;
35831         }
35832         function getUnionSignatures(signatureLists) {
35833             var result;
35834             var indexWithLengthOverOne;
35835             for (var i = 0; i < signatureLists.length; i++) {
35836                 if (signatureLists[i].length === 0)
35837                     return ts.emptyArray;
35838                 if (signatureLists[i].length > 1) {
35839                     indexWithLengthOverOne = indexWithLengthOverOne === undefined ? i : -1;
35840                 }
35841                 for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) {
35842                     var signature = _a[_i];
35843                     if (!result || !findMatchingSignature(result, signature, false, false, true)) {
35844                         var unionSignatures = findMatchingSignatures(signatureLists, signature, i);
35845                         if (unionSignatures) {
35846                             var s = signature;
35847                             if (unionSignatures.length > 1) {
35848                                 var thisParameter = signature.thisParameter;
35849                                 var firstThisParameterOfUnionSignatures = ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; });
35850                                 if (firstThisParameterOfUnionSignatures) {
35851                                     var thisType = getIntersectionType(ts.mapDefined(unionSignatures, function (sig) { return sig.thisParameter && getTypeOfSymbol(sig.thisParameter); }));
35852                                     thisParameter = createSymbolWithType(firstThisParameterOfUnionSignatures, thisType);
35853                                 }
35854                                 s = createUnionSignature(signature, unionSignatures);
35855                                 s.thisParameter = thisParameter;
35856                             }
35857                             (result || (result = [])).push(s);
35858                         }
35859                     }
35860                 }
35861             }
35862             if (!ts.length(result) && indexWithLengthOverOne !== -1) {
35863                 var masterList = signatureLists[indexWithLengthOverOne !== undefined ? indexWithLengthOverOne : 0];
35864                 var results = masterList.slice();
35865                 var _loop_9 = function (signatures) {
35866                     if (signatures !== masterList) {
35867                         var signature_1 = signatures[0];
35868                         ts.Debug.assert(!!signature_1, "getUnionSignatures bails early on empty signature lists and should not have empty lists on second pass");
35869                         results = signature_1.typeParameters && ts.some(results, function (s) { return !!s.typeParameters; }) ? undefined : ts.map(results, function (sig) { return combineSignaturesOfUnionMembers(sig, signature_1); });
35870                         if (!results) {
35871                             return "break";
35872                         }
35873                     }
35874                 };
35875                 for (var _b = 0, signatureLists_1 = signatureLists; _b < signatureLists_1.length; _b++) {
35876                     var signatures = signatureLists_1[_b];
35877                     var state_3 = _loop_9(signatures);
35878                     if (state_3 === "break")
35879                         break;
35880                 }
35881                 result = results;
35882             }
35883             return result || ts.emptyArray;
35884         }
35885         function combineUnionThisParam(left, right) {
35886             if (!left || !right) {
35887                 return left || right;
35888             }
35889             var thisType = getIntersectionType([getTypeOfSymbol(left), getTypeOfSymbol(right)]);
35890             return createSymbolWithType(left, thisType);
35891         }
35892         function combineUnionParameters(left, right) {
35893             var leftCount = getParameterCount(left);
35894             var rightCount = getParameterCount(right);
35895             var longest = leftCount >= rightCount ? left : right;
35896             var shorter = longest === left ? right : left;
35897             var longestCount = longest === left ? leftCount : rightCount;
35898             var eitherHasEffectiveRest = (hasEffectiveRestParameter(left) || hasEffectiveRestParameter(right));
35899             var needsExtraRestElement = eitherHasEffectiveRest && !hasEffectiveRestParameter(longest);
35900             var params = new Array(longestCount + (needsExtraRestElement ? 1 : 0));
35901             for (var i = 0; i < longestCount; i++) {
35902                 var longestParamType = tryGetTypeAtPosition(longest, i);
35903                 var shorterParamType = tryGetTypeAtPosition(shorter, i) || unknownType;
35904                 var unionParamType = getIntersectionType([longestParamType, shorterParamType]);
35905                 var isRestParam = eitherHasEffectiveRest && !needsExtraRestElement && i === (longestCount - 1);
35906                 var isOptional = i >= getMinArgumentCount(longest) && i >= getMinArgumentCount(shorter);
35907                 var leftName = i >= leftCount ? undefined : getParameterNameAtPosition(left, i);
35908                 var rightName = i >= rightCount ? undefined : getParameterNameAtPosition(right, i);
35909                 var paramName = leftName === rightName ? leftName :
35910                     !leftName ? rightName :
35911                         !rightName ? leftName :
35912                             undefined;
35913                 var paramSymbol = createSymbol(1 | (isOptional && !isRestParam ? 16777216 : 0), paramName || "arg" + i);
35914                 paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType;
35915                 params[i] = paramSymbol;
35916             }
35917             if (needsExtraRestElement) {
35918                 var restParamSymbol = createSymbol(1, "args");
35919                 restParamSymbol.type = createArrayType(getTypeAtPosition(shorter, longestCount));
35920                 params[longestCount] = restParamSymbol;
35921             }
35922             return params;
35923         }
35924         function combineSignaturesOfUnionMembers(left, right) {
35925             var declaration = left.declaration;
35926             var params = combineUnionParameters(left, right);
35927             var thisParam = combineUnionThisParam(left.thisParameter, right.thisParameter);
35928             var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount);
35929             var result = createSignature(declaration, left.typeParameters || right.typeParameters, thisParam, params, undefined, undefined, minArgCount, (left.flags | right.flags) & 3);
35930             result.unionSignatures = ts.concatenate(left.unionSignatures || [left], [right]);
35931             return result;
35932         }
35933         function getUnionIndexInfo(types, kind) {
35934             var indexTypes = [];
35935             var isAnyReadonly = false;
35936             for (var _i = 0, types_3 = types; _i < types_3.length; _i++) {
35937                 var type = types_3[_i];
35938                 var indexInfo = getIndexInfoOfType(getApparentType(type), kind);
35939                 if (!indexInfo) {
35940                     return undefined;
35941                 }
35942                 indexTypes.push(indexInfo.type);
35943                 isAnyReadonly = isAnyReadonly || indexInfo.isReadonly;
35944             }
35945             return createIndexInfo(getUnionType(indexTypes, 2), isAnyReadonly);
35946         }
35947         function resolveUnionTypeMembers(type) {
35948             var callSignatures = getUnionSignatures(ts.map(type.types, function (t) { return t === globalFunctionType ? [unknownSignature] : getSignaturesOfType(t, 0); }));
35949             var constructSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 1); }));
35950             var stringIndexInfo = getUnionIndexInfo(type.types, 0);
35951             var numberIndexInfo = getUnionIndexInfo(type.types, 1);
35952             setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
35953         }
35954         function intersectTypes(type1, type2) {
35955             return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]);
35956         }
35957         function intersectIndexInfos(info1, info2) {
35958             return !info1 ? info2 : !info2 ? info1 : createIndexInfo(getIntersectionType([info1.type, info2.type]), info1.isReadonly && info2.isReadonly);
35959         }
35960         function unionSpreadIndexInfos(info1, info2) {
35961             return info1 && info2 && createIndexInfo(getUnionType([info1.type, info2.type]), info1.isReadonly || info2.isReadonly);
35962         }
35963         function findMixins(types) {
35964             var constructorTypeCount = ts.countWhere(types, function (t) { return getSignaturesOfType(t, 1).length > 0; });
35965             var mixinFlags = ts.map(types, isMixinConstructorType);
35966             if (constructorTypeCount > 0 && constructorTypeCount === ts.countWhere(mixinFlags, function (b) { return b; })) {
35967                 var firstMixinIndex = mixinFlags.indexOf(true);
35968                 mixinFlags[firstMixinIndex] = false;
35969             }
35970             return mixinFlags;
35971         }
35972         function includeMixinType(type, types, mixinFlags, index) {
35973             var mixedTypes = [];
35974             for (var i = 0; i < types.length; i++) {
35975                 if (i === index) {
35976                     mixedTypes.push(type);
35977                 }
35978                 else if (mixinFlags[i]) {
35979                     mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1)[0]));
35980                 }
35981             }
35982             return getIntersectionType(mixedTypes);
35983         }
35984         function resolveIntersectionTypeMembers(type) {
35985             var callSignatures;
35986             var constructSignatures;
35987             var stringIndexInfo;
35988             var numberIndexInfo;
35989             var types = type.types;
35990             var mixinFlags = findMixins(types);
35991             var mixinCount = ts.countWhere(mixinFlags, function (b) { return b; });
35992             var _loop_10 = function (i) {
35993                 var t = type.types[i];
35994                 if (!mixinFlags[i]) {
35995                     var signatures = getSignaturesOfType(t, 1);
35996                     if (signatures.length && mixinCount > 0) {
35997                         signatures = ts.map(signatures, function (s) {
35998                             var clone = cloneSignature(s);
35999                             clone.resolvedReturnType = includeMixinType(getReturnTypeOfSignature(s), types, mixinFlags, i);
36000                             return clone;
36001                         });
36002                     }
36003                     constructSignatures = appendSignatures(constructSignatures, signatures);
36004                 }
36005                 callSignatures = appendSignatures(callSignatures, getSignaturesOfType(t, 0));
36006                 stringIndexInfo = intersectIndexInfos(stringIndexInfo, getIndexInfoOfType(t, 0));
36007                 numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1));
36008             };
36009             for (var i = 0; i < types.length; i++) {
36010                 _loop_10(i);
36011             }
36012             setStructuredTypeMembers(type, emptySymbols, callSignatures || ts.emptyArray, constructSignatures || ts.emptyArray, stringIndexInfo, numberIndexInfo);
36013         }
36014         function appendSignatures(signatures, newSignatures) {
36015             var _loop_11 = function (sig) {
36016                 if (!signatures || ts.every(signatures, function (s) { return !compareSignaturesIdentical(s, sig, false, false, false, compareTypesIdentical); })) {
36017                     signatures = ts.append(signatures, sig);
36018                 }
36019             };
36020             for (var _i = 0, newSignatures_1 = newSignatures; _i < newSignatures_1.length; _i++) {
36021                 var sig = newSignatures_1[_i];
36022                 _loop_11(sig);
36023             }
36024             return signatures;
36025         }
36026         function resolveAnonymousTypeMembers(type) {
36027             var symbol = getMergedSymbol(type.symbol);
36028             if (type.target) {
36029                 setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
36030                 var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, false);
36031                 var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0), type.mapper);
36032                 var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1), type.mapper);
36033                 var stringIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, 0), type.mapper);
36034                 var numberIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, 1), type.mapper);
36035                 setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
36036             }
36037             else if (symbol.flags & 2048) {
36038                 setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
36039                 var members = getMembersOfSymbol(symbol);
36040                 var callSignatures = getSignaturesOfSymbol(members.get("__call"));
36041                 var constructSignatures = getSignaturesOfSymbol(members.get("__new"));
36042                 var stringIndexInfo = getIndexInfoOfSymbol(symbol, 0);
36043                 var numberIndexInfo = getIndexInfoOfSymbol(symbol, 1);
36044                 setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
36045             }
36046             else {
36047                 var members = emptySymbols;
36048                 var stringIndexInfo = void 0;
36049                 if (symbol.exports) {
36050                     members = getExportsOfSymbol(symbol);
36051                     if (symbol === globalThisSymbol) {
36052                         var varsOnly_1 = ts.createMap();
36053                         members.forEach(function (p) {
36054                             if (!(p.flags & 418)) {
36055                                 varsOnly_1.set(p.escapedName, p);
36056                             }
36057                         });
36058                         members = varsOnly_1;
36059                     }
36060                 }
36061                 setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, undefined, undefined);
36062                 if (symbol.flags & 32) {
36063                     var classType = getDeclaredTypeOfClassOrInterface(symbol);
36064                     var baseConstructorType = getBaseConstructorTypeOfClass(classType);
36065                     if (baseConstructorType.flags & (524288 | 2097152 | 8650752)) {
36066                         members = ts.createSymbolTable(getNamedMembers(members));
36067                         addInheritedMembers(members, getPropertiesOfType(baseConstructorType));
36068                     }
36069                     else if (baseConstructorType === anyType) {
36070                         stringIndexInfo = createIndexInfo(anyType, false);
36071                     }
36072                 }
36073                 var numberIndexInfo = symbol.flags & 384 && (getDeclaredTypeOfSymbol(symbol).flags & 32 ||
36074                     ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296); })) ? enumNumberIndexInfo : undefined;
36075                 setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo);
36076                 if (symbol.flags & (16 | 8192)) {
36077                     type.callSignatures = getSignaturesOfSymbol(symbol);
36078                 }
36079                 if (symbol.flags & 32) {
36080                     var classType_1 = getDeclaredTypeOfClassOrInterface(symbol);
36081                     var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor")) : ts.emptyArray;
36082                     if (symbol.flags & 16) {
36083                         constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ?
36084                             createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, undefined, sig.minArgumentCount, sig.flags & 3) :
36085                             undefined; }));
36086                     }
36087                     if (!constructSignatures.length) {
36088                         constructSignatures = getDefaultConstructSignatures(classType_1);
36089                     }
36090                     type.constructSignatures = constructSignatures;
36091                 }
36092             }
36093         }
36094         function resolveReverseMappedTypeMembers(type) {
36095             var indexInfo = getIndexInfoOfType(type.source, 0);
36096             var modifiers = getMappedTypeModifiers(type.mappedType);
36097             var readonlyMask = modifiers & 1 ? false : true;
36098             var optionalMask = modifiers & 4 ? 0 : 16777216;
36099             var stringIndexInfo = indexInfo && createIndexInfo(inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType), readonlyMask && indexInfo.isReadonly);
36100             var members = ts.createSymbolTable();
36101             for (var _i = 0, _a = getPropertiesOfType(type.source); _i < _a.length; _i++) {
36102                 var prop = _a[_i];
36103                 var checkFlags = 8192 | (readonlyMask && isReadonlySymbol(prop) ? 8 : 0);
36104                 var inferredProp = createSymbol(4 | prop.flags & optionalMask, prop.escapedName, checkFlags);
36105                 inferredProp.declarations = prop.declarations;
36106                 inferredProp.nameType = getSymbolLinks(prop).nameType;
36107                 inferredProp.propertyType = getTypeOfSymbol(prop);
36108                 inferredProp.mappedType = type.mappedType;
36109                 inferredProp.constraintType = type.constraintType;
36110                 members.set(prop.escapedName, inferredProp);
36111             }
36112             setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined);
36113         }
36114         function getLowerBoundOfKeyType(type) {
36115             if (type.flags & (1 | 131068)) {
36116                 return type;
36117             }
36118             if (type.flags & 4194304) {
36119                 return getIndexType(getApparentType(type.type));
36120             }
36121             if (type.flags & 16777216) {
36122                 if (type.root.isDistributive) {
36123                     var checkType = type.checkType;
36124                     var constraint = getLowerBoundOfKeyType(checkType);
36125                     if (constraint !== checkType) {
36126                         return getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
36127                     }
36128                 }
36129                 return type;
36130             }
36131             if (type.flags & 1048576) {
36132                 return getUnionType(ts.sameMap(type.types, getLowerBoundOfKeyType));
36133             }
36134             if (type.flags & 2097152) {
36135                 return getIntersectionType(ts.sameMap(type.types, getLowerBoundOfKeyType));
36136             }
36137             return neverType;
36138         }
36139         function resolveMappedTypeMembers(type) {
36140             var members = ts.createSymbolTable();
36141             var stringIndexInfo;
36142             var numberIndexInfo;
36143             setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
36144             var typeParameter = getTypeParameterFromMappedType(type);
36145             var constraintType = getConstraintTypeFromMappedType(type);
36146             var templateType = getTemplateTypeFromMappedType(type.target || type);
36147             var modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
36148             var templateModifiers = getMappedTypeModifiers(type);
36149             var include = keyofStringsOnly ? 128 : 8576;
36150             if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
36151                 for (var _i = 0, _a = getPropertiesOfType(modifiersType); _i < _a.length; _i++) {
36152                     var prop = _a[_i];
36153                     addMemberForKeyType(getLiteralTypeFromProperty(prop, include));
36154                 }
36155                 if (modifiersType.flags & 1 || getIndexInfoOfType(modifiersType, 0)) {
36156                     addMemberForKeyType(stringType);
36157                 }
36158                 if (!keyofStringsOnly && getIndexInfoOfType(modifiersType, 1)) {
36159                     addMemberForKeyType(numberType);
36160                 }
36161             }
36162             else {
36163                 forEachType(getLowerBoundOfKeyType(constraintType), addMemberForKeyType);
36164             }
36165             setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo);
36166             function addMemberForKeyType(t) {
36167                 var templateMapper = appendTypeMapping(type.mapper, typeParameter, t);
36168                 if (isTypeUsableAsPropertyName(t)) {
36169                     var propName = getPropertyNameFromType(t);
36170                     var modifiersProp = getPropertyOfType(modifiersType, propName);
36171                     var isOptional = !!(templateModifiers & 4 ||
36172                         !(templateModifiers & 8) && modifiersProp && modifiersProp.flags & 16777216);
36173                     var isReadonly = !!(templateModifiers & 1 ||
36174                         !(templateModifiers & 2) && modifiersProp && isReadonlySymbol(modifiersProp));
36175                     var stripOptional = strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216;
36176                     var prop = createSymbol(4 | (isOptional ? 16777216 : 0), propName, 262144 | (isReadonly ? 8 : 0) | (stripOptional ? 524288 : 0));
36177                     prop.mappedType = type;
36178                     prop.mapper = templateMapper;
36179                     if (modifiersProp) {
36180                         prop.syntheticOrigin = modifiersProp;
36181                         prop.declarations = modifiersProp.declarations;
36182                     }
36183                     prop.nameType = t;
36184                     members.set(propName, prop);
36185                 }
36186                 else if (t.flags & (1 | 4 | 8 | 32)) {
36187                     var propType = instantiateType(templateType, templateMapper);
36188                     if (t.flags & (1 | 4)) {
36189                         stringIndexInfo = createIndexInfo(propType, !!(templateModifiers & 1));
36190                     }
36191                     else {
36192                         numberIndexInfo = createIndexInfo(numberIndexInfo ? getUnionType([numberIndexInfo.type, propType]) : propType, !!(templateModifiers & 1));
36193                     }
36194                 }
36195             }
36196         }
36197         function getTypeOfMappedSymbol(symbol) {
36198             if (!symbol.type) {
36199                 if (!pushTypeResolution(symbol, 0)) {
36200                     return errorType;
36201                 }
36202                 var templateType = getTemplateTypeFromMappedType(symbol.mappedType.target || symbol.mappedType);
36203                 var propType = instantiateType(templateType, symbol.mapper);
36204                 var type = strictNullChecks && symbol.flags & 16777216 && !maybeTypeOfKind(propType, 32768 | 16384) ? getOptionalType(propType) :
36205                     symbol.checkFlags & 524288 ? getTypeWithFacts(propType, 524288) :
36206                         propType;
36207                 if (!popTypeResolution()) {
36208                     error(currentNode, ts.Diagnostics.Type_of_property_0_circularly_references_itself_in_mapped_type_1, symbolToString(symbol), typeToString(symbol.mappedType));
36209                     type = errorType;
36210                 }
36211                 symbol.type = type;
36212                 symbol.mapper = undefined;
36213             }
36214             return symbol.type;
36215         }
36216         function getTypeParameterFromMappedType(type) {
36217             return type.typeParameter ||
36218                 (type.typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(type.declaration.typeParameter)));
36219         }
36220         function getConstraintTypeFromMappedType(type) {
36221             return type.constraintType ||
36222                 (type.constraintType = getConstraintOfTypeParameter(getTypeParameterFromMappedType(type)) || errorType);
36223         }
36224         function getTemplateTypeFromMappedType(type) {
36225             return type.templateType ||
36226                 (type.templateType = type.declaration.type ?
36227                     instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), !!(getMappedTypeModifiers(type) & 4)), type.mapper) :
36228                     errorType);
36229         }
36230         function getConstraintDeclarationForMappedType(type) {
36231             return ts.getEffectiveConstraintOfTypeParameter(type.declaration.typeParameter);
36232         }
36233         function isMappedTypeWithKeyofConstraintDeclaration(type) {
36234             var constraintDeclaration = getConstraintDeclarationForMappedType(type);
36235             return constraintDeclaration.kind === 184 &&
36236                 constraintDeclaration.operator === 134;
36237         }
36238         function getModifiersTypeFromMappedType(type) {
36239             if (!type.modifiersType) {
36240                 if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
36241                     type.modifiersType = instantiateType(getTypeFromTypeNode(getConstraintDeclarationForMappedType(type).type), type.mapper);
36242                 }
36243                 else {
36244                     var declaredType = getTypeFromMappedTypeNode(type.declaration);
36245                     var constraint = getConstraintTypeFromMappedType(declaredType);
36246                     var extendedConstraint = constraint && constraint.flags & 262144 ? getConstraintOfTypeParameter(constraint) : constraint;
36247                     type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 ? instantiateType(extendedConstraint.type, type.mapper) : unknownType;
36248                 }
36249             }
36250             return type.modifiersType;
36251         }
36252         function getMappedTypeModifiers(type) {
36253             var declaration = type.declaration;
36254             return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 ? 2 : 1 : 0) |
36255                 (declaration.questionToken ? declaration.questionToken.kind === 40 ? 8 : 4 : 0);
36256         }
36257         function getMappedTypeOptionality(type) {
36258             var modifiers = getMappedTypeModifiers(type);
36259             return modifiers & 8 ? -1 : modifiers & 4 ? 1 : 0;
36260         }
36261         function getCombinedMappedTypeOptionality(type) {
36262             var optionality = getMappedTypeOptionality(type);
36263             var modifiersType = getModifiersTypeFromMappedType(type);
36264             return optionality || (isGenericMappedType(modifiersType) ? getMappedTypeOptionality(modifiersType) : 0);
36265         }
36266         function isPartialMappedType(type) {
36267             return !!(ts.getObjectFlags(type) & 32 && getMappedTypeModifiers(type) & 4);
36268         }
36269         function isGenericMappedType(type) {
36270             return !!(ts.getObjectFlags(type) & 32) && isGenericIndexType(getConstraintTypeFromMappedType(type));
36271         }
36272         function resolveStructuredTypeMembers(type) {
36273             if (!type.members) {
36274                 if (type.flags & 524288) {
36275                     if (type.objectFlags & 4) {
36276                         resolveTypeReferenceMembers(type);
36277                     }
36278                     else if (type.objectFlags & 3) {
36279                         resolveClassOrInterfaceMembers(type);
36280                     }
36281                     else if (type.objectFlags & 2048) {
36282                         resolveReverseMappedTypeMembers(type);
36283                     }
36284                     else if (type.objectFlags & 16) {
36285                         resolveAnonymousTypeMembers(type);
36286                     }
36287                     else if (type.objectFlags & 32) {
36288                         resolveMappedTypeMembers(type);
36289                     }
36290                 }
36291                 else if (type.flags & 1048576) {
36292                     resolveUnionTypeMembers(type);
36293                 }
36294                 else if (type.flags & 2097152) {
36295                     resolveIntersectionTypeMembers(type);
36296                 }
36297             }
36298             return type;
36299         }
36300         function getPropertiesOfObjectType(type) {
36301             if (type.flags & 524288) {
36302                 return resolveStructuredTypeMembers(type).properties;
36303             }
36304             return ts.emptyArray;
36305         }
36306         function getPropertyOfObjectType(type, name) {
36307             if (type.flags & 524288) {
36308                 var resolved = resolveStructuredTypeMembers(type);
36309                 var symbol = resolved.members.get(name);
36310                 if (symbol && symbolIsValue(symbol)) {
36311                     return symbol;
36312                 }
36313             }
36314         }
36315         function getPropertiesOfUnionOrIntersectionType(type) {
36316             if (!type.resolvedProperties) {
36317                 var members = ts.createSymbolTable();
36318                 for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
36319                     var current = _a[_i];
36320                     for (var _b = 0, _c = getPropertiesOfType(current); _b < _c.length; _b++) {
36321                         var prop = _c[_b];
36322                         if (!members.has(prop.escapedName)) {
36323                             var combinedProp = getPropertyOfUnionOrIntersectionType(type, prop.escapedName);
36324                             if (combinedProp) {
36325                                 members.set(prop.escapedName, combinedProp);
36326                             }
36327                         }
36328                     }
36329                     if (type.flags & 1048576 && !getIndexInfoOfType(current, 0) && !getIndexInfoOfType(current, 1)) {
36330                         break;
36331                     }
36332                 }
36333                 type.resolvedProperties = getNamedMembers(members);
36334             }
36335             return type.resolvedProperties;
36336         }
36337         function getPropertiesOfType(type) {
36338             type = getReducedApparentType(type);
36339             return type.flags & 3145728 ?
36340                 getPropertiesOfUnionOrIntersectionType(type) :
36341                 getPropertiesOfObjectType(type);
36342         }
36343         function isTypeInvalidDueToUnionDiscriminant(contextualType, obj) {
36344             var list = obj.properties;
36345             return list.some(function (property) {
36346                 var nameType = property.name && getLiteralTypeFromPropertyName(property.name);
36347                 var name = nameType && isTypeUsableAsPropertyName(nameType) ? getPropertyNameFromType(nameType) : undefined;
36348                 var expected = name === undefined ? undefined : getTypeOfPropertyOfType(contextualType, name);
36349                 return !!expected && isLiteralType(expected) && !isTypeAssignableTo(getTypeOfNode(property), expected);
36350             });
36351         }
36352         function getAllPossiblePropertiesOfTypes(types) {
36353             var unionType = getUnionType(types);
36354             if (!(unionType.flags & 1048576)) {
36355                 return getAugmentedPropertiesOfType(unionType);
36356             }
36357             var props = ts.createSymbolTable();
36358             for (var _i = 0, types_4 = types; _i < types_4.length; _i++) {
36359                 var memberType = types_4[_i];
36360                 for (var _a = 0, _b = getAugmentedPropertiesOfType(memberType); _a < _b.length; _a++) {
36361                     var escapedName = _b[_a].escapedName;
36362                     if (!props.has(escapedName)) {
36363                         var prop = createUnionOrIntersectionProperty(unionType, escapedName);
36364                         if (prop)
36365                             props.set(escapedName, prop);
36366                     }
36367                 }
36368             }
36369             return ts.arrayFrom(props.values());
36370         }
36371         function getConstraintOfType(type) {
36372             return type.flags & 262144 ? getConstraintOfTypeParameter(type) :
36373                 type.flags & 8388608 ? getConstraintOfIndexedAccess(type) :
36374                     type.flags & 16777216 ? getConstraintOfConditionalType(type) :
36375                         getBaseConstraintOfType(type);
36376         }
36377         function getConstraintOfTypeParameter(typeParameter) {
36378             return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : undefined;
36379         }
36380         function getConstraintOfIndexedAccess(type) {
36381             return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : undefined;
36382         }
36383         function getSimplifiedTypeOrConstraint(type) {
36384             var simplified = getSimplifiedType(type, false);
36385             return simplified !== type ? simplified : getConstraintOfType(type);
36386         }
36387         function getConstraintFromIndexedAccess(type) {
36388             var indexConstraint = getSimplifiedTypeOrConstraint(type.indexType);
36389             if (indexConstraint && indexConstraint !== type.indexType) {
36390                 var indexedAccess = getIndexedAccessTypeOrUndefined(type.objectType, indexConstraint);
36391                 if (indexedAccess) {
36392                     return indexedAccess;
36393                 }
36394             }
36395             var objectConstraint = getSimplifiedTypeOrConstraint(type.objectType);
36396             if (objectConstraint && objectConstraint !== type.objectType) {
36397                 return getIndexedAccessTypeOrUndefined(objectConstraint, type.indexType);
36398             }
36399             return undefined;
36400         }
36401         function getDefaultConstraintOfConditionalType(type) {
36402             if (!type.resolvedDefaultConstraint) {
36403                 var trueConstraint = getInferredTrueTypeFromConditionalType(type);
36404                 var falseConstraint = getFalseTypeFromConditionalType(type);
36405                 type.resolvedDefaultConstraint = isTypeAny(trueConstraint) ? falseConstraint : isTypeAny(falseConstraint) ? trueConstraint : getUnionType([trueConstraint, falseConstraint]);
36406             }
36407             return type.resolvedDefaultConstraint;
36408         }
36409         function getConstraintOfDistributiveConditionalType(type) {
36410             if (type.root.isDistributive && type.restrictiveInstantiation !== type) {
36411                 var simplified = getSimplifiedType(type.checkType, false);
36412                 var constraint = simplified === type.checkType ? getConstraintOfType(simplified) : simplified;
36413                 if (constraint && constraint !== type.checkType) {
36414                     var instantiated = getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
36415                     if (!(instantiated.flags & 131072)) {
36416                         return instantiated;
36417                     }
36418                 }
36419             }
36420             return undefined;
36421         }
36422         function getConstraintFromConditionalType(type) {
36423             return getConstraintOfDistributiveConditionalType(type) || getDefaultConstraintOfConditionalType(type);
36424         }
36425         function getConstraintOfConditionalType(type) {
36426             return hasNonCircularBaseConstraint(type) ? getConstraintFromConditionalType(type) : undefined;
36427         }
36428         function getEffectiveConstraintOfIntersection(types, targetIsUnion) {
36429             var constraints;
36430             var hasDisjointDomainType = false;
36431             for (var _i = 0, types_5 = types; _i < types_5.length; _i++) {
36432                 var t = types_5[_i];
36433                 if (t.flags & 63176704) {
36434                     var constraint = getConstraintOfType(t);
36435                     while (constraint && constraint.flags & (262144 | 4194304 | 16777216)) {
36436                         constraint = getConstraintOfType(constraint);
36437                     }
36438                     if (constraint) {
36439                         constraints = ts.append(constraints, constraint);
36440                         if (targetIsUnion) {
36441                             constraints = ts.append(constraints, t);
36442                         }
36443                     }
36444                 }
36445                 else if (t.flags & 67238908) {
36446                     hasDisjointDomainType = true;
36447                 }
36448             }
36449             if (constraints && (targetIsUnion || hasDisjointDomainType)) {
36450                 if (hasDisjointDomainType) {
36451                     for (var _a = 0, types_6 = types; _a < types_6.length; _a++) {
36452                         var t = types_6[_a];
36453                         if (t.flags & 67238908) {
36454                             constraints = ts.append(constraints, t);
36455                         }
36456                     }
36457                 }
36458                 return getIntersectionType(constraints);
36459             }
36460             return undefined;
36461         }
36462         function getBaseConstraintOfType(type) {
36463             if (type.flags & (58982400 | 3145728)) {
36464                 var constraint = getResolvedBaseConstraint(type);
36465                 return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined;
36466             }
36467             return type.flags & 4194304 ? keyofConstraintType : undefined;
36468         }
36469         function getBaseConstraintOrType(type) {
36470             return getBaseConstraintOfType(type) || type;
36471         }
36472         function hasNonCircularBaseConstraint(type) {
36473             return getResolvedBaseConstraint(type) !== circularConstraintType;
36474         }
36475         function getResolvedBaseConstraint(type) {
36476             var nonTerminating = false;
36477             return type.resolvedBaseConstraint ||
36478                 (type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), type));
36479             function getImmediateBaseConstraint(t) {
36480                 if (!t.immediateBaseConstraint) {
36481                     if (!pushTypeResolution(t, 4)) {
36482                         return circularConstraintType;
36483                     }
36484                     if (constraintDepth >= 50) {
36485                         error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
36486                         nonTerminating = true;
36487                         return t.immediateBaseConstraint = noConstraintType;
36488                     }
36489                     constraintDepth++;
36490                     var result = computeBaseConstraint(getSimplifiedType(t, false));
36491                     constraintDepth--;
36492                     if (!popTypeResolution()) {
36493                         if (t.flags & 262144) {
36494                             var errorNode = getConstraintDeclaration(t);
36495                             if (errorNode) {
36496                                 var diagnostic = error(errorNode, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(t));
36497                                 if (currentNode && !ts.isNodeDescendantOf(errorNode, currentNode) && !ts.isNodeDescendantOf(currentNode, errorNode)) {
36498                                     ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(currentNode, ts.Diagnostics.Circularity_originates_in_type_at_this_location));
36499                                 }
36500                             }
36501                         }
36502                         result = circularConstraintType;
36503                     }
36504                     if (nonTerminating) {
36505                         result = circularConstraintType;
36506                     }
36507                     t.immediateBaseConstraint = result || noConstraintType;
36508                 }
36509                 return t.immediateBaseConstraint;
36510             }
36511             function getBaseConstraint(t) {
36512                 var c = getImmediateBaseConstraint(t);
36513                 return c !== noConstraintType && c !== circularConstraintType ? c : undefined;
36514             }
36515             function computeBaseConstraint(t) {
36516                 if (t.flags & 262144) {
36517                     var constraint = getConstraintFromTypeParameter(t);
36518                     return t.isThisType || !constraint ?
36519                         constraint :
36520                         getBaseConstraint(constraint);
36521                 }
36522                 if (t.flags & 3145728) {
36523                     var types = t.types;
36524                     var baseTypes = [];
36525                     for (var _i = 0, types_7 = types; _i < types_7.length; _i++) {
36526                         var type_2 = types_7[_i];
36527                         var baseType = getBaseConstraint(type_2);
36528                         if (baseType) {
36529                             baseTypes.push(baseType);
36530                         }
36531                     }
36532                     return t.flags & 1048576 && baseTypes.length === types.length ? getUnionType(baseTypes) :
36533                         t.flags & 2097152 && baseTypes.length ? getIntersectionType(baseTypes) :
36534                             undefined;
36535                 }
36536                 if (t.flags & 4194304) {
36537                     return keyofConstraintType;
36538                 }
36539                 if (t.flags & 8388608) {
36540                     var baseObjectType = getBaseConstraint(t.objectType);
36541                     var baseIndexType = getBaseConstraint(t.indexType);
36542                     var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType);
36543                     return baseIndexedAccess && getBaseConstraint(baseIndexedAccess);
36544                 }
36545                 if (t.flags & 16777216) {
36546                     var constraint = getConstraintFromConditionalType(t);
36547                     constraintDepth++;
36548                     var result = constraint && getBaseConstraint(constraint);
36549                     constraintDepth--;
36550                     return result;
36551                 }
36552                 if (t.flags & 33554432) {
36553                     return getBaseConstraint(t.substitute);
36554                 }
36555                 return t;
36556             }
36557         }
36558         function getApparentTypeOfIntersectionType(type) {
36559             return type.resolvedApparentType || (type.resolvedApparentType = getTypeWithThisArgument(type, type, true));
36560         }
36561         function getResolvedTypeParameterDefault(typeParameter) {
36562             if (!typeParameter.default) {
36563                 if (typeParameter.target) {
36564                     var targetDefault = getResolvedTypeParameterDefault(typeParameter.target);
36565                     typeParameter.default = targetDefault ? instantiateType(targetDefault, typeParameter.mapper) : noConstraintType;
36566                 }
36567                 else {
36568                     typeParameter.default = resolvingDefaultType;
36569                     var defaultDeclaration = typeParameter.symbol && ts.forEach(typeParameter.symbol.declarations, function (decl) { return ts.isTypeParameterDeclaration(decl) && decl.default; });
36570                     var defaultType = defaultDeclaration ? getTypeFromTypeNode(defaultDeclaration) : noConstraintType;
36571                     if (typeParameter.default === resolvingDefaultType) {
36572                         typeParameter.default = defaultType;
36573                     }
36574                 }
36575             }
36576             else if (typeParameter.default === resolvingDefaultType) {
36577                 typeParameter.default = circularConstraintType;
36578             }
36579             return typeParameter.default;
36580         }
36581         function getDefaultFromTypeParameter(typeParameter) {
36582             var defaultType = getResolvedTypeParameterDefault(typeParameter);
36583             return defaultType !== noConstraintType && defaultType !== circularConstraintType ? defaultType : undefined;
36584         }
36585         function hasNonCircularTypeParameterDefault(typeParameter) {
36586             return getResolvedTypeParameterDefault(typeParameter) !== circularConstraintType;
36587         }
36588         function hasTypeParameterDefault(typeParameter) {
36589             return !!(typeParameter.symbol && ts.forEach(typeParameter.symbol.declarations, function (decl) { return ts.isTypeParameterDeclaration(decl) && decl.default; }));
36590         }
36591         function getApparentTypeOfMappedType(type) {
36592             return type.resolvedApparentType || (type.resolvedApparentType = getResolvedApparentTypeOfMappedType(type));
36593         }
36594         function getResolvedApparentTypeOfMappedType(type) {
36595             var typeVariable = getHomomorphicTypeVariable(type);
36596             if (typeVariable) {
36597                 var constraint = getConstraintOfTypeParameter(typeVariable);
36598                 if (constraint && (isArrayType(constraint) || isTupleType(constraint))) {
36599                     return instantiateType(type, prependTypeMapping(typeVariable, constraint, type.mapper));
36600                 }
36601             }
36602             return type;
36603         }
36604         function getApparentType(type) {
36605             var t = type.flags & 63176704 ? getBaseConstraintOfType(type) || unknownType : type;
36606             return ts.getObjectFlags(t) & 32 ? getApparentTypeOfMappedType(t) :
36607                 t.flags & 2097152 ? getApparentTypeOfIntersectionType(t) :
36608                     t.flags & 132 ? globalStringType :
36609                         t.flags & 296 ? globalNumberType :
36610                             t.flags & 2112 ? getGlobalBigIntType(languageVersion >= 7) :
36611                                 t.flags & 528 ? globalBooleanType :
36612                                     t.flags & 12288 ? getGlobalESSymbolType(languageVersion >= 2) :
36613                                         t.flags & 67108864 ? emptyObjectType :
36614                                             t.flags & 4194304 ? keyofConstraintType :
36615                                                 t.flags & 2 && !strictNullChecks ? emptyObjectType :
36616                                                     t;
36617         }
36618         function getReducedApparentType(type) {
36619             return getReducedType(getApparentType(getReducedType(type)));
36620         }
36621         function createUnionOrIntersectionProperty(containingType, name) {
36622             var singleProp;
36623             var propSet;
36624             var indexTypes;
36625             var isUnion = containingType.flags & 1048576;
36626             var optionalFlag = isUnion ? 0 : 16777216;
36627             var syntheticFlag = 4;
36628             var checkFlags = 0;
36629             for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) {
36630                 var current = _a[_i];
36631                 var type = getApparentType(current);
36632                 if (!(type === errorType || type.flags & 131072)) {
36633                     var prop = getPropertyOfType(type, name);
36634                     var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0;
36635                     if (prop) {
36636                         if (isUnion) {
36637                             optionalFlag |= (prop.flags & 16777216);
36638                         }
36639                         else {
36640                             optionalFlag &= prop.flags;
36641                         }
36642                         if (!singleProp) {
36643                             singleProp = prop;
36644                         }
36645                         else if (prop !== singleProp) {
36646                             if (!propSet) {
36647                                 propSet = ts.createMap();
36648                                 propSet.set("" + getSymbolId(singleProp), singleProp);
36649                             }
36650                             var id = "" + getSymbolId(prop);
36651                             if (!propSet.has(id)) {
36652                                 propSet.set(id, prop);
36653                             }
36654                         }
36655                         checkFlags |= (isReadonlySymbol(prop) ? 8 : 0) |
36656                             (!(modifiers & 24) ? 256 : 0) |
36657                             (modifiers & 16 ? 512 : 0) |
36658                             (modifiers & 8 ? 1024 : 0) |
36659                             (modifiers & 32 ? 2048 : 0);
36660                         if (!isPrototypeProperty(prop)) {
36661                             syntheticFlag = 2;
36662                         }
36663                     }
36664                     else if (isUnion) {
36665                         var indexInfo = !isLateBoundName(name) && (isNumericLiteralName(name) && getIndexInfoOfType(type, 1) || getIndexInfoOfType(type, 0));
36666                         if (indexInfo) {
36667                             checkFlags |= 32 | (indexInfo.isReadonly ? 8 : 0);
36668                             indexTypes = ts.append(indexTypes, isTupleType(type) ? getRestTypeOfTupleType(type) || undefinedType : indexInfo.type);
36669                         }
36670                         else if (isObjectLiteralType(type)) {
36671                             checkFlags |= 32;
36672                             indexTypes = ts.append(indexTypes, undefinedType);
36673                         }
36674                         else {
36675                             checkFlags |= 16;
36676                         }
36677                     }
36678                 }
36679             }
36680             if (!singleProp || isUnion && (propSet || checkFlags & 48) && checkFlags & (1024 | 512)) {
36681                 return undefined;
36682             }
36683             if (!propSet && !(checkFlags & 16) && !indexTypes) {
36684                 return singleProp;
36685             }
36686             var props = propSet ? ts.arrayFrom(propSet.values()) : [singleProp];
36687             var declarations;
36688             var firstType;
36689             var nameType;
36690             var propTypes = [];
36691             var firstValueDeclaration;
36692             var hasNonUniformValueDeclaration = false;
36693             for (var _b = 0, props_1 = props; _b < props_1.length; _b++) {
36694                 var prop = props_1[_b];
36695                 if (!firstValueDeclaration) {
36696                     firstValueDeclaration = prop.valueDeclaration;
36697                 }
36698                 else if (prop.valueDeclaration && prop.valueDeclaration !== firstValueDeclaration) {
36699                     hasNonUniformValueDeclaration = true;
36700                 }
36701                 declarations = ts.addRange(declarations, prop.declarations);
36702                 var type = getTypeOfSymbol(prop);
36703                 if (!firstType) {
36704                     firstType = type;
36705                     nameType = getSymbolLinks(prop).nameType;
36706                 }
36707                 else if (type !== firstType) {
36708                     checkFlags |= 64;
36709                 }
36710                 if (isLiteralType(type)) {
36711                     checkFlags |= 128;
36712                 }
36713                 if (type.flags & 131072) {
36714                     checkFlags |= 131072;
36715                 }
36716                 propTypes.push(type);
36717             }
36718             ts.addRange(propTypes, indexTypes);
36719             var result = createSymbol(4 | optionalFlag, name, syntheticFlag | checkFlags);
36720             result.containingType = containingType;
36721             if (!hasNonUniformValueDeclaration && firstValueDeclaration) {
36722                 result.valueDeclaration = firstValueDeclaration;
36723                 if (firstValueDeclaration.symbol.parent) {
36724                     result.parent = firstValueDeclaration.symbol.parent;
36725                 }
36726             }
36727             result.declarations = declarations;
36728             result.nameType = nameType;
36729             if (propTypes.length > 2) {
36730                 result.checkFlags |= 65536;
36731                 result.deferralParent = containingType;
36732                 result.deferralConstituents = propTypes;
36733             }
36734             else {
36735                 result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes);
36736             }
36737             return result;
36738         }
36739         function getUnionOrIntersectionProperty(type, name) {
36740             var properties = type.propertyCache || (type.propertyCache = ts.createSymbolTable());
36741             var property = properties.get(name);
36742             if (!property) {
36743                 property = createUnionOrIntersectionProperty(type, name);
36744                 if (property) {
36745                     properties.set(name, property);
36746                 }
36747             }
36748             return property;
36749         }
36750         function getPropertyOfUnionOrIntersectionType(type, name) {
36751             var property = getUnionOrIntersectionProperty(type, name);
36752             return property && !(ts.getCheckFlags(property) & 16) ? property : undefined;
36753         }
36754         function getReducedType(type) {
36755             if (type.flags & 1048576 && type.objectFlags & 268435456) {
36756                 return type.resolvedReducedType || (type.resolvedReducedType = getReducedUnionType(type));
36757             }
36758             else if (type.flags & 2097152) {
36759                 if (!(type.objectFlags & 268435456)) {
36760                     type.objectFlags |= 268435456 |
36761                         (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 536870912 : 0);
36762                 }
36763                 return type.objectFlags & 536870912 ? neverType : type;
36764             }
36765             return type;
36766         }
36767         function getReducedUnionType(unionType) {
36768             var reducedTypes = ts.sameMap(unionType.types, getReducedType);
36769             if (reducedTypes === unionType.types) {
36770                 return unionType;
36771             }
36772             var reduced = getUnionType(reducedTypes);
36773             if (reduced.flags & 1048576) {
36774                 reduced.resolvedReducedType = reduced;
36775             }
36776             return reduced;
36777         }
36778         function isNeverReducedProperty(prop) {
36779             return isDiscriminantWithNeverType(prop) || isConflictingPrivateProperty(prop);
36780         }
36781         function isDiscriminantWithNeverType(prop) {
36782             return !(prop.flags & 16777216) &&
36783                 (ts.getCheckFlags(prop) & (192 | 131072)) === 192 &&
36784                 !!(getTypeOfSymbol(prop).flags & 131072);
36785         }
36786         function isConflictingPrivateProperty(prop) {
36787             return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024);
36788         }
36789         function elaborateNeverIntersection(errorInfo, type) {
36790             if (ts.getObjectFlags(type) & 536870912) {
36791                 var neverProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isDiscriminantWithNeverType);
36792                 if (neverProp) {
36793                     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));
36794                 }
36795                 var privateProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isConflictingPrivateProperty);
36796                 if (privateProp) {
36797                     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));
36798                 }
36799             }
36800             return errorInfo;
36801         }
36802         function getPropertyOfType(type, name) {
36803             type = getReducedApparentType(type);
36804             if (type.flags & 524288) {
36805                 var resolved = resolveStructuredTypeMembers(type);
36806                 var symbol = resolved.members.get(name);
36807                 if (symbol && symbolIsValue(symbol)) {
36808                     return symbol;
36809                 }
36810                 var functionType = resolved === anyFunctionType ? globalFunctionType :
36811                     resolved.callSignatures.length ? globalCallableFunctionType :
36812                         resolved.constructSignatures.length ? globalNewableFunctionType :
36813                             undefined;
36814                 if (functionType) {
36815                     var symbol_1 = getPropertyOfObjectType(functionType, name);
36816                     if (symbol_1) {
36817                         return symbol_1;
36818                     }
36819                 }
36820                 return getPropertyOfObjectType(globalObjectType, name);
36821             }
36822             if (type.flags & 3145728) {
36823                 return getPropertyOfUnionOrIntersectionType(type, name);
36824             }
36825             return undefined;
36826         }
36827         function getSignaturesOfStructuredType(type, kind) {
36828             if (type.flags & 3670016) {
36829                 var resolved = resolveStructuredTypeMembers(type);
36830                 return kind === 0 ? resolved.callSignatures : resolved.constructSignatures;
36831             }
36832             return ts.emptyArray;
36833         }
36834         function getSignaturesOfType(type, kind) {
36835             return getSignaturesOfStructuredType(getReducedApparentType(type), kind);
36836         }
36837         function getIndexInfoOfStructuredType(type, kind) {
36838             if (type.flags & 3670016) {
36839                 var resolved = resolveStructuredTypeMembers(type);
36840                 return kind === 0 ? resolved.stringIndexInfo : resolved.numberIndexInfo;
36841             }
36842         }
36843         function getIndexTypeOfStructuredType(type, kind) {
36844             var info = getIndexInfoOfStructuredType(type, kind);
36845             return info && info.type;
36846         }
36847         function getIndexInfoOfType(type, kind) {
36848             return getIndexInfoOfStructuredType(getReducedApparentType(type), kind);
36849         }
36850         function getIndexTypeOfType(type, kind) {
36851             return getIndexTypeOfStructuredType(getReducedApparentType(type), kind);
36852         }
36853         function getImplicitIndexTypeOfType(type, kind) {
36854             if (isObjectTypeWithInferableIndex(type)) {
36855                 var propTypes = [];
36856                 for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) {
36857                     var prop = _a[_i];
36858                     if (kind === 0 || isNumericLiteralName(prop.escapedName)) {
36859                         propTypes.push(getTypeOfSymbol(prop));
36860                     }
36861                 }
36862                 if (kind === 0) {
36863                     ts.append(propTypes, getIndexTypeOfType(type, 1));
36864                 }
36865                 if (propTypes.length) {
36866                     return getUnionType(propTypes);
36867                 }
36868             }
36869             return undefined;
36870         }
36871         function getTypeParametersFromDeclaration(declaration) {
36872             var result;
36873             for (var _i = 0, _a = ts.getEffectiveTypeParameterDeclarations(declaration); _i < _a.length; _i++) {
36874                 var node = _a[_i];
36875                 result = ts.appendIfUnique(result, getDeclaredTypeOfTypeParameter(node.symbol));
36876             }
36877             return result;
36878         }
36879         function symbolsToArray(symbols) {
36880             var result = [];
36881             symbols.forEach(function (symbol, id) {
36882                 if (!isReservedMemberName(id)) {
36883                     result.push(symbol);
36884                 }
36885             });
36886             return result;
36887         }
36888         function isJSDocOptionalParameter(node) {
36889             return ts.isInJSFile(node) && (node.type && node.type.kind === 299
36890                 || ts.getJSDocParameterTags(node).some(function (_a) {
36891                     var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression;
36892                     return isBracketed || !!typeExpression && typeExpression.type.kind === 299;
36893                 }));
36894         }
36895         function tryFindAmbientModule(moduleName, withAugmentations) {
36896             if (ts.isExternalModuleNameRelative(moduleName)) {
36897                 return undefined;
36898             }
36899             var symbol = getSymbol(globals, '"' + moduleName + '"', 512);
36900             return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol;
36901         }
36902         function isOptionalParameter(node) {
36903             if (ts.hasQuestionToken(node) || isOptionalJSDocParameterTag(node) || isJSDocOptionalParameter(node)) {
36904                 return true;
36905             }
36906             if (node.initializer) {
36907                 var signature = getSignatureFromDeclaration(node.parent);
36908                 var parameterIndex = node.parent.parameters.indexOf(node);
36909                 ts.Debug.assert(parameterIndex >= 0);
36910                 return parameterIndex >= getMinArgumentCount(signature, true);
36911             }
36912             var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent);
36913             if (iife) {
36914                 return !node.type &&
36915                     !node.dotDotDotToken &&
36916                     node.parent.parameters.indexOf(node) >= iife.arguments.length;
36917             }
36918             return false;
36919         }
36920         function isOptionalJSDocParameterTag(node) {
36921             if (!ts.isJSDocParameterTag(node)) {
36922                 return false;
36923             }
36924             var isBracketed = node.isBracketed, typeExpression = node.typeExpression;
36925             return isBracketed || !!typeExpression && typeExpression.type.kind === 299;
36926         }
36927         function createTypePredicate(kind, parameterName, parameterIndex, type) {
36928             return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type };
36929         }
36930         function getMinTypeArgumentCount(typeParameters) {
36931             var minTypeArgumentCount = 0;
36932             if (typeParameters) {
36933                 for (var i = 0; i < typeParameters.length; i++) {
36934                     if (!hasTypeParameterDefault(typeParameters[i])) {
36935                         minTypeArgumentCount = i + 1;
36936                     }
36937                 }
36938             }
36939             return minTypeArgumentCount;
36940         }
36941         function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount, isJavaScriptImplicitAny) {
36942             var numTypeParameters = ts.length(typeParameters);
36943             if (!numTypeParameters) {
36944                 return [];
36945             }
36946             var numTypeArguments = ts.length(typeArguments);
36947             if (isJavaScriptImplicitAny || (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters)) {
36948                 var result = typeArguments ? typeArguments.slice() : [];
36949                 for (var i = numTypeArguments; i < numTypeParameters; i++) {
36950                     result[i] = errorType;
36951                 }
36952                 var baseDefaultType = getDefaultTypeArgumentType(isJavaScriptImplicitAny);
36953                 for (var i = numTypeArguments; i < numTypeParameters; i++) {
36954                     var defaultType = getDefaultFromTypeParameter(typeParameters[i]);
36955                     if (isJavaScriptImplicitAny && defaultType && (isTypeIdenticalTo(defaultType, unknownType) || isTypeIdenticalTo(defaultType, emptyObjectType))) {
36956                         defaultType = anyType;
36957                     }
36958                     result[i] = defaultType ? instantiateType(defaultType, createTypeMapper(typeParameters, result)) : baseDefaultType;
36959                 }
36960                 result.length = typeParameters.length;
36961                 return result;
36962             }
36963             return typeArguments && typeArguments.slice();
36964         }
36965         function getSignatureFromDeclaration(declaration) {
36966             var links = getNodeLinks(declaration);
36967             if (!links.resolvedSignature) {
36968                 var parameters = [];
36969                 var flags = 0;
36970                 var minArgumentCount = 0;
36971                 var thisParameter = void 0;
36972                 var hasThisParameter = false;
36973                 var iife = ts.getImmediatelyInvokedFunctionExpression(declaration);
36974                 var isJSConstructSignature = ts.isJSDocConstructSignature(declaration);
36975                 var isUntypedSignatureInJSFile = !iife &&
36976                     ts.isInJSFile(declaration) &&
36977                     ts.isValueSignatureDeclaration(declaration) &&
36978                     !ts.hasJSDocParameterTags(declaration) &&
36979                     !ts.getJSDocType(declaration);
36980                 if (isUntypedSignatureInJSFile) {
36981                     flags |= 16;
36982                 }
36983                 for (var i = isJSConstructSignature ? 1 : 0; i < declaration.parameters.length; i++) {
36984                     var param = declaration.parameters[i];
36985                     var paramSymbol = param.symbol;
36986                     var type = ts.isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type;
36987                     if (paramSymbol && !!(paramSymbol.flags & 4) && !ts.isBindingPattern(param.name)) {
36988                         var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551, undefined, undefined, false);
36989                         paramSymbol = resolvedSymbol;
36990                     }
36991                     if (i === 0 && paramSymbol.escapedName === "this") {
36992                         hasThisParameter = true;
36993                         thisParameter = param.symbol;
36994                     }
36995                     else {
36996                         parameters.push(paramSymbol);
36997                     }
36998                     if (type && type.kind === 187) {
36999                         flags |= 2;
37000                     }
37001                     var isOptionalParameter_1 = isOptionalJSDocParameterTag(param) ||
37002                         param.initializer || param.questionToken || param.dotDotDotToken ||
37003                         iife && parameters.length > iife.arguments.length && !type ||
37004                         isJSDocOptionalParameter(param);
37005                     if (!isOptionalParameter_1) {
37006                         minArgumentCount = parameters.length;
37007                     }
37008                 }
37009                 if ((declaration.kind === 163 || declaration.kind === 164) &&
37010                     !hasNonBindableDynamicName(declaration) &&
37011                     (!hasThisParameter || !thisParameter)) {
37012                     var otherKind = declaration.kind === 163 ? 164 : 163;
37013                     var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind);
37014                     if (other) {
37015                         thisParameter = getAnnotatedAccessorThisParameter(other);
37016                     }
37017                 }
37018                 var classType = declaration.kind === 162 ?
37019                     getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol))
37020                     : undefined;
37021                 var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration);
37022                 if (ts.hasRestParameter(declaration) || ts.isInJSFile(declaration) && maybeAddJsSyntheticRestParameter(declaration, parameters)) {
37023                     flags |= 1;
37024                 }
37025                 links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, undefined, undefined, minArgumentCount, flags);
37026             }
37027             return links.resolvedSignature;
37028         }
37029         function maybeAddJsSyntheticRestParameter(declaration, parameters) {
37030             if (ts.isJSDocSignature(declaration) || !containsArgumentsReference(declaration)) {
37031                 return false;
37032             }
37033             var lastParam = ts.lastOrUndefined(declaration.parameters);
37034             var lastParamTags = lastParam ? ts.getJSDocParameterTags(lastParam) : ts.getJSDocTags(declaration).filter(ts.isJSDocParameterTag);
37035             var lastParamVariadicType = ts.firstDefined(lastParamTags, function (p) {
37036                 return p.typeExpression && ts.isJSDocVariadicType(p.typeExpression.type) ? p.typeExpression.type : undefined;
37037             });
37038             var syntheticArgsSymbol = createSymbol(3, "args", 32768);
37039             syntheticArgsSymbol.type = lastParamVariadicType ? createArrayType(getTypeFromTypeNode(lastParamVariadicType.type)) : anyArrayType;
37040             if (lastParamVariadicType) {
37041                 parameters.pop();
37042             }
37043             parameters.push(syntheticArgsSymbol);
37044             return true;
37045         }
37046         function getSignatureOfTypeTag(node) {
37047             if (!(ts.isInJSFile(node) && ts.isFunctionLikeDeclaration(node)))
37048                 return undefined;
37049             var typeTag = ts.getJSDocTypeTag(node);
37050             var signature = typeTag && typeTag.typeExpression && getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression));
37051             return signature && getErasedSignature(signature);
37052         }
37053         function getReturnTypeOfTypeTag(node) {
37054             var signature = getSignatureOfTypeTag(node);
37055             return signature && getReturnTypeOfSignature(signature);
37056         }
37057         function containsArgumentsReference(declaration) {
37058             var links = getNodeLinks(declaration);
37059             if (links.containsArgumentsReference === undefined) {
37060                 if (links.flags & 8192) {
37061                     links.containsArgumentsReference = true;
37062                 }
37063                 else {
37064                     links.containsArgumentsReference = traverse(declaration.body);
37065                 }
37066             }
37067             return links.containsArgumentsReference;
37068             function traverse(node) {
37069                 if (!node)
37070                     return false;
37071                 switch (node.kind) {
37072                     case 75:
37073                         return node.escapedText === "arguments" && ts.isExpressionNode(node);
37074                     case 159:
37075                     case 161:
37076                     case 163:
37077                     case 164:
37078                         return node.name.kind === 154
37079                             && traverse(node.name);
37080                     default:
37081                         return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse);
37082                 }
37083             }
37084         }
37085         function getSignaturesOfSymbol(symbol) {
37086             if (!symbol)
37087                 return ts.emptyArray;
37088             var result = [];
37089             for (var i = 0; i < symbol.declarations.length; i++) {
37090                 var decl = symbol.declarations[i];
37091                 if (!ts.isFunctionLike(decl))
37092                     continue;
37093                 if (i > 0 && decl.body) {
37094                     var previous = symbol.declarations[i - 1];
37095                     if (decl.parent === previous.parent && decl.kind === previous.kind && decl.pos === previous.end) {
37096                         continue;
37097                     }
37098                 }
37099                 result.push(getSignatureFromDeclaration(decl));
37100             }
37101             return result;
37102         }
37103         function resolveExternalModuleTypeByLiteral(name) {
37104             var moduleSym = resolveExternalModuleName(name, name);
37105             if (moduleSym) {
37106                 var resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym);
37107                 if (resolvedModuleSymbol) {
37108                     return getTypeOfSymbol(resolvedModuleSymbol);
37109                 }
37110             }
37111             return anyType;
37112         }
37113         function getThisTypeOfSignature(signature) {
37114             if (signature.thisParameter) {
37115                 return getTypeOfSymbol(signature.thisParameter);
37116             }
37117         }
37118         function getTypePredicateOfSignature(signature) {
37119             if (!signature.resolvedTypePredicate) {
37120                 if (signature.target) {
37121                     var targetTypePredicate = getTypePredicateOfSignature(signature.target);
37122                     signature.resolvedTypePredicate = targetTypePredicate ? instantiateTypePredicate(targetTypePredicate, signature.mapper) : noTypePredicate;
37123                 }
37124                 else if (signature.unionSignatures) {
37125                     signature.resolvedTypePredicate = getUnionTypePredicate(signature.unionSignatures) || noTypePredicate;
37126                 }
37127                 else {
37128                     var type = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration);
37129                     var jsdocPredicate = void 0;
37130                     if (!type && ts.isInJSFile(signature.declaration)) {
37131                         var jsdocSignature = getSignatureOfTypeTag(signature.declaration);
37132                         if (jsdocSignature && signature !== jsdocSignature) {
37133                             jsdocPredicate = getTypePredicateOfSignature(jsdocSignature);
37134                         }
37135                     }
37136                     signature.resolvedTypePredicate = type && ts.isTypePredicateNode(type) ?
37137                         createTypePredicateFromTypePredicateNode(type, signature) :
37138                         jsdocPredicate || noTypePredicate;
37139                 }
37140                 ts.Debug.assert(!!signature.resolvedTypePredicate);
37141             }
37142             return signature.resolvedTypePredicate === noTypePredicate ? undefined : signature.resolvedTypePredicate;
37143         }
37144         function createTypePredicateFromTypePredicateNode(node, signature) {
37145             var parameterName = node.parameterName;
37146             var type = node.type && getTypeFromTypeNode(node.type);
37147             return parameterName.kind === 183 ?
37148                 createTypePredicate(node.assertsModifier ? 2 : 0, undefined, undefined, type) :
37149                 createTypePredicate(node.assertsModifier ? 3 : 1, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type);
37150         }
37151         function getReturnTypeOfSignature(signature) {
37152             if (!signature.resolvedReturnType) {
37153                 if (!pushTypeResolution(signature, 3)) {
37154                     return errorType;
37155                 }
37156                 var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) :
37157                     signature.unionSignatures ? getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2) :
37158                         getReturnTypeFromAnnotation(signature.declaration) ||
37159                             (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration));
37160                 if (signature.flags & 4) {
37161                     type = addOptionalTypeMarker(type);
37162                 }
37163                 else if (signature.flags & 8) {
37164                     type = getOptionalType(type);
37165                 }
37166                 if (!popTypeResolution()) {
37167                     if (signature.declaration) {
37168                         var typeNode = ts.getEffectiveReturnTypeNode(signature.declaration);
37169                         if (typeNode) {
37170                             error(typeNode, ts.Diagnostics.Return_type_annotation_circularly_references_itself);
37171                         }
37172                         else if (noImplicitAny) {
37173                             var declaration = signature.declaration;
37174                             var name = ts.getNameOfDeclaration(declaration);
37175                             if (name) {
37176                                 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));
37177                             }
37178                             else {
37179                                 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);
37180                             }
37181                         }
37182                     }
37183                     type = anyType;
37184                 }
37185                 signature.resolvedReturnType = type;
37186             }
37187             return signature.resolvedReturnType;
37188         }
37189         function getReturnTypeFromAnnotation(declaration) {
37190             if (declaration.kind === 162) {
37191                 return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol));
37192             }
37193             if (ts.isJSDocConstructSignature(declaration)) {
37194                 return getTypeFromTypeNode(declaration.parameters[0].type);
37195             }
37196             var typeNode = ts.getEffectiveReturnTypeNode(declaration);
37197             if (typeNode) {
37198                 return getTypeFromTypeNode(typeNode);
37199             }
37200             if (declaration.kind === 163 && !hasNonBindableDynamicName(declaration)) {
37201                 var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration);
37202                 if (jsDocType) {
37203                     return jsDocType;
37204                 }
37205                 var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 164);
37206                 var setterType = getAnnotatedAccessorType(setter);
37207                 if (setterType) {
37208                     return setterType;
37209                 }
37210             }
37211             return getReturnTypeOfTypeTag(declaration);
37212         }
37213         function isResolvingReturnTypeOfSignature(signature) {
37214             return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3) >= 0;
37215         }
37216         function getRestTypeOfSignature(signature) {
37217             return tryGetRestTypeOfSignature(signature) || anyType;
37218         }
37219         function tryGetRestTypeOfSignature(signature) {
37220             if (signatureHasRestParameter(signature)) {
37221                 var sigRestType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]);
37222                 var restType = isTupleType(sigRestType) ? getRestTypeOfTupleType(sigRestType) : sigRestType;
37223                 return restType && getIndexTypeOfType(restType, 1);
37224             }
37225             return undefined;
37226         }
37227         function getSignatureInstantiation(signature, typeArguments, isJavascript, inferredTypeParameters) {
37228             var instantiatedSignature = getSignatureInstantiationWithoutFillingInTypeArguments(signature, fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript));
37229             if (inferredTypeParameters) {
37230                 var returnSignature = getSingleCallOrConstructSignature(getReturnTypeOfSignature(instantiatedSignature));
37231                 if (returnSignature) {
37232                     var newReturnSignature = cloneSignature(returnSignature);
37233                     newReturnSignature.typeParameters = inferredTypeParameters;
37234                     var newInstantiatedSignature = cloneSignature(instantiatedSignature);
37235                     newInstantiatedSignature.resolvedReturnType = getOrCreateTypeFromSignature(newReturnSignature);
37236                     return newInstantiatedSignature;
37237                 }
37238             }
37239             return instantiatedSignature;
37240         }
37241         function getSignatureInstantiationWithoutFillingInTypeArguments(signature, typeArguments) {
37242             var instantiations = signature.instantiations || (signature.instantiations = ts.createMap());
37243             var id = getTypeListId(typeArguments);
37244             var instantiation = instantiations.get(id);
37245             if (!instantiation) {
37246                 instantiations.set(id, instantiation = createSignatureInstantiation(signature, typeArguments));
37247             }
37248             return instantiation;
37249         }
37250         function createSignatureInstantiation(signature, typeArguments) {
37251             return instantiateSignature(signature, createSignatureTypeMapper(signature, typeArguments), true);
37252         }
37253         function createSignatureTypeMapper(signature, typeArguments) {
37254             return createTypeMapper(signature.typeParameters, typeArguments);
37255         }
37256         function getErasedSignature(signature) {
37257             return signature.typeParameters ?
37258                 signature.erasedSignatureCache || (signature.erasedSignatureCache = createErasedSignature(signature)) :
37259                 signature;
37260         }
37261         function createErasedSignature(signature) {
37262             return instantiateSignature(signature, createTypeEraser(signature.typeParameters), true);
37263         }
37264         function getCanonicalSignature(signature) {
37265             return signature.typeParameters ?
37266                 signature.canonicalSignatureCache || (signature.canonicalSignatureCache = createCanonicalSignature(signature)) :
37267                 signature;
37268         }
37269         function createCanonicalSignature(signature) {
37270             return getSignatureInstantiation(signature, ts.map(signature.typeParameters, function (tp) { return tp.target && !getConstraintOfTypeParameter(tp.target) ? tp.target : tp; }), ts.isInJSFile(signature.declaration));
37271         }
37272         function getBaseSignature(signature) {
37273             var typeParameters = signature.typeParameters;
37274             if (typeParameters) {
37275                 var typeEraser_1 = createTypeEraser(typeParameters);
37276                 var baseConstraints = ts.map(typeParameters, function (tp) { return instantiateType(getBaseConstraintOfType(tp), typeEraser_1) || unknownType; });
37277                 return instantiateSignature(signature, createTypeMapper(typeParameters, baseConstraints), true);
37278             }
37279             return signature;
37280         }
37281         function getOrCreateTypeFromSignature(signature) {
37282             if (!signature.isolatedSignatureType) {
37283                 var kind = signature.declaration ? signature.declaration.kind : 0;
37284                 var isConstructor = kind === 162 || kind === 166 || kind === 171;
37285                 var type = createObjectType(16);
37286                 type.members = emptySymbols;
37287                 type.properties = ts.emptyArray;
37288                 type.callSignatures = !isConstructor ? [signature] : ts.emptyArray;
37289                 type.constructSignatures = isConstructor ? [signature] : ts.emptyArray;
37290                 signature.isolatedSignatureType = type;
37291             }
37292             return signature.isolatedSignatureType;
37293         }
37294         function getIndexSymbol(symbol) {
37295             return symbol.members.get("__index");
37296         }
37297         function getIndexDeclarationOfSymbol(symbol, kind) {
37298             var syntaxKind = kind === 1 ? 140 : 143;
37299             var indexSymbol = getIndexSymbol(symbol);
37300             if (indexSymbol) {
37301                 for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
37302                     var decl = _a[_i];
37303                     var node = ts.cast(decl, ts.isIndexSignatureDeclaration);
37304                     if (node.parameters.length === 1) {
37305                         var parameter = node.parameters[0];
37306                         if (parameter.type && parameter.type.kind === syntaxKind) {
37307                             return node;
37308                         }
37309                     }
37310                 }
37311             }
37312             return undefined;
37313         }
37314         function createIndexInfo(type, isReadonly, declaration) {
37315             return { type: type, isReadonly: isReadonly, declaration: declaration };
37316         }
37317         function getIndexInfoOfSymbol(symbol, kind) {
37318             var declaration = getIndexDeclarationOfSymbol(symbol, kind);
37319             if (declaration) {
37320                 return createIndexInfo(declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasModifier(declaration, 64), declaration);
37321             }
37322             return undefined;
37323         }
37324         function getConstraintDeclaration(type) {
37325             return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0];
37326         }
37327         function getInferredTypeParameterConstraint(typeParameter) {
37328             var inferences;
37329             if (typeParameter.symbol) {
37330                 for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) {
37331                     var declaration = _a[_i];
37332                     if (declaration.parent.kind === 181) {
37333                         var grandParent = declaration.parent.parent;
37334                         if (grandParent.kind === 169) {
37335                             var typeReference = grandParent;
37336                             var typeParameters = getTypeParametersForTypeReference(typeReference);
37337                             if (typeParameters) {
37338                                 var index = typeReference.typeArguments.indexOf(declaration.parent);
37339                                 if (index < typeParameters.length) {
37340                                     var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]);
37341                                     if (declaredConstraint) {
37342                                         var mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters));
37343                                         var constraint = instantiateType(declaredConstraint, mapper);
37344                                         if (constraint !== typeParameter) {
37345                                             inferences = ts.append(inferences, constraint);
37346                                         }
37347                                     }
37348                                 }
37349                             }
37350                         }
37351                         else if (grandParent.kind === 156 && grandParent.dotDotDotToken) {
37352                             inferences = ts.append(inferences, createArrayType(unknownType));
37353                         }
37354                     }
37355                 }
37356             }
37357             return inferences && getIntersectionType(inferences);
37358         }
37359         function getConstraintFromTypeParameter(typeParameter) {
37360             if (!typeParameter.constraint) {
37361                 if (typeParameter.target) {
37362                     var targetConstraint = getConstraintOfTypeParameter(typeParameter.target);
37363                     typeParameter.constraint = targetConstraint ? instantiateType(targetConstraint, typeParameter.mapper) : noConstraintType;
37364                 }
37365                 else {
37366                     var constraintDeclaration = getConstraintDeclaration(typeParameter);
37367                     if (!constraintDeclaration) {
37368                         typeParameter.constraint = getInferredTypeParameterConstraint(typeParameter) || noConstraintType;
37369                     }
37370                     else {
37371                         var type = getTypeFromTypeNode(constraintDeclaration);
37372                         if (type.flags & 1 && type !== errorType) {
37373                             type = constraintDeclaration.parent.parent.kind === 186 ? keyofConstraintType : unknownType;
37374                         }
37375                         typeParameter.constraint = type;
37376                     }
37377                 }
37378             }
37379             return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint;
37380         }
37381         function getParentSymbolOfTypeParameter(typeParameter) {
37382             var tp = ts.getDeclarationOfKind(typeParameter.symbol, 155);
37383             var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent;
37384             return host && getSymbolOfNode(host);
37385         }
37386         function getTypeListId(types) {
37387             var result = "";
37388             if (types) {
37389                 var length_4 = types.length;
37390                 var i = 0;
37391                 while (i < length_4) {
37392                     var startId = types[i].id;
37393                     var count = 1;
37394                     while (i + count < length_4 && types[i + count].id === startId + count) {
37395                         count++;
37396                     }
37397                     if (result.length) {
37398                         result += ",";
37399                     }
37400                     result += startId;
37401                     if (count > 1) {
37402                         result += ":" + count;
37403                     }
37404                     i += count;
37405                 }
37406             }
37407             return result;
37408         }
37409         function getPropagatingFlagsOfTypes(types, excludeKinds) {
37410             var result = 0;
37411             for (var _i = 0, types_8 = types; _i < types_8.length; _i++) {
37412                 var type = types_8[_i];
37413                 if (!(type.flags & excludeKinds)) {
37414                     result |= ts.getObjectFlags(type);
37415                 }
37416             }
37417             return result & 3670016;
37418         }
37419         function createTypeReference(target, typeArguments) {
37420             var id = getTypeListId(typeArguments);
37421             var type = target.instantiations.get(id);
37422             if (!type) {
37423                 type = createObjectType(4, target.symbol);
37424                 target.instantiations.set(id, type);
37425                 type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, 0) : 0;
37426                 type.target = target;
37427                 type.resolvedTypeArguments = typeArguments;
37428             }
37429             return type;
37430         }
37431         function cloneTypeReference(source) {
37432             var type = createType(source.flags);
37433             type.symbol = source.symbol;
37434             type.objectFlags = source.objectFlags;
37435             type.target = source.target;
37436             type.resolvedTypeArguments = source.resolvedTypeArguments;
37437             return type;
37438         }
37439         function createDeferredTypeReference(target, node, mapper) {
37440             var aliasSymbol = getAliasSymbolForTypeNode(node);
37441             var aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
37442             var type = createObjectType(4, target.symbol);
37443             type.target = target;
37444             type.node = node;
37445             type.mapper = mapper;
37446             type.aliasSymbol = aliasSymbol;
37447             type.aliasTypeArguments = mapper ? instantiateTypes(aliasTypeArguments, mapper) : aliasTypeArguments;
37448             return type;
37449         }
37450         function getTypeArguments(type) {
37451             var _a, _b;
37452             if (!type.resolvedTypeArguments) {
37453                 if (!pushTypeResolution(type, 6)) {
37454                     return ((_a = type.target.localTypeParameters) === null || _a === void 0 ? void 0 : _a.map(function () { return errorType; })) || ts.emptyArray;
37455                 }
37456                 var node = type.node;
37457                 var typeArguments = !node ? ts.emptyArray :
37458                     node.kind === 169 ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) :
37459                         node.kind === 174 ? [getTypeFromTypeNode(node.elementType)] :
37460                             ts.map(node.elementTypes, getTypeFromTypeNode);
37461                 if (popTypeResolution()) {
37462                     type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments;
37463                 }
37464                 else {
37465                     type.resolvedTypeArguments = ((_b = type.target.localTypeParameters) === null || _b === void 0 ? void 0 : _b.map(function () { return errorType; })) || ts.emptyArray;
37466                     error(type.node || currentNode, type.target.symbol
37467                         ? ts.Diagnostics.Type_arguments_for_0_circularly_reference_themselves
37468                         : ts.Diagnostics.Tuple_type_arguments_circularly_reference_themselves, type.target.symbol && symbolToString(type.target.symbol));
37469                 }
37470             }
37471             return type.resolvedTypeArguments;
37472         }
37473         function getTypeReferenceArity(type) {
37474             return ts.length(type.target.typeParameters);
37475         }
37476         function getTypeFromClassOrInterfaceReference(node, symbol) {
37477             var type = getDeclaredTypeOfSymbol(getMergedSymbol(symbol));
37478             var typeParameters = type.localTypeParameters;
37479             if (typeParameters) {
37480                 var numTypeArguments = ts.length(node.typeArguments);
37481                 var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters);
37482                 var isJs = ts.isInJSFile(node);
37483                 var isJsImplicitAny = !noImplicitAny && isJs;
37484                 if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) {
37485                     var missingAugmentsTag = isJs && ts.isExpressionWithTypeArguments(node) && !ts.isJSDocAugmentsTag(node.parent);
37486                     var diag = minTypeArgumentCount === typeParameters.length ?
37487                         missingAugmentsTag ?
37488                             ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag :
37489                             ts.Diagnostics.Generic_type_0_requires_1_type_argument_s :
37490                         missingAugmentsTag ?
37491                             ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag :
37492                             ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments;
37493                     var typeStr = typeToString(type, undefined, 2);
37494                     error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length);
37495                     if (!isJs) {
37496                         return errorType;
37497                     }
37498                 }
37499                 if (node.kind === 169 && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) {
37500                     return createDeferredTypeReference(type, node, undefined);
37501                 }
37502                 var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgumentsFromTypeReferenceNode(node), typeParameters, minTypeArgumentCount, isJs));
37503                 return createTypeReference(type, typeArguments);
37504             }
37505             return checkNoTypeArguments(node, symbol) ? type : errorType;
37506         }
37507         function getTypeAliasInstantiation(symbol, typeArguments) {
37508             var type = getDeclaredTypeOfSymbol(symbol);
37509             var links = getSymbolLinks(symbol);
37510             var typeParameters = links.typeParameters;
37511             var id = getTypeListId(typeArguments);
37512             var instantiation = links.instantiations.get(id);
37513             if (!instantiation) {
37514                 links.instantiations.set(id, instantiation = instantiateType(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(symbol.valueDeclaration)))));
37515             }
37516             return instantiation;
37517         }
37518         function getTypeFromTypeAliasReference(node, symbol) {
37519             var type = getDeclaredTypeOfSymbol(symbol);
37520             var typeParameters = getSymbolLinks(symbol).typeParameters;
37521             if (typeParameters) {
37522                 var numTypeArguments = ts.length(node.typeArguments);
37523                 var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters);
37524                 if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) {
37525                     error(node, minTypeArgumentCount === typeParameters.length ?
37526                         ts.Diagnostics.Generic_type_0_requires_1_type_argument_s :
37527                         ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length);
37528                     return errorType;
37529                 }
37530                 return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node));
37531             }
37532             return checkNoTypeArguments(node, symbol) ? type : errorType;
37533         }
37534         function getTypeReferenceName(node) {
37535             switch (node.kind) {
37536                 case 169:
37537                     return node.typeName;
37538                 case 216:
37539                     var expr = node.expression;
37540                     if (ts.isEntityNameExpression(expr)) {
37541                         return expr;
37542                     }
37543             }
37544             return undefined;
37545         }
37546         function resolveTypeReferenceName(typeReferenceName, meaning, ignoreErrors) {
37547             if (!typeReferenceName) {
37548                 return unknownSymbol;
37549             }
37550             return resolveEntityName(typeReferenceName, meaning, ignoreErrors) || unknownSymbol;
37551         }
37552         function getTypeReferenceType(node, symbol) {
37553             if (symbol === unknownSymbol) {
37554                 return errorType;
37555             }
37556             symbol = getExpandoSymbol(symbol) || symbol;
37557             if (symbol.flags & (32 | 64)) {
37558                 return getTypeFromClassOrInterfaceReference(node, symbol);
37559             }
37560             if (symbol.flags & 524288) {
37561                 return getTypeFromTypeAliasReference(node, symbol);
37562             }
37563             var res = tryGetDeclaredTypeOfSymbol(symbol);
37564             if (res) {
37565                 return checkNoTypeArguments(node, symbol) ? getRegularTypeOfLiteralType(res) : errorType;
37566             }
37567             if (symbol.flags & 111551 && isJSDocTypeReference(node)) {
37568                 var jsdocType = getTypeFromJSDocValueReference(node, symbol);
37569                 if (jsdocType) {
37570                     return jsdocType;
37571                 }
37572                 else {
37573                     resolveTypeReferenceName(getTypeReferenceName(node), 788968);
37574                     return getTypeOfSymbol(symbol);
37575                 }
37576             }
37577             return errorType;
37578         }
37579         function getTypeFromJSDocValueReference(node, symbol) {
37580             var links = getNodeLinks(node);
37581             if (!links.resolvedJSDocType) {
37582                 var valueType = getTypeOfSymbol(symbol);
37583                 var typeType = valueType;
37584                 if (symbol.valueDeclaration) {
37585                     var decl = ts.getRootDeclaration(symbol.valueDeclaration);
37586                     var isRequireAlias = false;
37587                     if (ts.isVariableDeclaration(decl) && decl.initializer) {
37588                         var expr = decl.initializer;
37589                         while (ts.isPropertyAccessExpression(expr)) {
37590                             expr = expr.expression;
37591                         }
37592                         isRequireAlias = ts.isCallExpression(expr) && ts.isRequireCall(expr, true) && !!valueType.symbol;
37593                     }
37594                     var isImportTypeWithQualifier = node.kind === 188 && node.qualifier;
37595                     if (valueType.symbol && (isRequireAlias || isImportTypeWithQualifier)) {
37596                         typeType = getTypeReferenceType(node, valueType.symbol);
37597                     }
37598                 }
37599                 links.resolvedJSDocType = typeType;
37600             }
37601             return links.resolvedJSDocType;
37602         }
37603         function getSubstitutionType(baseType, substitute) {
37604             if (substitute.flags & 3 || substitute === baseType) {
37605                 return baseType;
37606             }
37607             var id = getTypeId(baseType) + ">" + getTypeId(substitute);
37608             var cached = substitutionTypes.get(id);
37609             if (cached) {
37610                 return cached;
37611             }
37612             var result = createType(33554432);
37613             result.baseType = baseType;
37614             result.substitute = substitute;
37615             substitutionTypes.set(id, result);
37616             return result;
37617         }
37618         function isUnaryTupleTypeNode(node) {
37619             return node.kind === 175 && node.elementTypes.length === 1;
37620         }
37621         function getImpliedConstraint(type, checkNode, extendsNode) {
37622             return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elementTypes[0], extendsNode.elementTypes[0]) :
37623                 getActualTypeVariable(getTypeFromTypeNode(checkNode)) === type ? getTypeFromTypeNode(extendsNode) :
37624                     undefined;
37625         }
37626         function getConditionalFlowTypeOfType(type, node) {
37627             var constraints;
37628             while (node && !ts.isStatement(node) && node.kind !== 303) {
37629                 var parent = node.parent;
37630                 if (parent.kind === 180 && node === parent.trueType) {
37631                     var constraint = getImpliedConstraint(type, parent.checkType, parent.extendsType);
37632                     if (constraint) {
37633                         constraints = ts.append(constraints, constraint);
37634                     }
37635                 }
37636                 node = parent;
37637             }
37638             return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type;
37639         }
37640         function isJSDocTypeReference(node) {
37641             return !!(node.flags & 4194304) && (node.kind === 169 || node.kind === 188);
37642         }
37643         function checkNoTypeArguments(node, symbol) {
37644             if (node.typeArguments) {
37645                 error(node, ts.Diagnostics.Type_0_is_not_generic, symbol ? symbolToString(symbol) : node.typeName ? ts.declarationNameToString(node.typeName) : anon);
37646                 return false;
37647             }
37648             return true;
37649         }
37650         function getIntendedTypeFromJSDocTypeReference(node) {
37651             if (ts.isIdentifier(node.typeName)) {
37652                 var typeArgs = node.typeArguments;
37653                 switch (node.typeName.escapedText) {
37654                     case "String":
37655                         checkNoTypeArguments(node);
37656                         return stringType;
37657                     case "Number":
37658                         checkNoTypeArguments(node);
37659                         return numberType;
37660                     case "Boolean":
37661                         checkNoTypeArguments(node);
37662                         return booleanType;
37663                     case "Void":
37664                         checkNoTypeArguments(node);
37665                         return voidType;
37666                     case "Undefined":
37667                         checkNoTypeArguments(node);
37668                         return undefinedType;
37669                     case "Null":
37670                         checkNoTypeArguments(node);
37671                         return nullType;
37672                     case "Function":
37673                     case "function":
37674                         checkNoTypeArguments(node);
37675                         return globalFunctionType;
37676                     case "array":
37677                         return (!typeArgs || !typeArgs.length) && !noImplicitAny ? anyArrayType : undefined;
37678                     case "promise":
37679                         return (!typeArgs || !typeArgs.length) && !noImplicitAny ? createPromiseType(anyType) : undefined;
37680                     case "Object":
37681                         if (typeArgs && typeArgs.length === 2) {
37682                             if (ts.isJSDocIndexSignature(node)) {
37683                                 var indexed = getTypeFromTypeNode(typeArgs[0]);
37684                                 var target = getTypeFromTypeNode(typeArgs[1]);
37685                                 var index = createIndexInfo(target, false);
37686                                 return createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, indexed === stringType ? index : undefined, indexed === numberType ? index : undefined);
37687                             }
37688                             return anyType;
37689                         }
37690                         checkNoTypeArguments(node);
37691                         return !noImplicitAny ? anyType : undefined;
37692                 }
37693             }
37694         }
37695         function getTypeFromJSDocNullableTypeNode(node) {
37696             var type = getTypeFromTypeNode(node.type);
37697             return strictNullChecks ? getNullableType(type, 65536) : type;
37698         }
37699         function getTypeFromTypeReference(node) {
37700             var links = getNodeLinks(node);
37701             if (!links.resolvedType) {
37702                 if (ts.isConstTypeReference(node) && ts.isAssertionExpression(node.parent)) {
37703                     links.resolvedSymbol = unknownSymbol;
37704                     return links.resolvedType = checkExpressionCached(node.parent.expression);
37705                 }
37706                 var symbol = void 0;
37707                 var type = void 0;
37708                 var meaning = 788968;
37709                 if (isJSDocTypeReference(node)) {
37710                     type = getIntendedTypeFromJSDocTypeReference(node);
37711                     if (!type) {
37712                         symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning, true);
37713                         if (symbol === unknownSymbol) {
37714                             symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning | 111551);
37715                         }
37716                         else {
37717                             resolveTypeReferenceName(getTypeReferenceName(node), meaning);
37718                         }
37719                         type = getTypeReferenceType(node, symbol);
37720                     }
37721                 }
37722                 if (!type) {
37723                     symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning);
37724                     type = getTypeReferenceType(node, symbol);
37725                 }
37726                 links.resolvedSymbol = symbol;
37727                 links.resolvedType = type;
37728             }
37729             return links.resolvedType;
37730         }
37731         function typeArgumentsFromTypeReferenceNode(node) {
37732             return ts.map(node.typeArguments, getTypeFromTypeNode);
37733         }
37734         function getTypeFromTypeQueryNode(node) {
37735             var links = getNodeLinks(node);
37736             if (!links.resolvedType) {
37737                 links.resolvedType = getRegularTypeOfLiteralType(getWidenedType(checkExpression(node.exprName)));
37738             }
37739             return links.resolvedType;
37740         }
37741         function getTypeOfGlobalSymbol(symbol, arity) {
37742             function getTypeDeclaration(symbol) {
37743                 var declarations = symbol.declarations;
37744                 for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) {
37745                     var declaration = declarations_3[_i];
37746                     switch (declaration.kind) {
37747                         case 245:
37748                         case 246:
37749                         case 248:
37750                             return declaration;
37751                     }
37752                 }
37753             }
37754             if (!symbol) {
37755                 return arity ? emptyGenericType : emptyObjectType;
37756             }
37757             var type = getDeclaredTypeOfSymbol(symbol);
37758             if (!(type.flags & 524288)) {
37759                 error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, ts.symbolName(symbol));
37760                 return arity ? emptyGenericType : emptyObjectType;
37761             }
37762             if (ts.length(type.typeParameters) !== arity) {
37763                 error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_have_1_type_parameter_s, ts.symbolName(symbol), arity);
37764                 return arity ? emptyGenericType : emptyObjectType;
37765             }
37766             return type;
37767         }
37768         function getGlobalValueSymbol(name, reportErrors) {
37769             return getGlobalSymbol(name, 111551, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined);
37770         }
37771         function getGlobalTypeSymbol(name, reportErrors) {
37772             return getGlobalSymbol(name, 788968, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined);
37773         }
37774         function getGlobalSymbol(name, meaning, diagnostic) {
37775             return resolveName(undefined, name, meaning, diagnostic, name, false);
37776         }
37777         function getGlobalType(name, arity, reportErrors) {
37778             var symbol = getGlobalTypeSymbol(name, reportErrors);
37779             return symbol || reportErrors ? getTypeOfGlobalSymbol(symbol, arity) : undefined;
37780         }
37781         function getGlobalTypedPropertyDescriptorType() {
37782             return deferredGlobalTypedPropertyDescriptorType || (deferredGlobalTypedPropertyDescriptorType = getGlobalType("TypedPropertyDescriptor", 1, true)) || emptyGenericType;
37783         }
37784         function getGlobalTemplateStringsArrayType() {
37785             return deferredGlobalTemplateStringsArrayType || (deferredGlobalTemplateStringsArrayType = getGlobalType("TemplateStringsArray", 0, true)) || emptyObjectType;
37786         }
37787         function getGlobalImportMetaType() {
37788             return deferredGlobalImportMetaType || (deferredGlobalImportMetaType = getGlobalType("ImportMeta", 0, true)) || emptyObjectType;
37789         }
37790         function getGlobalESSymbolConstructorSymbol(reportErrors) {
37791             return deferredGlobalESSymbolConstructorSymbol || (deferredGlobalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol", reportErrors));
37792         }
37793         function getGlobalESSymbolType(reportErrors) {
37794             return deferredGlobalESSymbolType || (deferredGlobalESSymbolType = getGlobalType("Symbol", 0, reportErrors)) || emptyObjectType;
37795         }
37796         function getGlobalPromiseType(reportErrors) {
37797             return deferredGlobalPromiseType || (deferredGlobalPromiseType = getGlobalType("Promise", 1, reportErrors)) || emptyGenericType;
37798         }
37799         function getGlobalPromiseLikeType(reportErrors) {
37800             return deferredGlobalPromiseLikeType || (deferredGlobalPromiseLikeType = getGlobalType("PromiseLike", 1, reportErrors)) || emptyGenericType;
37801         }
37802         function getGlobalPromiseConstructorSymbol(reportErrors) {
37803             return deferredGlobalPromiseConstructorSymbol || (deferredGlobalPromiseConstructorSymbol = getGlobalValueSymbol("Promise", reportErrors));
37804         }
37805         function getGlobalPromiseConstructorLikeType(reportErrors) {
37806             return deferredGlobalPromiseConstructorLikeType || (deferredGlobalPromiseConstructorLikeType = getGlobalType("PromiseConstructorLike", 0, reportErrors)) || emptyObjectType;
37807         }
37808         function getGlobalAsyncIterableType(reportErrors) {
37809             return deferredGlobalAsyncIterableType || (deferredGlobalAsyncIterableType = getGlobalType("AsyncIterable", 1, reportErrors)) || emptyGenericType;
37810         }
37811         function getGlobalAsyncIteratorType(reportErrors) {
37812             return deferredGlobalAsyncIteratorType || (deferredGlobalAsyncIteratorType = getGlobalType("AsyncIterator", 3, reportErrors)) || emptyGenericType;
37813         }
37814         function getGlobalAsyncIterableIteratorType(reportErrors) {
37815             return deferredGlobalAsyncIterableIteratorType || (deferredGlobalAsyncIterableIteratorType = getGlobalType("AsyncIterableIterator", 1, reportErrors)) || emptyGenericType;
37816         }
37817         function getGlobalAsyncGeneratorType(reportErrors) {
37818             return deferredGlobalAsyncGeneratorType || (deferredGlobalAsyncGeneratorType = getGlobalType("AsyncGenerator", 3, reportErrors)) || emptyGenericType;
37819         }
37820         function getGlobalIterableType(reportErrors) {
37821             return deferredGlobalIterableType || (deferredGlobalIterableType = getGlobalType("Iterable", 1, reportErrors)) || emptyGenericType;
37822         }
37823         function getGlobalIteratorType(reportErrors) {
37824             return deferredGlobalIteratorType || (deferredGlobalIteratorType = getGlobalType("Iterator", 3, reportErrors)) || emptyGenericType;
37825         }
37826         function getGlobalIterableIteratorType(reportErrors) {
37827             return deferredGlobalIterableIteratorType || (deferredGlobalIterableIteratorType = getGlobalType("IterableIterator", 1, reportErrors)) || emptyGenericType;
37828         }
37829         function getGlobalGeneratorType(reportErrors) {
37830             return deferredGlobalGeneratorType || (deferredGlobalGeneratorType = getGlobalType("Generator", 3, reportErrors)) || emptyGenericType;
37831         }
37832         function getGlobalIteratorYieldResultType(reportErrors) {
37833             return deferredGlobalIteratorYieldResultType || (deferredGlobalIteratorYieldResultType = getGlobalType("IteratorYieldResult", 1, reportErrors)) || emptyGenericType;
37834         }
37835         function getGlobalIteratorReturnResultType(reportErrors) {
37836             return deferredGlobalIteratorReturnResultType || (deferredGlobalIteratorReturnResultType = getGlobalType("IteratorReturnResult", 1, reportErrors)) || emptyGenericType;
37837         }
37838         function getGlobalTypeOrUndefined(name, arity) {
37839             if (arity === void 0) { arity = 0; }
37840             var symbol = getGlobalSymbol(name, 788968, undefined);
37841             return symbol && getTypeOfGlobalSymbol(symbol, arity);
37842         }
37843         function getGlobalExtractSymbol() {
37844             return deferredGlobalExtractSymbol || (deferredGlobalExtractSymbol = getGlobalSymbol("Extract", 524288, ts.Diagnostics.Cannot_find_global_type_0));
37845         }
37846         function getGlobalOmitSymbol() {
37847             return deferredGlobalOmitSymbol || (deferredGlobalOmitSymbol = getGlobalSymbol("Omit", 524288, ts.Diagnostics.Cannot_find_global_type_0));
37848         }
37849         function getGlobalBigIntType(reportErrors) {
37850             return deferredGlobalBigIntType || (deferredGlobalBigIntType = getGlobalType("BigInt", 0, reportErrors)) || emptyObjectType;
37851         }
37852         function createTypeFromGenericGlobalType(genericGlobalType, typeArguments) {
37853             return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType;
37854         }
37855         function createTypedPropertyDescriptorType(propertyType) {
37856             return createTypeFromGenericGlobalType(getGlobalTypedPropertyDescriptorType(), [propertyType]);
37857         }
37858         function createIterableType(iteratedType) {
37859             return createTypeFromGenericGlobalType(getGlobalIterableType(true), [iteratedType]);
37860         }
37861         function createArrayType(elementType, readonly) {
37862             return createTypeFromGenericGlobalType(readonly ? globalReadonlyArrayType : globalArrayType, [elementType]);
37863         }
37864         function getArrayOrTupleTargetType(node) {
37865             var readonly = isReadonlyTypeOperator(node.parent);
37866             if (node.kind === 174 || node.elementTypes.length === 1 && node.elementTypes[0].kind === 177) {
37867                 return readonly ? globalReadonlyArrayType : globalArrayType;
37868             }
37869             var lastElement = ts.lastOrUndefined(node.elementTypes);
37870             var restElement = lastElement && lastElement.kind === 177 ? lastElement : undefined;
37871             var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 176 && n !== restElement; }) + 1;
37872             return getTupleTypeOfArity(node.elementTypes.length, minLength, !!restElement, readonly, undefined);
37873         }
37874         function isDeferredTypeReferenceNode(node, hasDefaultTypeArguments) {
37875             return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 174 ? mayResolveTypeAlias(node.elementType) :
37876                 node.kind === 175 ? ts.some(node.elementTypes, mayResolveTypeAlias) :
37877                     hasDefaultTypeArguments || ts.some(node.typeArguments, mayResolveTypeAlias));
37878         }
37879         function isResolvedByTypeAlias(node) {
37880             var parent = node.parent;
37881             switch (parent.kind) {
37882                 case 182:
37883                 case 169:
37884                 case 178:
37885                 case 179:
37886                 case 185:
37887                 case 180:
37888                 case 184:
37889                 case 174:
37890                 case 175:
37891                     return isResolvedByTypeAlias(parent);
37892                 case 247:
37893                     return true;
37894             }
37895             return false;
37896         }
37897         function mayResolveTypeAlias(node) {
37898             switch (node.kind) {
37899                 case 169:
37900                     return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node.typeName, 788968).flags & 524288);
37901                 case 172:
37902                     return true;
37903                 case 184:
37904                     return node.operator !== 147 && mayResolveTypeAlias(node.type);
37905                 case 182:
37906                 case 176:
37907                 case 299:
37908                 case 297:
37909                 case 298:
37910                 case 294:
37911                     return mayResolveTypeAlias(node.type);
37912                 case 177:
37913                     return node.type.kind !== 174 || mayResolveTypeAlias(node.type.elementType);
37914                 case 178:
37915                 case 179:
37916                     return ts.some(node.types, mayResolveTypeAlias);
37917                 case 185:
37918                     return mayResolveTypeAlias(node.objectType) || mayResolveTypeAlias(node.indexType);
37919                 case 180:
37920                     return mayResolveTypeAlias(node.checkType) || mayResolveTypeAlias(node.extendsType) ||
37921                         mayResolveTypeAlias(node.trueType) || mayResolveTypeAlias(node.falseType);
37922             }
37923             return false;
37924         }
37925         function getTypeFromArrayOrTupleTypeNode(node) {
37926             var links = getNodeLinks(node);
37927             if (!links.resolvedType) {
37928                 var target = getArrayOrTupleTargetType(node);
37929                 if (target === emptyGenericType) {
37930                     links.resolvedType = emptyObjectType;
37931                 }
37932                 else if (isDeferredTypeReferenceNode(node)) {
37933                     links.resolvedType = node.kind === 175 && node.elementTypes.length === 0 ? target :
37934                         createDeferredTypeReference(target, node, undefined);
37935                 }
37936                 else {
37937                     var elementTypes = node.kind === 174 ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elementTypes, getTypeFromTypeNode);
37938                     links.resolvedType = createTypeReference(target, elementTypes);
37939                 }
37940             }
37941             return links.resolvedType;
37942         }
37943         function isReadonlyTypeOperator(node) {
37944             return ts.isTypeOperatorNode(node) && node.operator === 138;
37945         }
37946         function createTupleTypeOfArity(arity, minLength, hasRestElement, readonly, associatedNames) {
37947             var typeParameters;
37948             var properties = [];
37949             var maxLength = hasRestElement ? arity - 1 : arity;
37950             if (arity) {
37951                 typeParameters = new Array(arity);
37952                 for (var i = 0; i < arity; i++) {
37953                     var typeParameter = typeParameters[i] = createTypeParameter();
37954                     if (i < maxLength) {
37955                         var property = createSymbol(4 | (i >= minLength ? 16777216 : 0), "" + i, readonly ? 8 : 0);
37956                         property.type = typeParameter;
37957                         properties.push(property);
37958                     }
37959                 }
37960             }
37961             var literalTypes = [];
37962             for (var i = minLength; i <= maxLength; i++)
37963                 literalTypes.push(getLiteralType(i));
37964             var lengthSymbol = createSymbol(4, "length");
37965             lengthSymbol.type = hasRestElement ? numberType : getUnionType(literalTypes);
37966             properties.push(lengthSymbol);
37967             var type = createObjectType(8 | 4);
37968             type.typeParameters = typeParameters;
37969             type.outerTypeParameters = undefined;
37970             type.localTypeParameters = typeParameters;
37971             type.instantiations = ts.createMap();
37972             type.instantiations.set(getTypeListId(type.typeParameters), type);
37973             type.target = type;
37974             type.resolvedTypeArguments = type.typeParameters;
37975             type.thisType = createTypeParameter();
37976             type.thisType.isThisType = true;
37977             type.thisType.constraint = type;
37978             type.declaredProperties = properties;
37979             type.declaredCallSignatures = ts.emptyArray;
37980             type.declaredConstructSignatures = ts.emptyArray;
37981             type.declaredStringIndexInfo = undefined;
37982             type.declaredNumberIndexInfo = undefined;
37983             type.minLength = minLength;
37984             type.hasRestElement = hasRestElement;
37985             type.readonly = readonly;
37986             type.associatedNames = associatedNames;
37987             return type;
37988         }
37989         function getTupleTypeOfArity(arity, minLength, hasRestElement, readonly, associatedNames) {
37990             var key = arity + (hasRestElement ? "+" : ",") + minLength + (readonly ? "R" : "") + (associatedNames && associatedNames.length ? "," + associatedNames.join(",") : "");
37991             var type = tupleTypes.get(key);
37992             if (!type) {
37993                 tupleTypes.set(key, type = createTupleTypeOfArity(arity, minLength, hasRestElement, readonly, associatedNames));
37994             }
37995             return type;
37996         }
37997         function createTupleType(elementTypes, minLength, hasRestElement, readonly, associatedNames) {
37998             if (minLength === void 0) { minLength = elementTypes.length; }
37999             if (hasRestElement === void 0) { hasRestElement = false; }
38000             if (readonly === void 0) { readonly = false; }
38001             var arity = elementTypes.length;
38002             if (arity === 1 && hasRestElement) {
38003                 return createArrayType(elementTypes[0], readonly);
38004             }
38005             var tupleType = getTupleTypeOfArity(arity, minLength, arity > 0 && hasRestElement, readonly, associatedNames);
38006             return elementTypes.length ? createTypeReference(tupleType, elementTypes) : tupleType;
38007         }
38008         function sliceTupleType(type, index) {
38009             var tuple = type.target;
38010             if (tuple.hasRestElement) {
38011                 index = Math.min(index, getTypeReferenceArity(type) - 1);
38012             }
38013             return createTupleType(getTypeArguments(type).slice(index), Math.max(0, tuple.minLength - index), tuple.hasRestElement, tuple.readonly, tuple.associatedNames && tuple.associatedNames.slice(index));
38014         }
38015         function getTypeFromOptionalTypeNode(node) {
38016             var type = getTypeFromTypeNode(node.type);
38017             return strictNullChecks ? getOptionalType(type) : type;
38018         }
38019         function getTypeId(type) {
38020             return type.id;
38021         }
38022         function containsType(types, type) {
38023             return ts.binarySearch(types, type, getTypeId, ts.compareValues) >= 0;
38024         }
38025         function insertType(types, type) {
38026             var index = ts.binarySearch(types, type, getTypeId, ts.compareValues);
38027             if (index < 0) {
38028                 types.splice(~index, 0, type);
38029                 return true;
38030             }
38031             return false;
38032         }
38033         function addTypeToUnion(typeSet, includes, type) {
38034             var flags = type.flags;
38035             if (flags & 1048576) {
38036                 return addTypesToUnion(typeSet, includes, type.types);
38037             }
38038             if (!(flags & 131072)) {
38039                 includes |= flags & 71041023;
38040                 if (flags & 66846720)
38041                     includes |= 262144;
38042                 if (type === wildcardType)
38043                     includes |= 8388608;
38044                 if (!strictNullChecks && flags & 98304) {
38045                     if (!(ts.getObjectFlags(type) & 524288))
38046                         includes |= 4194304;
38047                 }
38048                 else {
38049                     var len = typeSet.length;
38050                     var index = len && type.id > typeSet[len - 1].id ? ~len : ts.binarySearch(typeSet, type, getTypeId, ts.compareValues);
38051                     if (index < 0) {
38052                         typeSet.splice(~index, 0, type);
38053                     }
38054                 }
38055             }
38056             return includes;
38057         }
38058         function addTypesToUnion(typeSet, includes, types) {
38059             for (var _i = 0, types_9 = types; _i < types_9.length; _i++) {
38060                 var type = types_9[_i];
38061                 includes = addTypeToUnion(typeSet, includes, type);
38062             }
38063             return includes;
38064         }
38065         function isSetOfLiteralsFromSameEnum(types) {
38066             var first = types[0];
38067             if (first.flags & 1024) {
38068                 var firstEnum = getParentOfSymbol(first.symbol);
38069                 for (var i = 1; i < types.length; i++) {
38070                     var other = types[i];
38071                     if (!(other.flags & 1024) || (firstEnum !== getParentOfSymbol(other.symbol))) {
38072                         return false;
38073                     }
38074                 }
38075                 return true;
38076             }
38077             return false;
38078         }
38079         function removeSubtypes(types, primitivesOnly) {
38080             var len = types.length;
38081             if (len === 0 || isSetOfLiteralsFromSameEnum(types)) {
38082                 return true;
38083             }
38084             var i = len;
38085             var count = 0;
38086             while (i > 0) {
38087                 i--;
38088                 var source = types[i];
38089                 for (var _i = 0, types_10 = types; _i < types_10.length; _i++) {
38090                     var target = types_10[_i];
38091                     if (source !== target) {
38092                         if (count === 100000) {
38093                             var estimatedCount = (count / (len - i)) * len;
38094                             if (estimatedCount > (primitivesOnly ? 25000000 : 1000000)) {
38095                                 error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
38096                                 return false;
38097                             }
38098                         }
38099                         count++;
38100                         if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (!(ts.getObjectFlags(getTargetType(source)) & 1) ||
38101                             !(ts.getObjectFlags(getTargetType(target)) & 1) ||
38102                             isTypeDerivedFrom(source, target))) {
38103                             ts.orderedRemoveItemAt(types, i);
38104                             break;
38105                         }
38106                     }
38107                 }
38108             }
38109             return true;
38110         }
38111         function removeRedundantLiteralTypes(types, includes) {
38112             var i = types.length;
38113             while (i > 0) {
38114                 i--;
38115                 var t = types[i];
38116                 var remove = t.flags & 128 && includes & 4 ||
38117                     t.flags & 256 && includes & 8 ||
38118                     t.flags & 2048 && includes & 64 ||
38119                     t.flags & 8192 && includes & 4096 ||
38120                     isFreshLiteralType(t) && containsType(types, t.regularType);
38121                 if (remove) {
38122                     ts.orderedRemoveItemAt(types, i);
38123                 }
38124             }
38125         }
38126         function getUnionType(types, unionReduction, aliasSymbol, aliasTypeArguments) {
38127             if (unionReduction === void 0) { unionReduction = 1; }
38128             if (types.length === 0) {
38129                 return neverType;
38130             }
38131             if (types.length === 1) {
38132                 return types[0];
38133             }
38134             var typeSet = [];
38135             var includes = addTypesToUnion(typeSet, 0, types);
38136             if (unionReduction !== 0) {
38137                 if (includes & 3) {
38138                     return includes & 1 ? includes & 8388608 ? wildcardType : anyType : unknownType;
38139                 }
38140                 switch (unionReduction) {
38141                     case 1:
38142                         if (includes & (2944 | 8192)) {
38143                             removeRedundantLiteralTypes(typeSet, includes);
38144                         }
38145                         break;
38146                     case 2:
38147                         if (!removeSubtypes(typeSet, !(includes & 262144))) {
38148                             return errorType;
38149                         }
38150                         break;
38151                 }
38152                 if (typeSet.length === 0) {
38153                     return includes & 65536 ? includes & 4194304 ? nullType : nullWideningType :
38154                         includes & 32768 ? includes & 4194304 ? undefinedType : undefinedWideningType :
38155                             neverType;
38156                 }
38157             }
38158             var objectFlags = (includes & 66994211 ? 0 : 262144) |
38159                 (includes & 2097152 ? 268435456 : 0);
38160             return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments);
38161         }
38162         function getUnionTypePredicate(signatures) {
38163             var first;
38164             var types = [];
38165             for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) {
38166                 var sig = signatures_6[_i];
38167                 var pred = getTypePredicateOfSignature(sig);
38168                 if (!pred || pred.kind === 2 || pred.kind === 3) {
38169                     continue;
38170                 }
38171                 if (first) {
38172                     if (!typePredicateKindsMatch(first, pred)) {
38173                         return undefined;
38174                     }
38175                 }
38176                 else {
38177                     first = pred;
38178                 }
38179                 types.push(pred.type);
38180             }
38181             if (!first) {
38182                 return undefined;
38183             }
38184             var unionType = getUnionType(types);
38185             return createTypePredicate(first.kind, first.parameterName, first.parameterIndex, unionType);
38186         }
38187         function typePredicateKindsMatch(a, b) {
38188             return a.kind === b.kind && a.parameterIndex === b.parameterIndex;
38189         }
38190         function getUnionTypeFromSortedList(types, objectFlags, aliasSymbol, aliasTypeArguments) {
38191             if (types.length === 0) {
38192                 return neverType;
38193             }
38194             if (types.length === 1) {
38195                 return types[0];
38196             }
38197             var id = getTypeListId(types);
38198             var type = unionTypes.get(id);
38199             if (!type) {
38200                 type = createType(1048576);
38201                 unionTypes.set(id, type);
38202                 type.objectFlags = objectFlags | getPropagatingFlagsOfTypes(types, 98304);
38203                 type.types = types;
38204                 type.aliasSymbol = aliasSymbol;
38205                 type.aliasTypeArguments = aliasTypeArguments;
38206             }
38207             return type;
38208         }
38209         function getTypeFromUnionTypeNode(node) {
38210             var links = getNodeLinks(node);
38211             if (!links.resolvedType) {
38212                 var aliasSymbol = getAliasSymbolForTypeNode(node);
38213                 links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
38214             }
38215             return links.resolvedType;
38216         }
38217         function addTypeToIntersection(typeSet, includes, type) {
38218             var flags = type.flags;
38219             if (flags & 2097152) {
38220                 return addTypesToIntersection(typeSet, includes, type.types);
38221             }
38222             if (isEmptyAnonymousObjectType(type)) {
38223                 if (!(includes & 16777216)) {
38224                     includes |= 16777216;
38225                     typeSet.set(type.id.toString(), type);
38226                 }
38227             }
38228             else {
38229                 if (flags & 3) {
38230                     if (type === wildcardType)
38231                         includes |= 8388608;
38232                 }
38233                 else if ((strictNullChecks || !(flags & 98304)) && !typeSet.has(type.id.toString())) {
38234                     if (type.flags & 109440 && includes & 109440) {
38235                         includes |= 67108864;
38236                     }
38237                     typeSet.set(type.id.toString(), type);
38238                 }
38239                 includes |= flags & 71041023;
38240             }
38241             return includes;
38242         }
38243         function addTypesToIntersection(typeSet, includes, types) {
38244             for (var _i = 0, types_11 = types; _i < types_11.length; _i++) {
38245                 var type = types_11[_i];
38246                 includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type));
38247             }
38248             return includes;
38249         }
38250         function removeRedundantPrimitiveTypes(types, includes) {
38251             var i = types.length;
38252             while (i > 0) {
38253                 i--;
38254                 var t = types[i];
38255                 var remove = t.flags & 4 && includes & 128 ||
38256                     t.flags & 8 && includes & 256 ||
38257                     t.flags & 64 && includes & 2048 ||
38258                     t.flags & 4096 && includes & 8192;
38259                 if (remove) {
38260                     ts.orderedRemoveItemAt(types, i);
38261                 }
38262             }
38263         }
38264         function eachUnionContains(unionTypes, type) {
38265             for (var _i = 0, unionTypes_1 = unionTypes; _i < unionTypes_1.length; _i++) {
38266                 var u = unionTypes_1[_i];
38267                 if (!containsType(u.types, type)) {
38268                     var primitive = type.flags & 128 ? stringType :
38269                         type.flags & 256 ? numberType :
38270                             type.flags & 2048 ? bigintType :
38271                                 type.flags & 8192 ? esSymbolType :
38272                                     undefined;
38273                     if (!primitive || !containsType(u.types, primitive)) {
38274                         return false;
38275                     }
38276                 }
38277             }
38278             return true;
38279         }
38280         function extractIrreducible(types, flag) {
38281             if (ts.every(types, function (t) { return !!(t.flags & 1048576) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); })) {
38282                 for (var i = 0; i < types.length; i++) {
38283                     types[i] = filterType(types[i], function (t) { return !(t.flags & flag); });
38284                 }
38285                 return true;
38286             }
38287             return false;
38288         }
38289         function intersectUnionsOfPrimitiveTypes(types) {
38290             var unionTypes;
38291             var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 262144); });
38292             if (index < 0) {
38293                 return false;
38294             }
38295             var i = index + 1;
38296             while (i < types.length) {
38297                 var t = types[i];
38298                 if (ts.getObjectFlags(t) & 262144) {
38299                     (unionTypes || (unionTypes = [types[index]])).push(t);
38300                     ts.orderedRemoveItemAt(types, i);
38301                 }
38302                 else {
38303                     i++;
38304                 }
38305             }
38306             if (!unionTypes) {
38307                 return false;
38308             }
38309             var checked = [];
38310             var result = [];
38311             for (var _i = 0, unionTypes_2 = unionTypes; _i < unionTypes_2.length; _i++) {
38312                 var u = unionTypes_2[_i];
38313                 for (var _a = 0, _b = u.types; _a < _b.length; _a++) {
38314                     var t = _b[_a];
38315                     if (insertType(checked, t)) {
38316                         if (eachUnionContains(unionTypes, t)) {
38317                             insertType(result, t);
38318                         }
38319                     }
38320                 }
38321             }
38322             types[index] = getUnionTypeFromSortedList(result, 262144);
38323             return true;
38324         }
38325         function createIntersectionType(types, aliasSymbol, aliasTypeArguments) {
38326             var result = createType(2097152);
38327             result.objectFlags = getPropagatingFlagsOfTypes(types, 98304);
38328             result.types = types;
38329             result.aliasSymbol = aliasSymbol;
38330             result.aliasTypeArguments = aliasTypeArguments;
38331             return result;
38332         }
38333         function getIntersectionType(types, aliasSymbol, aliasTypeArguments) {
38334             var typeMembershipMap = ts.createMap();
38335             var includes = addTypesToIntersection(typeMembershipMap, 0, types);
38336             var typeSet = ts.arrayFrom(typeMembershipMap.values());
38337             if (includes & 131072 ||
38338                 strictNullChecks && includes & 98304 && includes & (524288 | 67108864 | 16777216) ||
38339                 includes & 67108864 && includes & (67238908 & ~67108864) ||
38340                 includes & 132 && includes & (67238908 & ~132) ||
38341                 includes & 296 && includes & (67238908 & ~296) ||
38342                 includes & 2112 && includes & (67238908 & ~2112) ||
38343                 includes & 12288 && includes & (67238908 & ~12288) ||
38344                 includes & 49152 && includes & (67238908 & ~49152)) {
38345                 return neverType;
38346             }
38347             if (includes & 1) {
38348                 return includes & 8388608 ? wildcardType : anyType;
38349             }
38350             if (!strictNullChecks && includes & 98304) {
38351                 return includes & 32768 ? undefinedType : nullType;
38352             }
38353             if (includes & 4 && includes & 128 ||
38354                 includes & 8 && includes & 256 ||
38355                 includes & 64 && includes & 2048 ||
38356                 includes & 4096 && includes & 8192) {
38357                 removeRedundantPrimitiveTypes(typeSet, includes);
38358             }
38359             if (includes & 16777216 && includes & 524288) {
38360                 ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType));
38361             }
38362             if (typeSet.length === 0) {
38363                 return unknownType;
38364             }
38365             if (typeSet.length === 1) {
38366                 return typeSet[0];
38367             }
38368             var id = getTypeListId(typeSet);
38369             var result = intersectionTypes.get(id);
38370             if (!result) {
38371                 if (includes & 1048576) {
38372                     if (intersectUnionsOfPrimitiveTypes(typeSet)) {
38373                         result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
38374                     }
38375                     else if (extractIrreducible(typeSet, 32768)) {
38376                         result = getUnionType([getIntersectionType(typeSet), undefinedType], 1, aliasSymbol, aliasTypeArguments);
38377                     }
38378                     else if (extractIrreducible(typeSet, 65536)) {
38379                         result = getUnionType([getIntersectionType(typeSet), nullType], 1, aliasSymbol, aliasTypeArguments);
38380                     }
38381                     else {
38382                         var size = ts.reduceLeft(typeSet, function (n, t) { return n * (t.flags & 1048576 ? t.types.length : 1); }, 1);
38383                         if (size >= 100000) {
38384                             error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
38385                             return errorType;
38386                         }
38387                         var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 1048576) !== 0; });
38388                         var unionType = typeSet[unionIndex_1];
38389                         result = getUnionType(ts.map(unionType.types, function (t) { return getIntersectionType(ts.replaceElement(typeSet, unionIndex_1, t)); }), 1, aliasSymbol, aliasTypeArguments);
38390                     }
38391                 }
38392                 else {
38393                     result = createIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
38394                 }
38395                 intersectionTypes.set(id, result);
38396             }
38397             return result;
38398         }
38399         function getTypeFromIntersectionTypeNode(node) {
38400             var links = getNodeLinks(node);
38401             if (!links.resolvedType) {
38402                 var aliasSymbol = getAliasSymbolForTypeNode(node);
38403                 links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
38404             }
38405             return links.resolvedType;
38406         }
38407         function createIndexType(type, stringsOnly) {
38408             var result = createType(4194304);
38409             result.type = type;
38410             result.stringsOnly = stringsOnly;
38411             return result;
38412         }
38413         function getIndexTypeForGenericType(type, stringsOnly) {
38414             return stringsOnly ?
38415                 type.resolvedStringIndexType || (type.resolvedStringIndexType = createIndexType(type, true)) :
38416                 type.resolvedIndexType || (type.resolvedIndexType = createIndexType(type, false));
38417         }
38418         function getLiteralTypeFromPropertyName(name) {
38419             if (ts.isPrivateIdentifier(name)) {
38420                 return neverType;
38421             }
38422             return ts.isIdentifier(name) ? getLiteralType(ts.unescapeLeadingUnderscores(name.escapedText)) :
38423                 getRegularTypeOfLiteralType(ts.isComputedPropertyName(name) ? checkComputedPropertyName(name) : checkExpression(name));
38424         }
38425         function getBigIntLiteralType(node) {
38426             return getLiteralType({
38427                 negative: false,
38428                 base10Value: ts.parsePseudoBigInt(node.text)
38429             });
38430         }
38431         function getLiteralTypeFromProperty(prop, include) {
38432             if (!(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24)) {
38433                 var type = getSymbolLinks(getLateBoundSymbol(prop)).nameType;
38434                 if (!type && !ts.isKnownSymbol(prop)) {
38435                     if (prop.escapedName === "default") {
38436                         type = getLiteralType("default");
38437                     }
38438                     else {
38439                         var name = prop.valueDeclaration && ts.getNameOfDeclaration(prop.valueDeclaration);
38440                         type = name && getLiteralTypeFromPropertyName(name) || getLiteralType(ts.symbolName(prop));
38441                     }
38442                 }
38443                 if (type && type.flags & include) {
38444                     return type;
38445                 }
38446             }
38447             return neverType;
38448         }
38449         function getLiteralTypeFromProperties(type, include) {
38450             return getUnionType(ts.map(getPropertiesOfType(type), function (p) { return getLiteralTypeFromProperty(p, include); }));
38451         }
38452         function getNonEnumNumberIndexInfo(type) {
38453             var numberIndexInfo = getIndexInfoOfType(type, 1);
38454             return numberIndexInfo !== enumNumberIndexInfo ? numberIndexInfo : undefined;
38455         }
38456         function getIndexType(type, stringsOnly, noIndexSignatures) {
38457             if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; }
38458             type = getReducedType(type);
38459             return type.flags & 1048576 ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
38460                 type.flags & 2097152 ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
38461                     maybeTypeOfKind(type, 58982400) ? getIndexTypeForGenericType(type, stringsOnly) :
38462                         ts.getObjectFlags(type) & 32 ? filterType(getConstraintTypeFromMappedType(type), function (t) { return !(noIndexSignatures && t.flags & (1 | 4)); }) :
38463                             type === wildcardType ? wildcardType :
38464                                 type.flags & 2 ? neverType :
38465                                     type.flags & (1 | 131072) ? keyofConstraintType :
38466                                         stringsOnly ? !noIndexSignatures && getIndexInfoOfType(type, 0) ? stringType : getLiteralTypeFromProperties(type, 128) :
38467                                             !noIndexSignatures && getIndexInfoOfType(type, 0) ? getUnionType([stringType, numberType, getLiteralTypeFromProperties(type, 8192)]) :
38468                                                 getNonEnumNumberIndexInfo(type) ? getUnionType([numberType, getLiteralTypeFromProperties(type, 128 | 8192)]) :
38469                                                     getLiteralTypeFromProperties(type, 8576);
38470         }
38471         function getExtractStringType(type) {
38472             if (keyofStringsOnly) {
38473                 return type;
38474             }
38475             var extractTypeAlias = getGlobalExtractSymbol();
38476             return extractTypeAlias ? getTypeAliasInstantiation(extractTypeAlias, [type, stringType]) : stringType;
38477         }
38478         function getIndexTypeOrString(type) {
38479             var indexType = getExtractStringType(getIndexType(type));
38480             return indexType.flags & 131072 ? stringType : indexType;
38481         }
38482         function getTypeFromTypeOperatorNode(node) {
38483             var links = getNodeLinks(node);
38484             if (!links.resolvedType) {
38485                 switch (node.operator) {
38486                     case 134:
38487                         links.resolvedType = getIndexType(getTypeFromTypeNode(node.type));
38488                         break;
38489                     case 147:
38490                         links.resolvedType = node.type.kind === 144
38491                             ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent))
38492                             : errorType;
38493                         break;
38494                     case 138:
38495                         links.resolvedType = getTypeFromTypeNode(node.type);
38496                         break;
38497                     default:
38498                         throw ts.Debug.assertNever(node.operator);
38499                 }
38500             }
38501             return links.resolvedType;
38502         }
38503         function createIndexedAccessType(objectType, indexType, aliasSymbol, aliasTypeArguments) {
38504             var type = createType(8388608);
38505             type.objectType = objectType;
38506             type.indexType = indexType;
38507             type.aliasSymbol = aliasSymbol;
38508             type.aliasTypeArguments = aliasTypeArguments;
38509             return type;
38510         }
38511         function isJSLiteralType(type) {
38512             if (noImplicitAny) {
38513                 return false;
38514             }
38515             if (ts.getObjectFlags(type) & 16384) {
38516                 return true;
38517             }
38518             if (type.flags & 1048576) {
38519                 return ts.every(type.types, isJSLiteralType);
38520             }
38521             if (type.flags & 2097152) {
38522                 return ts.some(type.types, isJSLiteralType);
38523             }
38524             if (type.flags & 63176704) {
38525                 return isJSLiteralType(getResolvedBaseConstraint(type));
38526             }
38527             return false;
38528         }
38529         function getPropertyNameFromIndex(indexType, accessNode) {
38530             var accessExpression = accessNode && accessNode.kind === 195 ? accessNode : undefined;
38531             return isTypeUsableAsPropertyName(indexType) ?
38532                 getPropertyNameFromType(indexType) :
38533                 accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, false) ?
38534                     ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) :
38535                     accessNode && ts.isPropertyName(accessNode) ?
38536                         ts.getPropertyNameForPropertyNameNode(accessNode) :
38537                         undefined;
38538         }
38539         function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags) {
38540             var accessExpression = accessNode && accessNode.kind === 195 ? accessNode : undefined;
38541             var propName = accessNode && ts.isPrivateIdentifier(accessNode) ? undefined : getPropertyNameFromIndex(indexType, accessNode);
38542             if (propName !== undefined) {
38543                 var prop = getPropertyOfType(objectType, propName);
38544                 if (prop) {
38545                     if (accessExpression) {
38546                         markPropertyAsReferenced(prop, accessExpression, accessExpression.expression.kind === 104);
38547                         if (isAssignmentToReadonlyEntity(accessExpression, prop, ts.getAssignmentTargetKind(accessExpression))) {
38548                             error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop));
38549                             return undefined;
38550                         }
38551                         if (accessFlags & 4) {
38552                             getNodeLinks(accessNode).resolvedSymbol = prop;
38553                         }
38554                     }
38555                     var propType = getTypeOfSymbol(prop);
38556                     return accessExpression && ts.getAssignmentTargetKind(accessExpression) !== 1 ?
38557                         getFlowTypeOfReference(accessExpression, propType) :
38558                         propType;
38559                 }
38560                 if (everyType(objectType, isTupleType) && isNumericLiteralName(propName) && +propName >= 0) {
38561                     if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 8)) {
38562                         var indexNode = getIndexNodeForAccessExpression(accessNode);
38563                         if (isTupleType(objectType)) {
38564                             error(indexNode, ts.Diagnostics.Tuple_type_0_of_length_1_has_no_element_at_index_2, typeToString(objectType), getTypeReferenceArity(objectType), ts.unescapeLeadingUnderscores(propName));
38565                         }
38566                         else {
38567                             error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType));
38568                         }
38569                     }
38570                     errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, 1));
38571                     return mapType(objectType, function (t) { return getRestTypeOfTupleType(t) || undefinedType; });
38572                 }
38573             }
38574             if (!(indexType.flags & 98304) && isTypeAssignableToKind(indexType, 132 | 296 | 12288)) {
38575                 if (objectType.flags & (1 | 131072)) {
38576                     return objectType;
38577                 }
38578                 var stringIndexInfo = getIndexInfoOfType(objectType, 0);
38579                 var indexInfo = isTypeAssignableToKind(indexType, 296) && getIndexInfoOfType(objectType, 1) || stringIndexInfo;
38580                 if (indexInfo) {
38581                     if (accessFlags & 1 && indexInfo === stringIndexInfo) {
38582                         if (accessExpression) {
38583                             error(accessExpression, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(originalObjectType));
38584                         }
38585                         return undefined;
38586                     }
38587                     if (accessNode && !isTypeAssignableToKind(indexType, 4 | 8)) {
38588                         var indexNode = getIndexNodeForAccessExpression(accessNode);
38589                         error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType));
38590                         return indexInfo.type;
38591                     }
38592                     errorIfWritingToReadonlyIndex(indexInfo);
38593                     return indexInfo.type;
38594                 }
38595                 if (indexType.flags & 131072) {
38596                     return neverType;
38597                 }
38598                 if (isJSLiteralType(objectType)) {
38599                     return anyType;
38600                 }
38601                 if (accessExpression && !isConstEnumObjectType(objectType)) {
38602                     if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418)) {
38603                         error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType));
38604                     }
38605                     else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !suppressNoImplicitAnyError) {
38606                         if (propName !== undefined && typeHasStaticProperty(propName, objectType)) {
38607                             error(accessExpression, ts.Diagnostics.Property_0_is_a_static_member_of_type_1, propName, typeToString(objectType));
38608                         }
38609                         else if (getIndexTypeOfType(objectType, 1)) {
38610                             error(accessExpression.argumentExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number);
38611                         }
38612                         else {
38613                             var suggestion = void 0;
38614                             if (propName !== undefined && (suggestion = getSuggestionForNonexistentProperty(propName, objectType))) {
38615                                 if (suggestion !== undefined) {
38616                                     error(accessExpression.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, propName, typeToString(objectType), suggestion);
38617                                 }
38618                             }
38619                             else {
38620                                 var suggestion_1 = getSuggestionForNonexistentIndexSignature(objectType, accessExpression, indexType);
38621                                 if (suggestion_1 !== undefined) {
38622                                     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);
38623                                 }
38624                                 else {
38625                                     var errorInfo = void 0;
38626                                     if (indexType.flags & 1024) {
38627                                         errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + typeToString(indexType) + "]", typeToString(objectType));
38628                                     }
38629                                     else if (indexType.flags & 8192) {
38630                                         var symbolName_2 = getFullyQualifiedName(indexType.symbol, accessExpression);
38631                                         errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + symbolName_2 + "]", typeToString(objectType));
38632                                     }
38633                                     else if (indexType.flags & 128) {
38634                                         errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType));
38635                                     }
38636                                     else if (indexType.flags & 256) {
38637                                         errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType));
38638                                     }
38639                                     else if (indexType.flags & (8 | 4)) {
38640                                         errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1, typeToString(indexType), typeToString(objectType));
38641                                     }
38642                                     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));
38643                                     diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(accessExpression, errorInfo));
38644                                 }
38645                             }
38646                         }
38647                     }
38648                     return undefined;
38649                 }
38650             }
38651             if (isJSLiteralType(objectType)) {
38652                 return anyType;
38653             }
38654             if (accessNode) {
38655                 var indexNode = getIndexNodeForAccessExpression(accessNode);
38656                 if (indexType.flags & (128 | 256)) {
38657                     error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "" + indexType.value, typeToString(objectType));
38658                 }
38659                 else if (indexType.flags & (4 | 8)) {
38660                     error(indexNode, ts.Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType));
38661                 }
38662                 else {
38663                     error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType));
38664                 }
38665             }
38666             if (isTypeAny(indexType)) {
38667                 return indexType;
38668             }
38669             return undefined;
38670             function errorIfWritingToReadonlyIndex(indexInfo) {
38671                 if (indexInfo && indexInfo.isReadonly && accessExpression && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) {
38672                     error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType));
38673                 }
38674             }
38675         }
38676         function getIndexNodeForAccessExpression(accessNode) {
38677             return accessNode.kind === 195 ? accessNode.argumentExpression :
38678                 accessNode.kind === 185 ? accessNode.indexType :
38679                     accessNode.kind === 154 ? accessNode.expression :
38680                         accessNode;
38681         }
38682         function isGenericObjectType(type) {
38683             if (type.flags & 3145728) {
38684                 if (!(type.objectFlags & 4194304)) {
38685                     type.objectFlags |= 4194304 |
38686                         (ts.some(type.types, isGenericObjectType) ? 8388608 : 0);
38687                 }
38688                 return !!(type.objectFlags & 8388608);
38689             }
38690             return !!(type.flags & 58982400) || isGenericMappedType(type);
38691         }
38692         function isGenericIndexType(type) {
38693             if (type.flags & 3145728) {
38694                 if (!(type.objectFlags & 16777216)) {
38695                     type.objectFlags |= 16777216 |
38696                         (ts.some(type.types, isGenericIndexType) ? 33554432 : 0);
38697                 }
38698                 return !!(type.objectFlags & 33554432);
38699             }
38700             return !!(type.flags & (58982400 | 4194304));
38701         }
38702         function isThisTypeParameter(type) {
38703             return !!(type.flags & 262144 && type.isThisType);
38704         }
38705         function getSimplifiedType(type, writing) {
38706             return type.flags & 8388608 ? getSimplifiedIndexedAccessType(type, writing) :
38707                 type.flags & 16777216 ? getSimplifiedConditionalType(type, writing) :
38708                     type;
38709         }
38710         function distributeIndexOverObjectType(objectType, indexType, writing) {
38711             if (objectType.flags & 3145728) {
38712                 var types = ts.map(objectType.types, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType), writing); });
38713                 return objectType.flags & 2097152 || writing ? getIntersectionType(types) : getUnionType(types);
38714             }
38715         }
38716         function distributeObjectOverIndexType(objectType, indexType, writing) {
38717             if (indexType.flags & 1048576) {
38718                 var types = ts.map(indexType.types, function (t) { return getSimplifiedType(getIndexedAccessType(objectType, t), writing); });
38719                 return writing ? getIntersectionType(types) : getUnionType(types);
38720             }
38721         }
38722         function unwrapSubstitution(type) {
38723             if (type.flags & 33554432) {
38724                 return type.substitute;
38725             }
38726             return type;
38727         }
38728         function getSimplifiedIndexedAccessType(type, writing) {
38729             var cache = writing ? "simplifiedForWriting" : "simplifiedForReading";
38730             if (type[cache]) {
38731                 return type[cache] === circularConstraintType ? type : type[cache];
38732             }
38733             type[cache] = circularConstraintType;
38734             var objectType = unwrapSubstitution(getSimplifiedType(type.objectType, writing));
38735             var indexType = getSimplifiedType(type.indexType, writing);
38736             var distributedOverIndex = distributeObjectOverIndexType(objectType, indexType, writing);
38737             if (distributedOverIndex) {
38738                 return type[cache] = distributedOverIndex;
38739             }
38740             if (!(indexType.flags & 63176704)) {
38741                 var distributedOverObject = distributeIndexOverObjectType(objectType, indexType, writing);
38742                 if (distributedOverObject) {
38743                     return type[cache] = distributedOverObject;
38744                 }
38745             }
38746             if (isGenericMappedType(objectType)) {
38747                 return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), function (t) { return getSimplifiedType(t, writing); });
38748             }
38749             return type[cache] = type;
38750         }
38751         function getSimplifiedConditionalType(type, writing) {
38752             var checkType = type.checkType;
38753             var extendsType = type.extendsType;
38754             var trueType = getTrueTypeFromConditionalType(type);
38755             var falseType = getFalseTypeFromConditionalType(type);
38756             if (falseType.flags & 131072 && getActualTypeVariable(trueType) === getActualTypeVariable(checkType)) {
38757                 if (checkType.flags & 1 || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) {
38758                     return getSimplifiedType(trueType, writing);
38759                 }
38760                 else if (isIntersectionEmpty(checkType, extendsType)) {
38761                     return neverType;
38762                 }
38763             }
38764             else if (trueType.flags & 131072 && getActualTypeVariable(falseType) === getActualTypeVariable(checkType)) {
38765                 if (!(checkType.flags & 1) && isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) {
38766                     return neverType;
38767                 }
38768                 else if (checkType.flags & 1 || isIntersectionEmpty(checkType, extendsType)) {
38769                     return getSimplifiedType(falseType, writing);
38770                 }
38771             }
38772             return type;
38773         }
38774         function isIntersectionEmpty(type1, type2) {
38775             return !!(getUnionType([intersectTypes(type1, type2), neverType]).flags & 131072);
38776         }
38777         function substituteIndexedMappedType(objectType, index) {
38778             var mapper = createTypeMapper([getTypeParameterFromMappedType(objectType)], [index]);
38779             var templateMapper = combineTypeMappers(objectType.mapper, mapper);
38780             return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper);
38781         }
38782         function getIndexedAccessType(objectType, indexType, accessNode, aliasSymbol, aliasTypeArguments) {
38783             return getIndexedAccessTypeOrUndefined(objectType, indexType, accessNode, 0, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType);
38784         }
38785         function getIndexedAccessTypeOrUndefined(objectType, indexType, accessNode, accessFlags, aliasSymbol, aliasTypeArguments) {
38786             if (accessFlags === void 0) { accessFlags = 0; }
38787             if (objectType === wildcardType || indexType === wildcardType) {
38788                 return wildcardType;
38789             }
38790             if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304) && isTypeAssignableToKind(indexType, 4 | 8)) {
38791                 indexType = stringType;
38792             }
38793             if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 185) && isGenericObjectType(objectType)) {
38794                 if (objectType.flags & 3) {
38795                     return objectType;
38796                 }
38797                 var id = objectType.id + "," + indexType.id;
38798                 var type = indexedAccessTypes.get(id);
38799                 if (!type) {
38800                     indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType, aliasSymbol, aliasTypeArguments));
38801                 }
38802                 return type;
38803             }
38804             var apparentObjectType = getReducedApparentType(objectType);
38805             if (indexType.flags & 1048576 && !(indexType.flags & 16)) {
38806                 var propTypes = [];
38807                 var wasMissingProp = false;
38808                 for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) {
38809                     var t = _a[_i];
38810                     var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, wasMissingProp, accessNode, accessFlags);
38811                     if (propType) {
38812                         propTypes.push(propType);
38813                     }
38814                     else if (!accessNode) {
38815                         return undefined;
38816                     }
38817                     else {
38818                         wasMissingProp = true;
38819                     }
38820                 }
38821                 if (wasMissingProp) {
38822                     return undefined;
38823                 }
38824                 return accessFlags & 2 ? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments) : getUnionType(propTypes, 1, aliasSymbol, aliasTypeArguments);
38825             }
38826             return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, false, accessNode, accessFlags | 4);
38827         }
38828         function getTypeFromIndexedAccessTypeNode(node) {
38829             var links = getNodeLinks(node);
38830             if (!links.resolvedType) {
38831                 var objectType = getTypeFromTypeNode(node.objectType);
38832                 var indexType = getTypeFromTypeNode(node.indexType);
38833                 var potentialAlias = getAliasSymbolForTypeNode(node);
38834                 var resolved = getIndexedAccessType(objectType, indexType, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias));
38835                 links.resolvedType = resolved.flags & 8388608 &&
38836                     resolved.objectType === objectType &&
38837                     resolved.indexType === indexType ?
38838                     getConditionalFlowTypeOfType(resolved, node) : resolved;
38839             }
38840             return links.resolvedType;
38841         }
38842         function getTypeFromMappedTypeNode(node) {
38843             var links = getNodeLinks(node);
38844             if (!links.resolvedType) {
38845                 var type = createObjectType(32, node.symbol);
38846                 type.declaration = node;
38847                 type.aliasSymbol = getAliasSymbolForTypeNode(node);
38848                 type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(type.aliasSymbol);
38849                 links.resolvedType = type;
38850                 getConstraintTypeFromMappedType(type);
38851             }
38852             return links.resolvedType;
38853         }
38854         function getActualTypeVariable(type) {
38855             if (type.flags & 33554432) {
38856                 return type.baseType;
38857             }
38858             if (type.flags & 8388608 && (type.objectType.flags & 33554432 ||
38859                 type.indexType.flags & 33554432)) {
38860                 return getIndexedAccessType(getActualTypeVariable(type.objectType), getActualTypeVariable(type.indexType));
38861             }
38862             return type;
38863         }
38864         function getConditionalType(root, mapper) {
38865             var result;
38866             var extraTypes;
38867             var _loop_12 = function () {
38868                 var checkType = instantiateType(root.checkType, mapper);
38869                 var checkTypeInstantiable = isGenericObjectType(checkType) || isGenericIndexType(checkType);
38870                 var extendsType = instantiateType(root.extendsType, mapper);
38871                 if (checkType === wildcardType || extendsType === wildcardType) {
38872                     return { value: wildcardType };
38873                 }
38874                 var combinedMapper = void 0;
38875                 if (root.inferTypeParameters) {
38876                     var context = createInferenceContext(root.inferTypeParameters, undefined, 0);
38877                     if (!checkTypeInstantiable || !ts.some(root.inferTypeParameters, function (t) { return t === extendsType; })) {
38878                         inferTypes(context.inferences, checkType, extendsType, 128 | 256);
38879                     }
38880                     combinedMapper = mergeTypeMappers(mapper, context.mapper);
38881                 }
38882                 var inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
38883                 if (!checkTypeInstantiable && !isGenericObjectType(inferredExtendsType) && !isGenericIndexType(inferredExtendsType)) {
38884                     if (!(inferredExtendsType.flags & 3) && (checkType.flags & 1 || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) {
38885                         if (checkType.flags & 1) {
38886                             (extraTypes || (extraTypes = [])).push(instantiateTypeWithoutDepthIncrease(root.trueType, combinedMapper || mapper));
38887                         }
38888                         var falseType_1 = root.falseType;
38889                         if (falseType_1.flags & 16777216) {
38890                             var newRoot = falseType_1.root;
38891                             if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) {
38892                                 root = newRoot;
38893                                 return "continue";
38894                             }
38895                         }
38896                         result = instantiateTypeWithoutDepthIncrease(falseType_1, mapper);
38897                         return "break";
38898                     }
38899                     if (inferredExtendsType.flags & 3 || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) {
38900                         result = instantiateTypeWithoutDepthIncrease(root.trueType, combinedMapper || mapper);
38901                         return "break";
38902                     }
38903                 }
38904                 var erasedCheckType = getActualTypeVariable(checkType);
38905                 result = createType(16777216);
38906                 result.root = root;
38907                 result.checkType = erasedCheckType;
38908                 result.extendsType = extendsType;
38909                 result.mapper = mapper;
38910                 result.combinedMapper = combinedMapper;
38911                 result.aliasSymbol = root.aliasSymbol;
38912                 result.aliasTypeArguments = instantiateTypes(root.aliasTypeArguments, mapper);
38913                 return "break";
38914             };
38915             while (true) {
38916                 var state_4 = _loop_12();
38917                 if (typeof state_4 === "object")
38918                     return state_4.value;
38919                 if (state_4 === "break")
38920                     break;
38921             }
38922             return extraTypes ? getUnionType(ts.append(extraTypes, result)) : result;
38923         }
38924         function getTrueTypeFromConditionalType(type) {
38925             return type.resolvedTrueType || (type.resolvedTrueType = instantiateType(type.root.trueType, type.mapper));
38926         }
38927         function getFalseTypeFromConditionalType(type) {
38928             return type.resolvedFalseType || (type.resolvedFalseType = instantiateType(type.root.falseType, type.mapper));
38929         }
38930         function getInferredTrueTypeFromConditionalType(type) {
38931             return type.resolvedInferredTrueType || (type.resolvedInferredTrueType = type.combinedMapper ? instantiateType(type.root.trueType, type.combinedMapper) : getTrueTypeFromConditionalType(type));
38932         }
38933         function getInferTypeParameters(node) {
38934             var result;
38935             if (node.locals) {
38936                 node.locals.forEach(function (symbol) {
38937                     if (symbol.flags & 262144) {
38938                         result = ts.append(result, getDeclaredTypeOfSymbol(symbol));
38939                     }
38940                 });
38941             }
38942             return result;
38943         }
38944         function getTypeFromConditionalTypeNode(node) {
38945             var links = getNodeLinks(node);
38946             if (!links.resolvedType) {
38947                 var checkType = getTypeFromTypeNode(node.checkType);
38948                 var aliasSymbol = getAliasSymbolForTypeNode(node);
38949                 var aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
38950                 var allOuterTypeParameters = getOuterTypeParameters(node, true);
38951                 var outerTypeParameters = aliasTypeArguments ? allOuterTypeParameters : ts.filter(allOuterTypeParameters, function (tp) { return isTypeParameterPossiblyReferenced(tp, node); });
38952                 var root = {
38953                     node: node,
38954                     checkType: checkType,
38955                     extendsType: getTypeFromTypeNode(node.extendsType),
38956                     trueType: getTypeFromTypeNode(node.trueType),
38957                     falseType: getTypeFromTypeNode(node.falseType),
38958                     isDistributive: !!(checkType.flags & 262144),
38959                     inferTypeParameters: getInferTypeParameters(node),
38960                     outerTypeParameters: outerTypeParameters,
38961                     instantiations: undefined,
38962                     aliasSymbol: aliasSymbol,
38963                     aliasTypeArguments: aliasTypeArguments
38964                 };
38965                 links.resolvedType = getConditionalType(root, undefined);
38966                 if (outerTypeParameters) {
38967                     root.instantiations = ts.createMap();
38968                     root.instantiations.set(getTypeListId(outerTypeParameters), links.resolvedType);
38969                 }
38970             }
38971             return links.resolvedType;
38972         }
38973         function getTypeFromInferTypeNode(node) {
38974             var links = getNodeLinks(node);
38975             if (!links.resolvedType) {
38976                 links.resolvedType = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter));
38977             }
38978             return links.resolvedType;
38979         }
38980         function getIdentifierChain(node) {
38981             if (ts.isIdentifier(node)) {
38982                 return [node];
38983             }
38984             else {
38985                 return ts.append(getIdentifierChain(node.left), node.right);
38986             }
38987         }
38988         function getTypeFromImportTypeNode(node) {
38989             var links = getNodeLinks(node);
38990             if (!links.resolvedType) {
38991                 if (node.isTypeOf && node.typeArguments) {
38992                     error(node, ts.Diagnostics.Type_arguments_cannot_be_used_here);
38993                     links.resolvedSymbol = unknownSymbol;
38994                     return links.resolvedType = errorType;
38995                 }
38996                 if (!ts.isLiteralImportTypeNode(node)) {
38997                     error(node.argument, ts.Diagnostics.String_literal_expected);
38998                     links.resolvedSymbol = unknownSymbol;
38999                     return links.resolvedType = errorType;
39000                 }
39001                 var targetMeaning = node.isTypeOf ? 111551 : node.flags & 4194304 ? 111551 | 788968 : 788968;
39002                 var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal);
39003                 if (!innerModuleSymbol) {
39004                     links.resolvedSymbol = unknownSymbol;
39005                     return links.resolvedType = errorType;
39006                 }
39007                 var moduleSymbol = resolveExternalModuleSymbol(innerModuleSymbol, false);
39008                 if (!ts.nodeIsMissing(node.qualifier)) {
39009                     var nameStack = getIdentifierChain(node.qualifier);
39010                     var currentNamespace = moduleSymbol;
39011                     var current = void 0;
39012                     while (current = nameStack.shift()) {
39013                         var meaning = nameStack.length ? 1920 : targetMeaning;
39014                         var next = getSymbol(getExportsOfSymbol(getMergedSymbol(resolveSymbol(currentNamespace))), current.escapedText, meaning);
39015                         if (!next) {
39016                             error(current, ts.Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(currentNamespace), ts.declarationNameToString(current));
39017                             return links.resolvedType = errorType;
39018                         }
39019                         getNodeLinks(current).resolvedSymbol = next;
39020                         getNodeLinks(current.parent).resolvedSymbol = next;
39021                         currentNamespace = next;
39022                     }
39023                     links.resolvedType = resolveImportSymbolType(node, links, currentNamespace, targetMeaning);
39024                 }
39025                 else {
39026                     if (moduleSymbol.flags & targetMeaning) {
39027                         links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning);
39028                     }
39029                     else {
39030                         var errorMessage = targetMeaning === 111551
39031                             ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here
39032                             : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0;
39033                         error(node, errorMessage, node.argument.literal.text);
39034                         links.resolvedSymbol = unknownSymbol;
39035                         links.resolvedType = errorType;
39036                     }
39037                 }
39038             }
39039             return links.resolvedType;
39040         }
39041         function resolveImportSymbolType(node, links, symbol, meaning) {
39042             var resolvedSymbol = resolveSymbol(symbol);
39043             links.resolvedSymbol = resolvedSymbol;
39044             if (meaning === 111551) {
39045                 return getTypeOfSymbol(symbol);
39046             }
39047             else {
39048                 return getTypeReferenceType(node, resolvedSymbol);
39049             }
39050         }
39051         function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) {
39052             var links = getNodeLinks(node);
39053             if (!links.resolvedType) {
39054                 var aliasSymbol = getAliasSymbolForTypeNode(node);
39055                 if (getMembersOfSymbol(node.symbol).size === 0 && !aliasSymbol) {
39056                     links.resolvedType = emptyTypeLiteralType;
39057                 }
39058                 else {
39059                     var type = createObjectType(16, node.symbol);
39060                     type.aliasSymbol = aliasSymbol;
39061                     type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
39062                     if (ts.isJSDocTypeLiteral(node) && node.isArrayType) {
39063                         type = createArrayType(type);
39064                     }
39065                     links.resolvedType = type;
39066                 }
39067             }
39068             return links.resolvedType;
39069         }
39070         function getAliasSymbolForTypeNode(node) {
39071             var host = node.parent;
39072             while (ts.isParenthesizedTypeNode(host) || ts.isTypeOperatorNode(host) && host.operator === 138) {
39073                 host = host.parent;
39074             }
39075             return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined;
39076         }
39077         function getTypeArgumentsForAliasSymbol(symbol) {
39078             return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined;
39079         }
39080         function isNonGenericObjectType(type) {
39081             return !!(type.flags & 524288) && !isGenericMappedType(type);
39082         }
39083         function isEmptyObjectTypeOrSpreadsIntoEmptyObject(type) {
39084             return isEmptyObjectType(type) || !!(type.flags & (65536 | 32768 | 528 | 296 | 2112 | 132 | 1056 | 67108864 | 4194304));
39085         }
39086         function isSinglePropertyAnonymousObjectType(type) {
39087             return !!(type.flags & 524288) &&
39088                 !!(ts.getObjectFlags(type) & 16) &&
39089                 (ts.length(getPropertiesOfType(type)) === 1 || ts.every(getPropertiesOfType(type), function (p) { return !!(p.flags & 16777216); }));
39090         }
39091         function tryMergeUnionOfObjectTypeAndEmptyObject(type, readonly) {
39092             if (type.types.length === 2) {
39093                 var firstType = type.types[0];
39094                 var secondType = type.types[1];
39095                 if (ts.every(type.types, isEmptyObjectTypeOrSpreadsIntoEmptyObject)) {
39096                     return isEmptyObjectType(firstType) ? firstType : isEmptyObjectType(secondType) ? secondType : emptyObjectType;
39097                 }
39098                 if (isEmptyObjectTypeOrSpreadsIntoEmptyObject(firstType) && isSinglePropertyAnonymousObjectType(secondType)) {
39099                     return getAnonymousPartialType(secondType);
39100                 }
39101                 if (isEmptyObjectTypeOrSpreadsIntoEmptyObject(secondType) && isSinglePropertyAnonymousObjectType(firstType)) {
39102                     return getAnonymousPartialType(firstType);
39103                 }
39104             }
39105             function getAnonymousPartialType(type) {
39106                 var members = ts.createSymbolTable();
39107                 for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) {
39108                     var prop = _a[_i];
39109                     if (ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 | 16)) {
39110                     }
39111                     else if (isSpreadableProperty(prop)) {
39112                         var isSetonlyAccessor = prop.flags & 65536 && !(prop.flags & 32768);
39113                         var flags = 4 | 16777216;
39114                         var result = createSymbol(flags, prop.escapedName, readonly ? 8 : 0);
39115                         result.type = isSetonlyAccessor ? undefinedType : getTypeOfSymbol(prop);
39116                         result.declarations = prop.declarations;
39117                         result.nameType = getSymbolLinks(prop).nameType;
39118                         result.syntheticOrigin = prop;
39119                         members.set(prop.escapedName, result);
39120                     }
39121                 }
39122                 var spread = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfoOfType(type, 0), getIndexInfoOfType(type, 1));
39123                 spread.objectFlags |= 128 | 1048576;
39124                 return spread;
39125             }
39126         }
39127         function getSpreadType(left, right, symbol, objectFlags, readonly) {
39128             if (left.flags & 1 || right.flags & 1) {
39129                 return anyType;
39130             }
39131             if (left.flags & 2 || right.flags & 2) {
39132                 return unknownType;
39133             }
39134             if (left.flags & 131072) {
39135                 return right;
39136             }
39137             if (right.flags & 131072) {
39138                 return left;
39139             }
39140             if (left.flags & 1048576) {
39141                 var merged = tryMergeUnionOfObjectTypeAndEmptyObject(left, readonly);
39142                 if (merged) {
39143                     return getSpreadType(merged, right, symbol, objectFlags, readonly);
39144                 }
39145                 return mapType(left, function (t) { return getSpreadType(t, right, symbol, objectFlags, readonly); });
39146             }
39147             if (right.flags & 1048576) {
39148                 var merged = tryMergeUnionOfObjectTypeAndEmptyObject(right, readonly);
39149                 if (merged) {
39150                     return getSpreadType(left, merged, symbol, objectFlags, readonly);
39151                 }
39152                 return mapType(right, function (t) { return getSpreadType(left, t, symbol, objectFlags, readonly); });
39153             }
39154             if (right.flags & (528 | 296 | 2112 | 132 | 1056 | 67108864 | 4194304)) {
39155                 return left;
39156             }
39157             if (isGenericObjectType(left) || isGenericObjectType(right)) {
39158                 if (isEmptyObjectType(left)) {
39159                     return right;
39160                 }
39161                 if (left.flags & 2097152) {
39162                     var types = left.types;
39163                     var lastLeft = types[types.length - 1];
39164                     if (isNonGenericObjectType(lastLeft) && isNonGenericObjectType(right)) {
39165                         return getIntersectionType(ts.concatenate(types.slice(0, types.length - 1), [getSpreadType(lastLeft, right, symbol, objectFlags, readonly)]));
39166                     }
39167                 }
39168                 return getIntersectionType([left, right]);
39169             }
39170             var members = ts.createSymbolTable();
39171             var skippedPrivateMembers = ts.createUnderscoreEscapedMap();
39172             var stringIndexInfo;
39173             var numberIndexInfo;
39174             if (left === emptyObjectType) {
39175                 stringIndexInfo = getIndexInfoOfType(right, 0);
39176                 numberIndexInfo = getIndexInfoOfType(right, 1);
39177             }
39178             else {
39179                 stringIndexInfo = unionSpreadIndexInfos(getIndexInfoOfType(left, 0), getIndexInfoOfType(right, 0));
39180                 numberIndexInfo = unionSpreadIndexInfos(getIndexInfoOfType(left, 1), getIndexInfoOfType(right, 1));
39181             }
39182             for (var _i = 0, _a = getPropertiesOfType(right); _i < _a.length; _i++) {
39183                 var rightProp = _a[_i];
39184                 if (ts.getDeclarationModifierFlagsFromSymbol(rightProp) & (8 | 16)) {
39185                     skippedPrivateMembers.set(rightProp.escapedName, true);
39186                 }
39187                 else if (isSpreadableProperty(rightProp)) {
39188                     members.set(rightProp.escapedName, getSpreadSymbol(rightProp, readonly));
39189                 }
39190             }
39191             for (var _b = 0, _c = getPropertiesOfType(left); _b < _c.length; _b++) {
39192                 var leftProp = _c[_b];
39193                 if (skippedPrivateMembers.has(leftProp.escapedName) || !isSpreadableProperty(leftProp)) {
39194                     continue;
39195                 }
39196                 if (members.has(leftProp.escapedName)) {
39197                     var rightProp = members.get(leftProp.escapedName);
39198                     var rightType = getTypeOfSymbol(rightProp);
39199                     if (rightProp.flags & 16777216) {
39200                         var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations);
39201                         var flags = 4 | (leftProp.flags & 16777216);
39202                         var result = createSymbol(flags, leftProp.escapedName);
39203                         result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 524288)]);
39204                         result.leftSpread = leftProp;
39205                         result.rightSpread = rightProp;
39206                         result.declarations = declarations;
39207                         result.nameType = getSymbolLinks(leftProp).nameType;
39208                         members.set(leftProp.escapedName, result);
39209                     }
39210                 }
39211                 else {
39212                     members.set(leftProp.escapedName, getSpreadSymbol(leftProp, readonly));
39213                 }
39214             }
39215             var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfoWithReadonly(stringIndexInfo, readonly), getIndexInfoWithReadonly(numberIndexInfo, readonly));
39216             spread.objectFlags |= 128 | 1048576 | 1024 | objectFlags;
39217             return spread;
39218         }
39219         function isSpreadableProperty(prop) {
39220             return !ts.some(prop.declarations, ts.isPrivateIdentifierPropertyDeclaration) &&
39221                 (!(prop.flags & (8192 | 32768 | 65536)) ||
39222                     !prop.declarations.some(function (decl) { return ts.isClassLike(decl.parent); }));
39223         }
39224         function getSpreadSymbol(prop, readonly) {
39225             var isSetonlyAccessor = prop.flags & 65536 && !(prop.flags & 32768);
39226             if (!isSetonlyAccessor && readonly === isReadonlySymbol(prop)) {
39227                 return prop;
39228             }
39229             var flags = 4 | (prop.flags & 16777216);
39230             var result = createSymbol(flags, prop.escapedName, readonly ? 8 : 0);
39231             result.type = isSetonlyAccessor ? undefinedType : getTypeOfSymbol(prop);
39232             result.declarations = prop.declarations;
39233             result.nameType = getSymbolLinks(prop).nameType;
39234             result.syntheticOrigin = prop;
39235             return result;
39236         }
39237         function getIndexInfoWithReadonly(info, readonly) {
39238             return info && info.isReadonly !== readonly ? createIndexInfo(info.type, readonly, info.declaration) : info;
39239         }
39240         function createLiteralType(flags, value, symbol) {
39241             var type = createType(flags);
39242             type.symbol = symbol;
39243             type.value = value;
39244             return type;
39245         }
39246         function getFreshTypeOfLiteralType(type) {
39247             if (type.flags & 2944) {
39248                 if (!type.freshType) {
39249                     var freshType = createLiteralType(type.flags, type.value, type.symbol);
39250                     freshType.regularType = type;
39251                     freshType.freshType = freshType;
39252                     type.freshType = freshType;
39253                 }
39254                 return type.freshType;
39255             }
39256             return type;
39257         }
39258         function getRegularTypeOfLiteralType(type) {
39259             return type.flags & 2944 ? type.regularType :
39260                 type.flags & 1048576 ? (type.regularType || (type.regularType = getUnionType(ts.sameMap(type.types, getRegularTypeOfLiteralType)))) :
39261                     type;
39262         }
39263         function isFreshLiteralType(type) {
39264             return !!(type.flags & 2944) && type.freshType === type;
39265         }
39266         function getLiteralType(value, enumId, symbol) {
39267             var qualifier = typeof value === "number" ? "#" : typeof value === "string" ? "@" : "n";
39268             var key = (enumId ? enumId : "") + qualifier + (typeof value === "object" ? ts.pseudoBigIntToString(value) : value);
39269             var type = literalTypes.get(key);
39270             if (!type) {
39271                 var flags = (typeof value === "number" ? 256 :
39272                     typeof value === "string" ? 128 : 2048) |
39273                     (enumId ? 1024 : 0);
39274                 literalTypes.set(key, type = createLiteralType(flags, value, symbol));
39275                 type.regularType = type;
39276             }
39277             return type;
39278         }
39279         function getTypeFromLiteralTypeNode(node) {
39280             var links = getNodeLinks(node);
39281             if (!links.resolvedType) {
39282                 links.resolvedType = getRegularTypeOfLiteralType(checkExpression(node.literal));
39283             }
39284             return links.resolvedType;
39285         }
39286         function createUniqueESSymbolType(symbol) {
39287             var type = createType(8192);
39288             type.symbol = symbol;
39289             type.escapedName = "__@" + type.symbol.escapedName + "@" + getSymbolId(type.symbol);
39290             return type;
39291         }
39292         function getESSymbolLikeTypeForNode(node) {
39293             if (ts.isValidESSymbolDeclaration(node)) {
39294                 var symbol = getSymbolOfNode(node);
39295                 var links = getSymbolLinks(symbol);
39296                 return links.uniqueESSymbolType || (links.uniqueESSymbolType = createUniqueESSymbolType(symbol));
39297             }
39298             return esSymbolType;
39299         }
39300         function getThisType(node) {
39301             var container = ts.getThisContainer(node, false);
39302             var parent = container && container.parent;
39303             if (parent && (ts.isClassLike(parent) || parent.kind === 246)) {
39304                 if (!ts.hasModifier(container, 32) &&
39305                     (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) {
39306                     return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType;
39307                 }
39308             }
39309             if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6) {
39310                 return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent.parent.left).parent).thisType;
39311             }
39312             var host = node.flags & 4194304 ? ts.getHostSignatureFromJSDoc(node) : undefined;
39313             if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3) {
39314                 return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType;
39315             }
39316             if (isJSConstructor(container) && ts.isNodeDescendantOf(node, container.body)) {
39317                 return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(container)).thisType;
39318             }
39319             error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface);
39320             return errorType;
39321         }
39322         function getTypeFromThisTypeNode(node) {
39323             var links = getNodeLinks(node);
39324             if (!links.resolvedType) {
39325                 links.resolvedType = getThisType(node);
39326             }
39327             return links.resolvedType;
39328         }
39329         function getTypeFromTypeNode(node) {
39330             return getConditionalFlowTypeOfType(getTypeFromTypeNodeWorker(node), node);
39331         }
39332         function getTypeFromTypeNodeWorker(node) {
39333             switch (node.kind) {
39334                 case 125:
39335                 case 295:
39336                 case 296:
39337                     return anyType;
39338                 case 148:
39339                     return unknownType;
39340                 case 143:
39341                     return stringType;
39342                 case 140:
39343                     return numberType;
39344                 case 151:
39345                     return bigintType;
39346                 case 128:
39347                     return booleanType;
39348                 case 144:
39349                     return esSymbolType;
39350                 case 110:
39351                     return voidType;
39352                 case 146:
39353                     return undefinedType;
39354                 case 100:
39355                     return nullType;
39356                 case 137:
39357                     return neverType;
39358                 case 141:
39359                     return node.flags & 131072 && !noImplicitAny ? anyType : nonPrimitiveType;
39360                 case 183:
39361                 case 104:
39362                     return getTypeFromThisTypeNode(node);
39363                 case 187:
39364                     return getTypeFromLiteralTypeNode(node);
39365                 case 169:
39366                     return getTypeFromTypeReference(node);
39367                 case 168:
39368                     return node.assertsModifier ? voidType : booleanType;
39369                 case 216:
39370                     return getTypeFromTypeReference(node);
39371                 case 172:
39372                     return getTypeFromTypeQueryNode(node);
39373                 case 174:
39374                 case 175:
39375                     return getTypeFromArrayOrTupleTypeNode(node);
39376                 case 176:
39377                     return getTypeFromOptionalTypeNode(node);
39378                 case 178:
39379                     return getTypeFromUnionTypeNode(node);
39380                 case 179:
39381                     return getTypeFromIntersectionTypeNode(node);
39382                 case 297:
39383                     return getTypeFromJSDocNullableTypeNode(node);
39384                 case 299:
39385                     return addOptionality(getTypeFromTypeNode(node.type));
39386                 case 182:
39387                 case 298:
39388                 case 294:
39389                     return getTypeFromTypeNode(node.type);
39390                 case 177:
39391                     return getElementTypeOfArrayType(getTypeFromTypeNode(node.type)) || errorType;
39392                 case 301:
39393                     return getTypeFromJSDocVariadicType(node);
39394                 case 170:
39395                 case 171:
39396                 case 173:
39397                 case 304:
39398                 case 300:
39399                 case 305:
39400                     return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node);
39401                 case 184:
39402                     return getTypeFromTypeOperatorNode(node);
39403                 case 185:
39404                     return getTypeFromIndexedAccessTypeNode(node);
39405                 case 186:
39406                     return getTypeFromMappedTypeNode(node);
39407                 case 180:
39408                     return getTypeFromConditionalTypeNode(node);
39409                 case 181:
39410                     return getTypeFromInferTypeNode(node);
39411                 case 188:
39412                     return getTypeFromImportTypeNode(node);
39413                 case 75:
39414                 case 153:
39415                     var symbol = getSymbolAtLocation(node);
39416                     return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType;
39417                 default:
39418                     return errorType;
39419             }
39420         }
39421         function instantiateList(items, mapper, instantiator) {
39422             if (items && items.length) {
39423                 for (var i = 0; i < items.length; i++) {
39424                     var item = items[i];
39425                     var mapped = instantiator(item, mapper);
39426                     if (item !== mapped) {
39427                         var result = i === 0 ? [] : items.slice(0, i);
39428                         result.push(mapped);
39429                         for (i++; i < items.length; i++) {
39430                             result.push(instantiator(items[i], mapper));
39431                         }
39432                         return result;
39433                     }
39434                 }
39435             }
39436             return items;
39437         }
39438         function instantiateTypes(types, mapper) {
39439             return instantiateList(types, mapper, instantiateType);
39440         }
39441         function instantiateSignatures(signatures, mapper) {
39442             return instantiateList(signatures, mapper, instantiateSignature);
39443         }
39444         function createTypeMapper(sources, targets) {
39445             return sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : makeArrayTypeMapper(sources, targets);
39446         }
39447         function getMappedType(type, mapper) {
39448             switch (mapper.kind) {
39449                 case 0:
39450                     return type === mapper.source ? mapper.target : type;
39451                 case 1:
39452                     var sources = mapper.sources;
39453                     var targets = mapper.targets;
39454                     for (var i = 0; i < sources.length; i++) {
39455                         if (type === sources[i]) {
39456                             return targets ? targets[i] : anyType;
39457                         }
39458                     }
39459                     return type;
39460                 case 2:
39461                     return mapper.func(type);
39462                 case 3:
39463                 case 4:
39464                     var t1 = getMappedType(type, mapper.mapper1);
39465                     return t1 !== type && mapper.kind === 3 ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2);
39466             }
39467         }
39468         function makeUnaryTypeMapper(source, target) {
39469             return { kind: 0, source: source, target: target };
39470         }
39471         function makeArrayTypeMapper(sources, targets) {
39472             return { kind: 1, sources: sources, targets: targets };
39473         }
39474         function makeFunctionTypeMapper(func) {
39475             return { kind: 2, func: func };
39476         }
39477         function makeCompositeTypeMapper(kind, mapper1, mapper2) {
39478             return { kind: kind, mapper1: mapper1, mapper2: mapper2 };
39479         }
39480         function createTypeEraser(sources) {
39481             return createTypeMapper(sources, undefined);
39482         }
39483         function createBackreferenceMapper(context, index) {
39484             return makeFunctionTypeMapper(function (t) { return ts.findIndex(context.inferences, function (info) { return info.typeParameter === t; }) >= index ? unknownType : t; });
39485         }
39486         function combineTypeMappers(mapper1, mapper2) {
39487             return mapper1 ? makeCompositeTypeMapper(3, mapper1, mapper2) : mapper2;
39488         }
39489         function mergeTypeMappers(mapper1, mapper2) {
39490             return mapper1 ? makeCompositeTypeMapper(4, mapper1, mapper2) : mapper2;
39491         }
39492         function prependTypeMapping(source, target, mapper) {
39493             return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4, makeUnaryTypeMapper(source, target), mapper);
39494         }
39495         function appendTypeMapping(mapper, source, target) {
39496             return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4, mapper, makeUnaryTypeMapper(source, target));
39497         }
39498         function getRestrictiveTypeParameter(tp) {
39499             return tp.constraint === unknownType ? tp : tp.restrictiveInstantiation || (tp.restrictiveInstantiation = createTypeParameter(tp.symbol),
39500                 tp.restrictiveInstantiation.constraint = unknownType,
39501                 tp.restrictiveInstantiation);
39502         }
39503         function cloneTypeParameter(typeParameter) {
39504             var result = createTypeParameter(typeParameter.symbol);
39505             result.target = typeParameter;
39506             return result;
39507         }
39508         function instantiateTypePredicate(predicate, mapper) {
39509             return createTypePredicate(predicate.kind, predicate.parameterName, predicate.parameterIndex, instantiateType(predicate.type, mapper));
39510         }
39511         function instantiateSignature(signature, mapper, eraseTypeParameters) {
39512             var freshTypeParameters;
39513             if (signature.typeParameters && !eraseTypeParameters) {
39514                 freshTypeParameters = ts.map(signature.typeParameters, cloneTypeParameter);
39515                 mapper = combineTypeMappers(createTypeMapper(signature.typeParameters, freshTypeParameters), mapper);
39516                 for (var _i = 0, freshTypeParameters_1 = freshTypeParameters; _i < freshTypeParameters_1.length; _i++) {
39517                     var tp = freshTypeParameters_1[_i];
39518                     tp.mapper = mapper;
39519                 }
39520             }
39521             var result = createSignature(signature.declaration, freshTypeParameters, signature.thisParameter && instantiateSymbol(signature.thisParameter, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol), undefined, undefined, signature.minArgumentCount, signature.flags & 3);
39522             result.target = signature;
39523             result.mapper = mapper;
39524             return result;
39525         }
39526         function instantiateSymbol(symbol, mapper) {
39527             var links = getSymbolLinks(symbol);
39528             if (links.type && !couldContainTypeVariables(links.type)) {
39529                 return symbol;
39530             }
39531             if (ts.getCheckFlags(symbol) & 1) {
39532                 symbol = links.target;
39533                 mapper = combineTypeMappers(links.mapper, mapper);
39534             }
39535             var result = createSymbol(symbol.flags, symbol.escapedName, 1 | ts.getCheckFlags(symbol) & (8 | 4096 | 16384 | 32768));
39536             result.declarations = symbol.declarations;
39537             result.parent = symbol.parent;
39538             result.target = symbol;
39539             result.mapper = mapper;
39540             if (symbol.valueDeclaration) {
39541                 result.valueDeclaration = symbol.valueDeclaration;
39542             }
39543             if (links.nameType) {
39544                 result.nameType = links.nameType;
39545             }
39546             return result;
39547         }
39548         function getObjectTypeInstantiation(type, mapper) {
39549             var target = type.objectFlags & 64 ? type.target : type;
39550             var node = type.objectFlags & 4 ? type.node : type.symbol.declarations[0];
39551             var links = getNodeLinks(node);
39552             var typeParameters = links.outerTypeParameters;
39553             if (!typeParameters) {
39554                 var declaration_1 = node;
39555                 if (ts.isInJSFile(declaration_1)) {
39556                     var paramTag = ts.findAncestor(declaration_1, ts.isJSDocParameterTag);
39557                     if (paramTag) {
39558                         var paramSymbol = ts.getParameterSymbolFromJSDoc(paramTag);
39559                         if (paramSymbol) {
39560                             declaration_1 = paramSymbol.valueDeclaration;
39561                         }
39562                     }
39563                 }
39564                 var outerTypeParameters = getOuterTypeParameters(declaration_1, true);
39565                 if (isJSConstructor(declaration_1)) {
39566                     var templateTagParameters = getTypeParametersFromDeclaration(declaration_1);
39567                     outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters);
39568                 }
39569                 typeParameters = outerTypeParameters || ts.emptyArray;
39570                 typeParameters = (target.objectFlags & 4 || target.symbol.flags & 2048) && !target.aliasTypeArguments ?
39571                     ts.filter(typeParameters, function (tp) { return isTypeParameterPossiblyReferenced(tp, declaration_1); }) :
39572                     typeParameters;
39573                 links.outerTypeParameters = typeParameters;
39574                 if (typeParameters.length) {
39575                     links.instantiations = ts.createMap();
39576                     links.instantiations.set(getTypeListId(typeParameters), target);
39577                 }
39578             }
39579             if (typeParameters.length) {
39580                 var combinedMapper_1 = combineTypeMappers(type.mapper, mapper);
39581                 var typeArguments = ts.map(typeParameters, function (t) { return getMappedType(t, combinedMapper_1); });
39582                 var id = getTypeListId(typeArguments);
39583                 var result = links.instantiations.get(id);
39584                 if (!result) {
39585                     var newMapper = createTypeMapper(typeParameters, typeArguments);
39586                     result = target.objectFlags & 4 ? createDeferredTypeReference(type.target, type.node, newMapper) :
39587                         target.objectFlags & 32 ? instantiateMappedType(target, newMapper) :
39588                             instantiateAnonymousType(target, newMapper);
39589                     links.instantiations.set(id, result);
39590                 }
39591                 return result;
39592             }
39593             return type;
39594         }
39595         function maybeTypeParameterReference(node) {
39596             return !(node.kind === 153 ||
39597                 node.parent.kind === 169 && node.parent.typeArguments && node === node.parent.typeName ||
39598                 node.parent.kind === 188 && node.parent.typeArguments && node === node.parent.qualifier);
39599         }
39600         function isTypeParameterPossiblyReferenced(tp, node) {
39601             if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) {
39602                 var container = tp.symbol.declarations[0].parent;
39603                 for (var n = node; n !== container; n = n.parent) {
39604                     if (!n || n.kind === 223 || n.kind === 180 && ts.forEachChild(n.extendsType, containsReference)) {
39605                         return true;
39606                     }
39607                 }
39608                 return !!ts.forEachChild(node, containsReference);
39609             }
39610             return true;
39611             function containsReference(node) {
39612                 switch (node.kind) {
39613                     case 183:
39614                         return !!tp.isThisType;
39615                     case 75:
39616                         return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) &&
39617                             getTypeFromTypeNodeWorker(node) === tp;
39618                     case 172:
39619                         return true;
39620                 }
39621                 return !!ts.forEachChild(node, containsReference);
39622             }
39623         }
39624         function getHomomorphicTypeVariable(type) {
39625             var constraintType = getConstraintTypeFromMappedType(type);
39626             if (constraintType.flags & 4194304) {
39627                 var typeVariable = getActualTypeVariable(constraintType.type);
39628                 if (typeVariable.flags & 262144) {
39629                     return typeVariable;
39630                 }
39631             }
39632             return undefined;
39633         }
39634         function instantiateMappedType(type, mapper) {
39635             var typeVariable = getHomomorphicTypeVariable(type);
39636             if (typeVariable) {
39637                 var mappedTypeVariable = instantiateType(typeVariable, mapper);
39638                 if (typeVariable !== mappedTypeVariable) {
39639                     return mapType(getReducedType(mappedTypeVariable), function (t) {
39640                         if (t.flags & (3 | 58982400 | 524288 | 2097152) && t !== wildcardType && t !== errorType) {
39641                             var replacementMapper = prependTypeMapping(typeVariable, t, mapper);
39642                             return isArrayType(t) ? instantiateMappedArrayType(t, type, replacementMapper) :
39643                                 isTupleType(t) ? instantiateMappedTupleType(t, type, replacementMapper) :
39644                                     instantiateAnonymousType(type, replacementMapper);
39645                         }
39646                         return t;
39647                     });
39648                 }
39649             }
39650             return instantiateAnonymousType(type, mapper);
39651         }
39652         function getModifiedReadonlyState(state, modifiers) {
39653             return modifiers & 1 ? true : modifiers & 2 ? false : state;
39654         }
39655         function instantiateMappedArrayType(arrayType, mappedType, mapper) {
39656             var elementType = instantiateMappedTypeTemplate(mappedType, numberType, true, mapper);
39657             return elementType === errorType ? errorType :
39658                 createArrayType(elementType, getModifiedReadonlyState(isReadonlyArrayType(arrayType), getMappedTypeModifiers(mappedType)));
39659         }
39660         function instantiateMappedTupleType(tupleType, mappedType, mapper) {
39661             var minLength = tupleType.target.minLength;
39662             var elementTypes = ts.map(getTypeArguments(tupleType), function (_, i) {
39663                 return instantiateMappedTypeTemplate(mappedType, getLiteralType("" + i), i >= minLength, mapper);
39664             });
39665             var modifiers = getMappedTypeModifiers(mappedType);
39666             var newMinLength = modifiers & 4 ? 0 :
39667                 modifiers & 8 ? getTypeReferenceArity(tupleType) - (tupleType.target.hasRestElement ? 1 : 0) :
39668                     minLength;
39669             var newReadonly = getModifiedReadonlyState(tupleType.target.readonly, modifiers);
39670             return ts.contains(elementTypes, errorType) ? errorType :
39671                 createTupleType(elementTypes, newMinLength, tupleType.target.hasRestElement, newReadonly, tupleType.target.associatedNames);
39672         }
39673         function instantiateMappedTypeTemplate(type, key, isOptional, mapper) {
39674             var templateMapper = appendTypeMapping(mapper, getTypeParameterFromMappedType(type), key);
39675             var propType = instantiateType(getTemplateTypeFromMappedType(type.target || type), templateMapper);
39676             var modifiers = getMappedTypeModifiers(type);
39677             return strictNullChecks && modifiers & 4 && !maybeTypeOfKind(propType, 32768 | 16384) ? getOptionalType(propType) :
39678                 strictNullChecks && modifiers & 8 && isOptional ? getTypeWithFacts(propType, 524288) :
39679                     propType;
39680         }
39681         function instantiateAnonymousType(type, mapper) {
39682             var result = createObjectType(type.objectFlags | 64, type.symbol);
39683             if (type.objectFlags & 32) {
39684                 result.declaration = type.declaration;
39685                 var origTypeParameter = getTypeParameterFromMappedType(type);
39686                 var freshTypeParameter = cloneTypeParameter(origTypeParameter);
39687                 result.typeParameter = freshTypeParameter;
39688                 mapper = combineTypeMappers(makeUnaryTypeMapper(origTypeParameter, freshTypeParameter), mapper);
39689                 freshTypeParameter.mapper = mapper;
39690             }
39691             result.target = type;
39692             result.mapper = mapper;
39693             result.aliasSymbol = type.aliasSymbol;
39694             result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper);
39695             return result;
39696         }
39697         function getConditionalTypeInstantiation(type, mapper) {
39698             var root = type.root;
39699             if (root.outerTypeParameters) {
39700                 var typeArguments = ts.map(root.outerTypeParameters, function (t) { return getMappedType(t, mapper); });
39701                 var id = getTypeListId(typeArguments);
39702                 var result = root.instantiations.get(id);
39703                 if (!result) {
39704                     var newMapper = createTypeMapper(root.outerTypeParameters, typeArguments);
39705                     result = instantiateConditionalType(root, newMapper);
39706                     root.instantiations.set(id, result);
39707                 }
39708                 return result;
39709             }
39710             return type;
39711         }
39712         function instantiateConditionalType(root, mapper) {
39713             if (root.isDistributive) {
39714                 var checkType_1 = root.checkType;
39715                 var instantiatedType = getMappedType(checkType_1, mapper);
39716                 if (checkType_1 !== instantiatedType && instantiatedType.flags & (1048576 | 131072)) {
39717                     return mapType(instantiatedType, function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, mapper)); });
39718                 }
39719             }
39720             return getConditionalType(root, mapper);
39721         }
39722         function instantiateType(type, mapper) {
39723             if (!type || !mapper) {
39724                 return type;
39725             }
39726             if (instantiationDepth === 50 || instantiationCount >= 5000000) {
39727                 error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
39728                 return errorType;
39729             }
39730             totalInstantiationCount++;
39731             instantiationCount++;
39732             instantiationDepth++;
39733             var result = instantiateTypeWorker(type, mapper);
39734             instantiationDepth--;
39735             return result;
39736         }
39737         function instantiateTypeWithoutDepthIncrease(type, mapper) {
39738             instantiationDepth--;
39739             var result = instantiateType(type, mapper);
39740             instantiationDepth++;
39741             return result;
39742         }
39743         function instantiateTypeWorker(type, mapper) {
39744             var flags = type.flags;
39745             if (flags & 262144) {
39746                 return getMappedType(type, mapper);
39747             }
39748             if (flags & 524288) {
39749                 var objectFlags = type.objectFlags;
39750                 if (objectFlags & 16) {
39751                     return couldContainTypeVariables(type) ?
39752                         getObjectTypeInstantiation(type, mapper) : type;
39753                 }
39754                 if (objectFlags & 32) {
39755                     return getObjectTypeInstantiation(type, mapper);
39756                 }
39757                 if (objectFlags & 4) {
39758                     if (type.node) {
39759                         return getObjectTypeInstantiation(type, mapper);
39760                     }
39761                     var resolvedTypeArguments = type.resolvedTypeArguments;
39762                     var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper);
39763                     return newTypeArguments !== resolvedTypeArguments ? createTypeReference(type.target, newTypeArguments) : type;
39764                 }
39765                 return type;
39766             }
39767             if ((flags & 2097152) || (flags & 1048576 && !(flags & 131068))) {
39768                 if (!couldContainTypeVariables(type)) {
39769                     return type;
39770                 }
39771                 var types = type.types;
39772                 var newTypes = instantiateTypes(types, mapper);
39773                 return newTypes === types
39774                     ? type
39775                     : (flags & 2097152)
39776                         ? getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper))
39777                         : getUnionType(newTypes, 1, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper));
39778             }
39779             if (flags & 4194304) {
39780                 return getIndexType(instantiateType(type.type, mapper));
39781             }
39782             if (flags & 8388608) {
39783                 return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), undefined, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper));
39784             }
39785             if (flags & 16777216) {
39786                 return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper));
39787             }
39788             if (flags & 33554432) {
39789                 var maybeVariable = instantiateType(type.baseType, mapper);
39790                 if (maybeVariable.flags & 8650752) {
39791                     return getSubstitutionType(maybeVariable, instantiateType(type.substitute, mapper));
39792                 }
39793                 else {
39794                     var sub = instantiateType(type.substitute, mapper);
39795                     if (sub.flags & 3 || isTypeAssignableTo(getRestrictiveInstantiation(maybeVariable), getRestrictiveInstantiation(sub))) {
39796                         return maybeVariable;
39797                     }
39798                     return sub;
39799                 }
39800             }
39801             return type;
39802         }
39803         function getPermissiveInstantiation(type) {
39804             return type.flags & (131068 | 3 | 131072) ? type :
39805                 type.permissiveInstantiation || (type.permissiveInstantiation = instantiateType(type, permissiveMapper));
39806         }
39807         function getRestrictiveInstantiation(type) {
39808             if (type.flags & (131068 | 3 | 131072)) {
39809                 return type;
39810             }
39811             if (type.restrictiveInstantiation) {
39812                 return type.restrictiveInstantiation;
39813             }
39814             type.restrictiveInstantiation = instantiateType(type, restrictiveMapper);
39815             type.restrictiveInstantiation.restrictiveInstantiation = type.restrictiveInstantiation;
39816             return type.restrictiveInstantiation;
39817         }
39818         function instantiateIndexInfo(info, mapper) {
39819             return info && createIndexInfo(instantiateType(info.type, mapper), info.isReadonly, info.declaration);
39820         }
39821         function isContextSensitive(node) {
39822             ts.Debug.assert(node.kind !== 161 || ts.isObjectLiteralMethod(node));
39823             switch (node.kind) {
39824                 case 201:
39825                 case 202:
39826                 case 161:
39827                 case 244:
39828                     return isContextSensitiveFunctionLikeDeclaration(node);
39829                 case 193:
39830                     return ts.some(node.properties, isContextSensitive);
39831                 case 192:
39832                     return ts.some(node.elements, isContextSensitive);
39833                 case 210:
39834                     return isContextSensitive(node.whenTrue) ||
39835                         isContextSensitive(node.whenFalse);
39836                 case 209:
39837                     return (node.operatorToken.kind === 56 || node.operatorToken.kind === 60) &&
39838                         (isContextSensitive(node.left) || isContextSensitive(node.right));
39839                 case 281:
39840                     return isContextSensitive(node.initializer);
39841                 case 200:
39842                     return isContextSensitive(node.expression);
39843                 case 274:
39844                     return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive);
39845                 case 273: {
39846                     var initializer = node.initializer;
39847                     return !!initializer && isContextSensitive(initializer);
39848                 }
39849                 case 276: {
39850                     var expression = node.expression;
39851                     return !!expression && isContextSensitive(expression);
39852                 }
39853             }
39854             return false;
39855         }
39856         function isContextSensitiveFunctionLikeDeclaration(node) {
39857             return (!ts.isFunctionDeclaration(node) || ts.isInJSFile(node) && !!getTypeForDeclarationFromJSDocComment(node)) &&
39858                 (hasContextSensitiveParameters(node) || hasContextSensitiveReturnExpression(node));
39859         }
39860         function hasContextSensitiveParameters(node) {
39861             if (!node.typeParameters) {
39862                 if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) {
39863                     return true;
39864                 }
39865                 if (node.kind !== 202) {
39866                     var parameter = ts.firstOrUndefined(node.parameters);
39867                     if (!(parameter && ts.parameterIsThisKeyword(parameter))) {
39868                         return true;
39869                     }
39870                 }
39871             }
39872             return false;
39873         }
39874         function hasContextSensitiveReturnExpression(node) {
39875             return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 223 && isContextSensitive(node.body);
39876         }
39877         function isContextSensitiveFunctionOrObjectLiteralMethod(func) {
39878             return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) &&
39879                 isContextSensitiveFunctionLikeDeclaration(func);
39880         }
39881         function getTypeWithoutSignatures(type) {
39882             if (type.flags & 524288) {
39883                 var resolved = resolveStructuredTypeMembers(type);
39884                 if (resolved.constructSignatures.length || resolved.callSignatures.length) {
39885                     var result = createObjectType(16, type.symbol);
39886                     result.members = resolved.members;
39887                     result.properties = resolved.properties;
39888                     result.callSignatures = ts.emptyArray;
39889                     result.constructSignatures = ts.emptyArray;
39890                     return result;
39891                 }
39892             }
39893             else if (type.flags & 2097152) {
39894                 return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures));
39895             }
39896             return type;
39897         }
39898         function isTypeIdenticalTo(source, target) {
39899             return isTypeRelatedTo(source, target, identityRelation);
39900         }
39901         function compareTypesIdentical(source, target) {
39902             return isTypeRelatedTo(source, target, identityRelation) ? -1 : 0;
39903         }
39904         function compareTypesAssignable(source, target) {
39905             return isTypeRelatedTo(source, target, assignableRelation) ? -1 : 0;
39906         }
39907         function compareTypesSubtypeOf(source, target) {
39908             return isTypeRelatedTo(source, target, subtypeRelation) ? -1 : 0;
39909         }
39910         function isTypeSubtypeOf(source, target) {
39911             return isTypeRelatedTo(source, target, subtypeRelation);
39912         }
39913         function isTypeAssignableTo(source, target) {
39914             return isTypeRelatedTo(source, target, assignableRelation);
39915         }
39916         function isTypeDerivedFrom(source, target) {
39917             return source.flags & 1048576 ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) :
39918                 target.flags & 1048576 ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) :
39919                     source.flags & 58982400 ? isTypeDerivedFrom(getBaseConstraintOfType(source) || unknownType, target) :
39920                         target === globalObjectType ? !!(source.flags & (524288 | 67108864)) :
39921                             target === globalFunctionType ? !!(source.flags & 524288) && isFunctionObjectType(source) :
39922                                 hasBaseType(source, getTargetType(target));
39923         }
39924         function isTypeComparableTo(source, target) {
39925             return isTypeRelatedTo(source, target, comparableRelation);
39926         }
39927         function areTypesComparable(type1, type2) {
39928             return isTypeComparableTo(type1, type2) || isTypeComparableTo(type2, type1);
39929         }
39930         function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain, errorOutputObject) {
39931             return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain, errorOutputObject);
39932         }
39933         function checkTypeAssignableToAndOptionallyElaborate(source, target, errorNode, expr, headMessage, containingMessageChain) {
39934             return checkTypeRelatedToAndOptionallyElaborate(source, target, assignableRelation, errorNode, expr, headMessage, containingMessageChain, undefined);
39935         }
39936         function checkTypeRelatedToAndOptionallyElaborate(source, target, relation, errorNode, expr, headMessage, containingMessageChain, errorOutputContainer) {
39937             if (isTypeRelatedTo(source, target, relation))
39938                 return true;
39939             if (!errorNode || !elaborateError(expr, source, target, relation, headMessage, containingMessageChain, errorOutputContainer)) {
39940                 return checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer);
39941             }
39942             return false;
39943         }
39944         function isOrHasGenericConditional(type) {
39945             return !!(type.flags & 16777216 || (type.flags & 2097152 && ts.some(type.types, isOrHasGenericConditional)));
39946         }
39947         function elaborateError(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer) {
39948             if (!node || isOrHasGenericConditional(target))
39949                 return false;
39950             if (!checkTypeRelatedTo(source, target, relation, undefined)
39951                 && elaborateDidYouMeanToCallOrConstruct(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer)) {
39952                 return true;
39953             }
39954             switch (node.kind) {
39955                 case 276:
39956                 case 200:
39957                     return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer);
39958                 case 209:
39959                     switch (node.operatorToken.kind) {
39960                         case 62:
39961                         case 27:
39962                             return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer);
39963                     }
39964                     break;
39965                 case 193:
39966                     return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer);
39967                 case 192:
39968                     return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer);
39969                 case 274:
39970                     return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer);
39971                 case 202:
39972                     return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer);
39973             }
39974             return false;
39975         }
39976         function elaborateDidYouMeanToCallOrConstruct(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer) {
39977             var callSignatures = getSignaturesOfType(source, 0);
39978             var constructSignatures = getSignaturesOfType(source, 1);
39979             for (var _i = 0, _a = [constructSignatures, callSignatures]; _i < _a.length; _i++) {
39980                 var signatures = _a[_i];
39981                 if (ts.some(signatures, function (s) {
39982                     var returnType = getReturnTypeOfSignature(s);
39983                     return !(returnType.flags & (1 | 131072)) && checkTypeRelatedTo(returnType, target, relation, undefined);
39984                 })) {
39985                     var resultObj = errorOutputContainer || {};
39986                     checkTypeAssignableTo(source, target, node, headMessage, containingMessageChain, resultObj);
39987                     var diagnostic = resultObj.errors[resultObj.errors.length - 1];
39988                     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));
39989                     return true;
39990                 }
39991             }
39992             return false;
39993         }
39994         function elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer) {
39995             if (ts.isBlock(node.body)) {
39996                 return false;
39997             }
39998             if (ts.some(node.parameters, ts.hasType)) {
39999                 return false;
40000             }
40001             var sourceSig = getSingleCallSignature(source);
40002             if (!sourceSig) {
40003                 return false;
40004             }
40005             var targetSignatures = getSignaturesOfType(target, 0);
40006             if (!ts.length(targetSignatures)) {
40007                 return false;
40008             }
40009             var returnExpression = node.body;
40010             var sourceReturn = getReturnTypeOfSignature(sourceSig);
40011             var targetReturn = getUnionType(ts.map(targetSignatures, getReturnTypeOfSignature));
40012             if (!checkTypeRelatedTo(sourceReturn, targetReturn, relation, undefined)) {
40013                 var elaborated = returnExpression && elaborateError(returnExpression, sourceReturn, targetReturn, relation, undefined, containingMessageChain, errorOutputContainer);
40014                 if (elaborated) {
40015                     return elaborated;
40016                 }
40017                 var resultObj = errorOutputContainer || {};
40018                 checkTypeRelatedTo(sourceReturn, targetReturn, relation, returnExpression, undefined, containingMessageChain, resultObj);
40019                 if (resultObj.errors) {
40020                     if (target.symbol && ts.length(target.symbol.declarations)) {
40021                         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));
40022                     }
40023                     if ((ts.getFunctionFlags(node) & 2) === 0
40024                         && !getTypeOfPropertyOfType(sourceReturn, "then")
40025                         && checkTypeRelatedTo(createPromiseType(sourceReturn), targetReturn, relation, undefined)) {
40026                         ts.addRelatedInfo(resultObj.errors[resultObj.errors.length - 1], ts.createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async));
40027                     }
40028                     return true;
40029                 }
40030             }
40031             return false;
40032         }
40033         function getBestMatchIndexedAccessTypeOrUndefined(source, target, nameType) {
40034             var idx = getIndexedAccessTypeOrUndefined(target, nameType);
40035             if (idx) {
40036                 return idx;
40037             }
40038             if (target.flags & 1048576) {
40039                 var best = getBestMatchingType(source, target);
40040                 if (best) {
40041                     return getIndexedAccessTypeOrUndefined(best, nameType);
40042                 }
40043             }
40044         }
40045         function checkExpressionForMutableLocationWithContextualType(next, sourcePropType) {
40046             next.contextualType = sourcePropType;
40047             try {
40048                 return checkExpressionForMutableLocation(next, 1, sourcePropType);
40049             }
40050             finally {
40051                 next.contextualType = undefined;
40052             }
40053         }
40054         function elaborateElementwise(iterator, source, target, relation, containingMessageChain, errorOutputContainer) {
40055             var reportedError = false;
40056             for (var status = iterator.next(); !status.done; status = iterator.next()) {
40057                 var _a = status.value, prop = _a.errorNode, next = _a.innerExpression, nameType = _a.nameType, errorMessage = _a.errorMessage;
40058                 var targetPropType = getBestMatchIndexedAccessTypeOrUndefined(source, target, nameType);
40059                 if (!targetPropType || targetPropType.flags & 8388608)
40060                     continue;
40061                 var sourcePropType = getIndexedAccessTypeOrUndefined(source, nameType);
40062                 if (sourcePropType && !checkTypeRelatedTo(sourcePropType, targetPropType, relation, undefined)) {
40063                     var elaborated = next && elaborateError(next, sourcePropType, targetPropType, relation, undefined, containingMessageChain, errorOutputContainer);
40064                     if (elaborated) {
40065                         reportedError = true;
40066                     }
40067                     else {
40068                         var resultObj = errorOutputContainer || {};
40069                         var specificSource = next ? checkExpressionForMutableLocationWithContextualType(next, sourcePropType) : sourcePropType;
40070                         var result = checkTypeRelatedTo(specificSource, targetPropType, relation, prop, errorMessage, containingMessageChain, resultObj);
40071                         if (result && specificSource !== sourcePropType) {
40072                             checkTypeRelatedTo(sourcePropType, targetPropType, relation, prop, errorMessage, containingMessageChain, resultObj);
40073                         }
40074                         if (resultObj.errors) {
40075                             var reportedDiag = resultObj.errors[resultObj.errors.length - 1];
40076                             var propertyName = isTypeUsableAsPropertyName(nameType) ? getPropertyNameFromType(nameType) : undefined;
40077                             var targetProp = propertyName !== undefined ? getPropertyOfType(target, propertyName) : undefined;
40078                             var issuedElaboration = false;
40079                             if (!targetProp) {
40080                                 var indexInfo = isTypeAssignableToKind(nameType, 296) && getIndexInfoOfType(target, 1) ||
40081                                     getIndexInfoOfType(target, 0) ||
40082                                     undefined;
40083                                 if (indexInfo && indexInfo.declaration && !ts.getSourceFileOfNode(indexInfo.declaration).hasNoDefaultLib) {
40084                                     issuedElaboration = true;
40085                                     ts.addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(indexInfo.declaration, ts.Diagnostics.The_expected_type_comes_from_this_index_signature));
40086                                 }
40087                             }
40088                             if (!issuedElaboration && (targetProp && ts.length(targetProp.declarations) || target.symbol && ts.length(target.symbol.declarations))) {
40089                                 var targetNode = targetProp && ts.length(targetProp.declarations) ? targetProp.declarations[0] : target.symbol.declarations[0];
40090                                 if (!ts.getSourceFileOfNode(targetNode).hasNoDefaultLib) {
40091                                     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)));
40092                                 }
40093                             }
40094                         }
40095                         reportedError = true;
40096                     }
40097                 }
40098             }
40099             return reportedError;
40100         }
40101         function generateJsxAttributes(node) {
40102             var _i, _a, prop;
40103             return __generator(this, function (_b) {
40104                 switch (_b.label) {
40105                     case 0:
40106                         if (!ts.length(node.properties))
40107                             return [2];
40108                         _i = 0, _a = node.properties;
40109                         _b.label = 1;
40110                     case 1:
40111                         if (!(_i < _a.length)) return [3, 4];
40112                         prop = _a[_i];
40113                         if (ts.isJsxSpreadAttribute(prop))
40114                             return [3, 3];
40115                         return [4, { errorNode: prop.name, innerExpression: prop.initializer, nameType: getLiteralType(ts.idText(prop.name)) }];
40116                     case 2:
40117                         _b.sent();
40118                         _b.label = 3;
40119                     case 3:
40120                         _i++;
40121                         return [3, 1];
40122                     case 4: return [2];
40123                 }
40124             });
40125         }
40126         function generateJsxChildren(node, getInvalidTextDiagnostic) {
40127             var memberOffset, i, child, nameType, elem;
40128             return __generator(this, function (_a) {
40129                 switch (_a.label) {
40130                     case 0:
40131                         if (!ts.length(node.children))
40132                             return [2];
40133                         memberOffset = 0;
40134                         i = 0;
40135                         _a.label = 1;
40136                     case 1:
40137                         if (!(i < node.children.length)) return [3, 5];
40138                         child = node.children[i];
40139                         nameType = getLiteralType(i - memberOffset);
40140                         elem = getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic);
40141                         if (!elem) return [3, 3];
40142                         return [4, elem];
40143                     case 2:
40144                         _a.sent();
40145                         return [3, 4];
40146                     case 3:
40147                         memberOffset++;
40148                         _a.label = 4;
40149                     case 4:
40150                         i++;
40151                         return [3, 1];
40152                     case 5: return [2];
40153                 }
40154             });
40155         }
40156         function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) {
40157             switch (child.kind) {
40158                 case 276:
40159                     return { errorNode: child, innerExpression: child.expression, nameType: nameType };
40160                 case 11:
40161                     if (child.containsOnlyTriviaWhiteSpaces) {
40162                         break;
40163                     }
40164                     return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() };
40165                 case 266:
40166                 case 267:
40167                 case 270:
40168                     return { errorNode: child, innerExpression: child, nameType: nameType };
40169                 default:
40170                     return ts.Debug.assertNever(child, "Found invalid jsx child");
40171             }
40172         }
40173         function getSemanticJsxChildren(children) {
40174             return ts.filter(children, function (i) { return !ts.isJsxText(i) || !i.containsOnlyTriviaWhiteSpaces; });
40175         }
40176         function elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer) {
40177             var result = elaborateElementwise(generateJsxAttributes(node), source, target, relation, containingMessageChain, errorOutputContainer);
40178             var invalidTextDiagnostic;
40179             if (ts.isJsxOpeningElement(node.parent) && ts.isJsxElement(node.parent.parent)) {
40180                 var containingElement = node.parent.parent;
40181                 var childPropName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node));
40182                 var childrenPropName = childPropName === undefined ? "children" : ts.unescapeLeadingUnderscores(childPropName);
40183                 var childrenNameType = getLiteralType(childrenPropName);
40184                 var childrenTargetType = getIndexedAccessType(target, childrenNameType);
40185                 var validChildren = getSemanticJsxChildren(containingElement.children);
40186                 if (!ts.length(validChildren)) {
40187                     return result;
40188                 }
40189                 var moreThanOneRealChildren = ts.length(validChildren) > 1;
40190                 var arrayLikeTargetParts = filterType(childrenTargetType, isArrayOrTupleLikeType);
40191                 var nonArrayLikeTargetParts = filterType(childrenTargetType, function (t) { return !isArrayOrTupleLikeType(t); });
40192                 if (moreThanOneRealChildren) {
40193                     if (arrayLikeTargetParts !== neverType) {
40194                         var realSource = createTupleType(checkJsxChildren(containingElement, 0));
40195                         var children = generateJsxChildren(containingElement, getInvalidTextualChildDiagnostic);
40196                         result = elaborateElementwise(children, realSource, arrayLikeTargetParts, relation, containingMessageChain, errorOutputContainer) || result;
40197                     }
40198                     else if (!isTypeRelatedTo(getIndexedAccessType(source, childrenNameType), childrenTargetType, relation)) {
40199                         result = true;
40200                         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));
40201                         if (errorOutputContainer && errorOutputContainer.skipLogging) {
40202                             (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
40203                         }
40204                     }
40205                 }
40206                 else {
40207                     if (nonArrayLikeTargetParts !== neverType) {
40208                         var child = validChildren[0];
40209                         var elem_1 = getElaborationElementForJsxChild(child, childrenNameType, getInvalidTextualChildDiagnostic);
40210                         if (elem_1) {
40211                             result = elaborateElementwise((function () { return __generator(this, function (_a) {
40212                                 switch (_a.label) {
40213                                     case 0: return [4, elem_1];
40214                                     case 1:
40215                                         _a.sent();
40216                                         return [2];
40217                                 }
40218                             }); })(), source, target, relation, containingMessageChain, errorOutputContainer) || result;
40219                         }
40220                     }
40221                     else if (!isTypeRelatedTo(getIndexedAccessType(source, childrenNameType), childrenTargetType, relation)) {
40222                         result = true;
40223                         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));
40224                         if (errorOutputContainer && errorOutputContainer.skipLogging) {
40225                             (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
40226                         }
40227                     }
40228                 }
40229             }
40230             return result;
40231             function getInvalidTextualChildDiagnostic() {
40232                 if (!invalidTextDiagnostic) {
40233                     var tagNameText = ts.getTextOfNode(node.parent.tagName);
40234                     var childPropName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node));
40235                     var childrenPropName = childPropName === undefined ? "children" : ts.unescapeLeadingUnderscores(childPropName);
40236                     var childrenTargetType = getIndexedAccessType(target, getLiteralType(childrenPropName));
40237                     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;
40238                     invalidTextDiagnostic = __assign(__assign({}, diagnostic), { key: "!!ALREADY FORMATTED!!", message: ts.formatMessage(undefined, diagnostic, tagNameText, childrenPropName, typeToString(childrenTargetType)) });
40239                 }
40240                 return invalidTextDiagnostic;
40241             }
40242         }
40243         function generateLimitedTupleElements(node, target) {
40244             var len, i, elem, nameType;
40245             return __generator(this, function (_a) {
40246                 switch (_a.label) {
40247                     case 0:
40248                         len = ts.length(node.elements);
40249                         if (!len)
40250                             return [2];
40251                         i = 0;
40252                         _a.label = 1;
40253                     case 1:
40254                         if (!(i < len)) return [3, 4];
40255                         if (isTupleLikeType(target) && !getPropertyOfType(target, ("" + i)))
40256                             return [3, 3];
40257                         elem = node.elements[i];
40258                         if (ts.isOmittedExpression(elem))
40259                             return [3, 3];
40260                         nameType = getLiteralType(i);
40261                         return [4, { errorNode: elem, innerExpression: elem, nameType: nameType }];
40262                     case 2:
40263                         _a.sent();
40264                         _a.label = 3;
40265                     case 3:
40266                         i++;
40267                         return [3, 1];
40268                     case 4: return [2];
40269                 }
40270             });
40271         }
40272         function elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) {
40273             if (target.flags & 131068)
40274                 return false;
40275             if (isTupleLikeType(source)) {
40276                 return elaborateElementwise(generateLimitedTupleElements(node, target), source, target, relation, containingMessageChain, errorOutputContainer);
40277             }
40278             var oldContext = node.contextualType;
40279             node.contextualType = target;
40280             try {
40281                 var tupleizedType = checkArrayLiteral(node, 1, true);
40282                 node.contextualType = oldContext;
40283                 if (isTupleLikeType(tupleizedType)) {
40284                     return elaborateElementwise(generateLimitedTupleElements(node, target), tupleizedType, target, relation, containingMessageChain, errorOutputContainer);
40285                 }
40286                 return false;
40287             }
40288             finally {
40289                 node.contextualType = oldContext;
40290             }
40291         }
40292         function generateObjectLiteralElements(node) {
40293             var _i, _a, prop, type, _b;
40294             return __generator(this, function (_c) {
40295                 switch (_c.label) {
40296                     case 0:
40297                         if (!ts.length(node.properties))
40298                             return [2];
40299                         _i = 0, _a = node.properties;
40300                         _c.label = 1;
40301                     case 1:
40302                         if (!(_i < _a.length)) return [3, 8];
40303                         prop = _a[_i];
40304                         if (ts.isSpreadAssignment(prop))
40305                             return [3, 7];
40306                         type = getLiteralTypeFromProperty(getSymbolOfNode(prop), 8576);
40307                         if (!type || (type.flags & 131072)) {
40308                             return [3, 7];
40309                         }
40310                         _b = prop.kind;
40311                         switch (_b) {
40312                             case 164: return [3, 2];
40313                             case 163: return [3, 2];
40314                             case 161: return [3, 2];
40315                             case 282: return [3, 2];
40316                             case 281: return [3, 4];
40317                         }
40318                         return [3, 6];
40319                     case 2: return [4, { errorNode: prop.name, innerExpression: undefined, nameType: type }];
40320                     case 3:
40321                         _c.sent();
40322                         return [3, 7];
40323                     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 }];
40324                     case 5:
40325                         _c.sent();
40326                         return [3, 7];
40327                     case 6:
40328                         ts.Debug.assertNever(prop);
40329                         _c.label = 7;
40330                     case 7:
40331                         _i++;
40332                         return [3, 1];
40333                     case 8: return [2];
40334                 }
40335             });
40336         }
40337         function elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) {
40338             if (target.flags & 131068)
40339                 return false;
40340             return elaborateElementwise(generateObjectLiteralElements(node), source, target, relation, containingMessageChain, errorOutputContainer);
40341         }
40342         function checkTypeComparableTo(source, target, errorNode, headMessage, containingMessageChain) {
40343             return checkTypeRelatedTo(source, target, comparableRelation, errorNode, headMessage, containingMessageChain);
40344         }
40345         function isSignatureAssignableTo(source, target, ignoreReturnTypes) {
40346             return compareSignaturesRelated(source, target, ignoreReturnTypes ? 4 : 0, false, undefined, undefined, compareTypesAssignable, undefined) !== 0;
40347         }
40348         function isAnySignature(s) {
40349             return !s.typeParameters && (!s.thisParameter || isTypeAny(getTypeOfParameter(s.thisParameter))) && s.parameters.length === 1 &&
40350                 signatureHasRestParameter(s) && (getTypeOfParameter(s.parameters[0]) === anyArrayType || isTypeAny(getTypeOfParameter(s.parameters[0]))) &&
40351                 isTypeAny(getReturnTypeOfSignature(s));
40352         }
40353         function compareSignaturesRelated(source, target, checkMode, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) {
40354             if (source === target) {
40355                 return -1;
40356             }
40357             if (isAnySignature(target)) {
40358                 return -1;
40359             }
40360             var targetCount = getParameterCount(target);
40361             var sourceHasMoreParameters = !hasEffectiveRestParameter(target) &&
40362                 (checkMode & 8 ? hasEffectiveRestParameter(source) || getParameterCount(source) > targetCount : getMinArgumentCount(source) > targetCount);
40363             if (sourceHasMoreParameters) {
40364                 return 0;
40365             }
40366             if (source.typeParameters && source.typeParameters !== target.typeParameters) {
40367                 target = getCanonicalSignature(target);
40368                 source = instantiateSignatureInContextOf(source, target, undefined, compareTypes);
40369             }
40370             var sourceCount = getParameterCount(source);
40371             var sourceRestType = getNonArrayRestType(source);
40372             var targetRestType = getNonArrayRestType(target);
40373             if (sourceRestType || targetRestType) {
40374                 void instantiateType(sourceRestType || targetRestType, reportUnreliableMarkers);
40375             }
40376             if (sourceRestType && targetRestType && sourceCount !== targetCount) {
40377                 return 0;
40378             }
40379             var kind = target.declaration ? target.declaration.kind : 0;
40380             var strictVariance = !(checkMode & 3) && strictFunctionTypes && kind !== 161 &&
40381                 kind !== 160 && kind !== 162;
40382             var result = -1;
40383             var sourceThisType = getThisTypeOfSignature(source);
40384             if (sourceThisType && sourceThisType !== voidType) {
40385                 var targetThisType = getThisTypeOfSignature(target);
40386                 if (targetThisType) {
40387                     var related = !strictVariance && compareTypes(sourceThisType, targetThisType, false)
40388                         || compareTypes(targetThisType, sourceThisType, reportErrors);
40389                     if (!related) {
40390                         if (reportErrors) {
40391                             errorReporter(ts.Diagnostics.The_this_types_of_each_signature_are_incompatible);
40392                         }
40393                         return 0;
40394                     }
40395                     result &= related;
40396                 }
40397             }
40398             var paramCount = sourceRestType || targetRestType ? Math.min(sourceCount, targetCount) : Math.max(sourceCount, targetCount);
40399             var restIndex = sourceRestType || targetRestType ? paramCount - 1 : -1;
40400             for (var i = 0; i < paramCount; i++) {
40401                 var sourceType = i === restIndex ? getRestTypeAtPosition(source, i) : getTypeAtPosition(source, i);
40402                 var targetType = i === restIndex ? getRestTypeAtPosition(target, i) : getTypeAtPosition(target, i);
40403                 var sourceSig = checkMode & 3 ? undefined : getSingleCallSignature(getNonNullableType(sourceType));
40404                 var targetSig = checkMode & 3 ? undefined : getSingleCallSignature(getNonNullableType(targetType));
40405                 var callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) &&
40406                     (getFalsyFlags(sourceType) & 98304) === (getFalsyFlags(targetType) & 98304);
40407                 var related = callbacks ?
40408                     compareSignaturesRelated(targetSig, sourceSig, (checkMode & 8) | (strictVariance ? 2 : 1), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) :
40409                     !(checkMode & 3) && !strictVariance && compareTypes(sourceType, targetType, false) || compareTypes(targetType, sourceType, reportErrors);
40410                 if (related && checkMode & 8 && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(sourceType, targetType, false)) {
40411                     related = 0;
40412                 }
40413                 if (!related) {
40414                     if (reportErrors) {
40415                         errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.unescapeLeadingUnderscores(getParameterNameAtPosition(source, i)), ts.unescapeLeadingUnderscores(getParameterNameAtPosition(target, i)));
40416                     }
40417                     return 0;
40418                 }
40419                 result &= related;
40420             }
40421             if (!(checkMode & 4)) {
40422                 var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType
40423                     : target.declaration && isJSConstructor(target.declaration) ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(target.declaration.symbol))
40424                         : getReturnTypeOfSignature(target);
40425                 if (targetReturnType === voidType) {
40426                     return result;
40427                 }
40428                 var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType
40429                     : source.declaration && isJSConstructor(source.declaration) ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(source.declaration.symbol))
40430                         : getReturnTypeOfSignature(source);
40431                 var targetTypePredicate = getTypePredicateOfSignature(target);
40432                 if (targetTypePredicate) {
40433                     var sourceTypePredicate = getTypePredicateOfSignature(source);
40434                     if (sourceTypePredicate) {
40435                         result &= compareTypePredicateRelatedTo(sourceTypePredicate, targetTypePredicate, reportErrors, errorReporter, compareTypes);
40436                     }
40437                     else if (ts.isIdentifierTypePredicate(targetTypePredicate)) {
40438                         if (reportErrors) {
40439                             errorReporter(ts.Diagnostics.Signature_0_must_be_a_type_predicate, signatureToString(source));
40440                         }
40441                         return 0;
40442                     }
40443                 }
40444                 else {
40445                     result &= checkMode & 1 && compareTypes(targetReturnType, sourceReturnType, false) ||
40446                         compareTypes(sourceReturnType, targetReturnType, reportErrors);
40447                     if (!result && reportErrors && incompatibleErrorReporter) {
40448                         incompatibleErrorReporter(sourceReturnType, targetReturnType);
40449                     }
40450                 }
40451             }
40452             return result;
40453         }
40454         function compareTypePredicateRelatedTo(source, target, reportErrors, errorReporter, compareTypes) {
40455             if (source.kind !== target.kind) {
40456                 if (reportErrors) {
40457                     errorReporter(ts.Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard);
40458                     errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target));
40459                 }
40460                 return 0;
40461             }
40462             if (source.kind === 1 || source.kind === 3) {
40463                 if (source.parameterIndex !== target.parameterIndex) {
40464                     if (reportErrors) {
40465                         errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, source.parameterName, target.parameterName);
40466                         errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target));
40467                     }
40468                     return 0;
40469                 }
40470             }
40471             var related = source.type === target.type ? -1 :
40472                 source.type && target.type ? compareTypes(source.type, target.type, reportErrors) :
40473                     0;
40474             if (related === 0 && reportErrors) {
40475                 errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target));
40476             }
40477             return related;
40478         }
40479         function isImplementationCompatibleWithOverload(implementation, overload) {
40480             var erasedSource = getErasedSignature(implementation);
40481             var erasedTarget = getErasedSignature(overload);
40482             var sourceReturnType = getReturnTypeOfSignature(erasedSource);
40483             var targetReturnType = getReturnTypeOfSignature(erasedTarget);
40484             if (targetReturnType === voidType
40485                 || isTypeRelatedTo(targetReturnType, sourceReturnType, assignableRelation)
40486                 || isTypeRelatedTo(sourceReturnType, targetReturnType, assignableRelation)) {
40487                 return isSignatureAssignableTo(erasedSource, erasedTarget, true);
40488             }
40489             return false;
40490         }
40491         function isEmptyResolvedType(t) {
40492             return t !== anyFunctionType &&
40493                 t.properties.length === 0 &&
40494                 t.callSignatures.length === 0 &&
40495                 t.constructSignatures.length === 0 &&
40496                 !t.stringIndexInfo &&
40497                 !t.numberIndexInfo;
40498         }
40499         function isEmptyObjectType(type) {
40500             return type.flags & 524288 ? !isGenericMappedType(type) && isEmptyResolvedType(resolveStructuredTypeMembers(type)) :
40501                 type.flags & 67108864 ? true :
40502                     type.flags & 1048576 ? ts.some(type.types, isEmptyObjectType) :
40503                         type.flags & 2097152 ? ts.every(type.types, isEmptyObjectType) :
40504                             false;
40505         }
40506         function isEmptyAnonymousObjectType(type) {
40507             return !!(ts.getObjectFlags(type) & 16) && isEmptyObjectType(type);
40508         }
40509         function isStringIndexSignatureOnlyType(type) {
40510             return type.flags & 524288 && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfoOfType(type, 0) && !getIndexInfoOfType(type, 1) ||
40511                 type.flags & 3145728 && ts.every(type.types, isStringIndexSignatureOnlyType) ||
40512                 false;
40513         }
40514         function isEnumTypeRelatedTo(sourceSymbol, targetSymbol, errorReporter) {
40515             if (sourceSymbol === targetSymbol) {
40516                 return true;
40517             }
40518             var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol);
40519             var entry = enumRelation.get(id);
40520             if (entry !== undefined && !(!(entry & 4) && entry & 2 && errorReporter)) {
40521                 return !!(entry & 1);
40522             }
40523             if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256) || !(targetSymbol.flags & 256)) {
40524                 enumRelation.set(id, 2 | 4);
40525                 return false;
40526             }
40527             var targetEnumType = getTypeOfSymbol(targetSymbol);
40528             for (var _i = 0, _a = getPropertiesOfType(getTypeOfSymbol(sourceSymbol)); _i < _a.length; _i++) {
40529                 var property = _a[_i];
40530                 if (property.flags & 8) {
40531                     var targetProperty = getPropertyOfType(targetEnumType, property.escapedName);
40532                     if (!targetProperty || !(targetProperty.flags & 8)) {
40533                         if (errorReporter) {
40534                             errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), undefined, 64));
40535                             enumRelation.set(id, 2 | 4);
40536                         }
40537                         else {
40538                             enumRelation.set(id, 2);
40539                         }
40540                         return false;
40541                     }
40542                 }
40543             }
40544             enumRelation.set(id, 1);
40545             return true;
40546         }
40547         function isSimpleTypeRelatedTo(source, target, relation, errorReporter) {
40548             var s = source.flags;
40549             var t = target.flags;
40550             if (t & 3 || s & 131072 || source === wildcardType)
40551                 return true;
40552             if (t & 131072)
40553                 return false;
40554             if (s & 132 && t & 4)
40555                 return true;
40556             if (s & 128 && s & 1024 &&
40557                 t & 128 && !(t & 1024) &&
40558                 source.value === target.value)
40559                 return true;
40560             if (s & 296 && t & 8)
40561                 return true;
40562             if (s & 256 && s & 1024 &&
40563                 t & 256 && !(t & 1024) &&
40564                 source.value === target.value)
40565                 return true;
40566             if (s & 2112 && t & 64)
40567                 return true;
40568             if (s & 528 && t & 16)
40569                 return true;
40570             if (s & 12288 && t & 4096)
40571                 return true;
40572             if (s & 32 && t & 32 && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter))
40573                 return true;
40574             if (s & 1024 && t & 1024) {
40575                 if (s & 1048576 && t & 1048576 && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter))
40576                     return true;
40577                 if (s & 2944 && t & 2944 &&
40578                     source.value === target.value &&
40579                     isEnumTypeRelatedTo(getParentOfSymbol(source.symbol), getParentOfSymbol(target.symbol), errorReporter))
40580                     return true;
40581             }
40582             if (s & 32768 && (!strictNullChecks || t & (32768 | 16384)))
40583                 return true;
40584             if (s & 65536 && (!strictNullChecks || t & 65536))
40585                 return true;
40586             if (s & 524288 && t & 67108864)
40587                 return true;
40588             if (relation === assignableRelation || relation === comparableRelation) {
40589                 if (s & 1)
40590                     return true;
40591                 if (s & (8 | 256) && !(s & 1024) && (t & 32 || t & 256 && t & 1024))
40592                     return true;
40593             }
40594             return false;
40595         }
40596         function isTypeRelatedTo(source, target, relation) {
40597             if (isFreshLiteralType(source)) {
40598                 source = source.regularType;
40599             }
40600             if (isFreshLiteralType(target)) {
40601                 target = target.regularType;
40602             }
40603             if (source === target) {
40604                 return true;
40605             }
40606             if (relation !== identityRelation) {
40607                 if (relation === comparableRelation && !(target.flags & 131072) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation)) {
40608                     return true;
40609                 }
40610             }
40611             else {
40612                 if (!(source.flags & 3145728) && !(target.flags & 3145728) &&
40613                     source.flags !== target.flags && !(source.flags & 66584576))
40614                     return false;
40615             }
40616             if (source.flags & 524288 && target.flags & 524288) {
40617                 var related = relation.get(getRelationKey(source, target, 0, relation));
40618                 if (related !== undefined) {
40619                     return !!(related & 1);
40620                 }
40621             }
40622             if (source.flags & 66846720 || target.flags & 66846720) {
40623                 return checkTypeRelatedTo(source, target, relation, undefined);
40624             }
40625             return false;
40626         }
40627         function isIgnoredJsxProperty(source, sourceProp) {
40628             return ts.getObjectFlags(source) & 4096 && !isUnhyphenatedJsxName(sourceProp.escapedName);
40629         }
40630         function getNormalizedType(type, writing) {
40631             while (true) {
40632                 var t = isFreshLiteralType(type) ? type.regularType :
40633                     ts.getObjectFlags(type) & 4 && type.node ? createTypeReference(type.target, getTypeArguments(type)) :
40634                         type.flags & 3145728 ? getReducedType(type) :
40635                             type.flags & 33554432 ? writing ? type.baseType : type.substitute :
40636                                 type.flags & 25165824 ? getSimplifiedType(type, writing) :
40637                                     type;
40638                 if (t === type)
40639                     break;
40640                 type = t;
40641             }
40642             return type;
40643         }
40644         function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer) {
40645             var errorInfo;
40646             var relatedInfo;
40647             var maybeKeys;
40648             var sourceStack;
40649             var targetStack;
40650             var maybeCount = 0;
40651             var depth = 0;
40652             var expandingFlags = 0;
40653             var overflow = false;
40654             var overrideNextErrorInfo = 0;
40655             var lastSkippedInfo;
40656             var incompatibleStack = [];
40657             var inPropertyCheck = false;
40658             ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking");
40659             var result = isRelatedTo(source, target, !!errorNode, headMessage);
40660             if (incompatibleStack.length) {
40661                 reportIncompatibleStack();
40662             }
40663             if (overflow) {
40664                 var diag = error(errorNode || currentNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target));
40665                 if (errorOutputContainer) {
40666                     (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
40667                 }
40668             }
40669             else if (errorInfo) {
40670                 if (containingMessageChain) {
40671                     var chain = containingMessageChain();
40672                     if (chain) {
40673                         ts.concatenateDiagnosticMessageChains(chain, errorInfo);
40674                         errorInfo = chain;
40675                     }
40676                 }
40677                 var relatedInformation = void 0;
40678                 if (headMessage && errorNode && !result && source.symbol) {
40679                     var links = getSymbolLinks(source.symbol);
40680                     if (links.originatingImport && !ts.isImportCall(links.originatingImport)) {
40681                         var helpfulRetry = checkTypeRelatedTo(getTypeOfSymbol(links.target), target, relation, undefined);
40682                         if (helpfulRetry) {
40683                             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);
40684                             relatedInformation = ts.append(relatedInformation, diag_1);
40685                         }
40686                     }
40687                 }
40688                 var diag = ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation);
40689                 if (relatedInfo) {
40690                     ts.addRelatedInfo.apply(void 0, __spreadArrays([diag], relatedInfo));
40691                 }
40692                 if (errorOutputContainer) {
40693                     (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
40694                 }
40695                 if (!errorOutputContainer || !errorOutputContainer.skipLogging) {
40696                     diagnostics.add(diag);
40697                 }
40698             }
40699             if (errorNode && errorOutputContainer && errorOutputContainer.skipLogging && result === 0) {
40700                 ts.Debug.assert(!!errorOutputContainer.errors, "missed opportunity to interact with error.");
40701             }
40702             return result !== 0;
40703             function resetErrorInfo(saved) {
40704                 errorInfo = saved.errorInfo;
40705                 lastSkippedInfo = saved.lastSkippedInfo;
40706                 incompatibleStack = saved.incompatibleStack;
40707                 overrideNextErrorInfo = saved.overrideNextErrorInfo;
40708                 relatedInfo = saved.relatedInfo;
40709             }
40710             function captureErrorCalculationState() {
40711                 return {
40712                     errorInfo: errorInfo,
40713                     lastSkippedInfo: lastSkippedInfo,
40714                     incompatibleStack: incompatibleStack.slice(),
40715                     overrideNextErrorInfo: overrideNextErrorInfo,
40716                     relatedInfo: !relatedInfo ? undefined : relatedInfo.slice()
40717                 };
40718             }
40719             function reportIncompatibleError(message, arg0, arg1, arg2, arg3) {
40720                 overrideNextErrorInfo++;
40721                 lastSkippedInfo = undefined;
40722                 incompatibleStack.push([message, arg0, arg1, arg2, arg3]);
40723             }
40724             function reportIncompatibleStack() {
40725                 var stack = incompatibleStack;
40726                 incompatibleStack = [];
40727                 var info = lastSkippedInfo;
40728                 lastSkippedInfo = undefined;
40729                 if (stack.length === 1) {
40730                     reportError.apply(void 0, stack[0]);
40731                     if (info) {
40732                         reportRelationError.apply(void 0, __spreadArrays([undefined], info));
40733                     }
40734                     return;
40735                 }
40736                 var path = "";
40737                 var secondaryRootErrors = [];
40738                 while (stack.length) {
40739                     var _a = stack.pop(), msg = _a[0], args = _a.slice(1);
40740                     switch (msg.code) {
40741                         case ts.Diagnostics.Types_of_property_0_are_incompatible.code: {
40742                             if (path.indexOf("new ") === 0) {
40743                                 path = "(" + path + ")";
40744                             }
40745                             var str = "" + args[0];
40746                             if (path.length === 0) {
40747                                 path = "" + str;
40748                             }
40749                             else if (ts.isIdentifierText(str, compilerOptions.target)) {
40750                                 path = path + "." + str;
40751                             }
40752                             else if (str[0] === "[" && str[str.length - 1] === "]") {
40753                                 path = "" + path + str;
40754                             }
40755                             else {
40756                                 path = path + "[" + str + "]";
40757                             }
40758                             break;
40759                         }
40760                         case ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible.code:
40761                         case ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code:
40762                         case ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code:
40763                         case ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code: {
40764                             if (path.length === 0) {
40765                                 var mappedMsg = msg;
40766                                 if (msg.code === ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) {
40767                                     mappedMsg = ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible;
40768                                 }
40769                                 else if (msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) {
40770                                     mappedMsg = ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible;
40771                                 }
40772                                 secondaryRootErrors.unshift([mappedMsg, args[0], args[1]]);
40773                             }
40774                             else {
40775                                 var prefix = (msg.code === ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code ||
40776                                     msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code)
40777                                     ? "new "
40778                                     : "";
40779                                 var params = (msg.code === ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code ||
40780                                     msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code)
40781                                     ? ""
40782                                     : "...";
40783                                 path = "" + prefix + path + "(" + params + ")";
40784                             }
40785                             break;
40786                         }
40787                         default:
40788                             return ts.Debug.fail("Unhandled Diagnostic: " + msg.code);
40789                     }
40790                 }
40791                 if (path) {
40792                     reportError(path[path.length - 1] === ")"
40793                         ? ts.Diagnostics.The_types_returned_by_0_are_incompatible_between_these_types
40794                         : ts.Diagnostics.The_types_of_0_are_incompatible_between_these_types, path);
40795                 }
40796                 else {
40797                     secondaryRootErrors.shift();
40798                 }
40799                 for (var _i = 0, secondaryRootErrors_1 = secondaryRootErrors; _i < secondaryRootErrors_1.length; _i++) {
40800                     var _b = secondaryRootErrors_1[_i], msg = _b[0], args = _b.slice(1);
40801                     var originalValue = msg.elidedInCompatabilityPyramid;
40802                     msg.elidedInCompatabilityPyramid = false;
40803                     reportError.apply(void 0, __spreadArrays([msg], args));
40804                     msg.elidedInCompatabilityPyramid = originalValue;
40805                 }
40806                 if (info) {
40807                     reportRelationError.apply(void 0, __spreadArrays([undefined], info));
40808                 }
40809             }
40810             function reportError(message, arg0, arg1, arg2, arg3) {
40811                 ts.Debug.assert(!!errorNode);
40812                 if (incompatibleStack.length)
40813                     reportIncompatibleStack();
40814                 if (message.elidedInCompatabilityPyramid)
40815                     return;
40816                 errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2, arg3);
40817             }
40818             function associateRelatedInfo(info) {
40819                 ts.Debug.assert(!!errorInfo);
40820                 if (!relatedInfo) {
40821                     relatedInfo = [info];
40822                 }
40823                 else {
40824                     relatedInfo.push(info);
40825                 }
40826             }
40827             function reportRelationError(message, source, target) {
40828                 if (incompatibleStack.length)
40829                     reportIncompatibleStack();
40830                 var _a = getTypeNamesForErrorDisplay(source, target), sourceType = _a[0], targetType = _a[1];
40831                 if (target.flags & 262144) {
40832                     var constraint = getBaseConstraintOfType(target);
40833                     var constraintElab = constraint && isTypeAssignableTo(source, constraint);
40834                     if (constraintElab) {
40835                         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));
40836                     }
40837                     else {
40838                         reportError(ts.Diagnostics._0_could_be_instantiated_with_an_arbitrary_type_which_could_be_unrelated_to_1, targetType, sourceType);
40839                     }
40840                 }
40841                 if (!message) {
40842                     if (relation === comparableRelation) {
40843                         message = ts.Diagnostics.Type_0_is_not_comparable_to_type_1;
40844                     }
40845                     else if (sourceType === targetType) {
40846                         message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated;
40847                     }
40848                     else {
40849                         message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1;
40850                     }
40851                 }
40852                 reportError(message, sourceType, targetType);
40853             }
40854             function tryElaborateErrorsForPrimitivesAndObjects(source, target) {
40855                 var sourceType = symbolValueDeclarationIsContextSensitive(source.symbol) ? typeToString(source, source.symbol.valueDeclaration) : typeToString(source);
40856                 var targetType = symbolValueDeclarationIsContextSensitive(target.symbol) ? typeToString(target, target.symbol.valueDeclaration) : typeToString(target);
40857                 if ((globalStringType === source && stringType === target) ||
40858                     (globalNumberType === source && numberType === target) ||
40859                     (globalBooleanType === source && booleanType === target) ||
40860                     (getGlobalESSymbolType(false) === source && esSymbolType === target)) {
40861                     reportError(ts.Diagnostics._0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible, targetType, sourceType);
40862                 }
40863             }
40864             function tryElaborateArrayLikeErrors(source, target, reportErrors) {
40865                 if (isTupleType(source)) {
40866                     if (source.target.readonly && isMutableArrayOrTuple(target)) {
40867                         if (reportErrors) {
40868                             reportError(ts.Diagnostics.The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1, typeToString(source), typeToString(target));
40869                         }
40870                         return false;
40871                     }
40872                     return isTupleType(target) || isArrayType(target);
40873                 }
40874                 if (isReadonlyArrayType(source) && isMutableArrayOrTuple(target)) {
40875                     if (reportErrors) {
40876                         reportError(ts.Diagnostics.The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1, typeToString(source), typeToString(target));
40877                     }
40878                     return false;
40879                 }
40880                 if (isTupleType(target)) {
40881                     return isArrayType(source);
40882                 }
40883                 return true;
40884             }
40885             function isRelatedTo(originalSource, originalTarget, reportErrors, headMessage, intersectionState) {
40886                 if (reportErrors === void 0) { reportErrors = false; }
40887                 if (intersectionState === void 0) { intersectionState = 0; }
40888                 if (originalSource.flags & 524288 && originalTarget.flags & 131068) {
40889                     if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) {
40890                         return -1;
40891                     }
40892                     reportErrorResults(originalSource, originalTarget, 0, !!(ts.getObjectFlags(originalSource) & 4096));
40893                     return 0;
40894                 }
40895                 var source = getNormalizedType(originalSource, false);
40896                 var target = getNormalizedType(originalTarget, true);
40897                 if (source === target)
40898                     return -1;
40899                 if (relation === identityRelation) {
40900                     return isIdenticalTo(source, target);
40901                 }
40902                 if (source.flags & 262144 && getConstraintOfType(source) === target) {
40903                     return -1;
40904                 }
40905                 if (target.flags & 1048576 && source.flags & 524288 &&
40906                     target.types.length <= 3 && maybeTypeOfKind(target, 98304)) {
40907                     var nullStrippedTarget = extractTypesOfKind(target, ~98304);
40908                     if (!(nullStrippedTarget.flags & (1048576 | 131072))) {
40909                         if (source === nullStrippedTarget)
40910                             return -1;
40911                         target = nullStrippedTarget;
40912                     }
40913                 }
40914                 if (relation === comparableRelation && !(target.flags & 131072) && isSimpleTypeRelatedTo(target, source, relation) ||
40915                     isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined))
40916                     return -1;
40917                 var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096);
40918                 var isPerformingExcessPropertyChecks = !(intersectionState & 2) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768);
40919                 if (isPerformingExcessPropertyChecks) {
40920                     if (hasExcessProperties(source, target, reportErrors)) {
40921                         if (reportErrors) {
40922                             reportRelationError(headMessage, source, target);
40923                         }
40924                         return 0;
40925                     }
40926                 }
40927                 var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2) &&
40928                     source.flags & (131068 | 524288 | 2097152) && source !== globalObjectType &&
40929                     target.flags & (524288 | 2097152) && isWeakType(target) &&
40930                     (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source));
40931                 if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) {
40932                     if (reportErrors) {
40933                         var calls = getSignaturesOfType(source, 0);
40934                         var constructs = getSignaturesOfType(source, 1);
40935                         if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, false) ||
40936                             constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, false)) {
40937                             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));
40938                         }
40939                         else {
40940                             reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, typeToString(source), typeToString(target));
40941                         }
40942                     }
40943                     return 0;
40944                 }
40945                 var result = 0;
40946                 var saveErrorInfo = captureErrorCalculationState();
40947                 if (source.flags & 1048576) {
40948                     result = relation === comparableRelation ?
40949                         someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068), intersectionState) :
40950                         eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068), intersectionState);
40951                 }
40952                 else {
40953                     if (target.flags & 1048576) {
40954                         result = typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068) && !(target.flags & 131068));
40955                     }
40956                     else if (target.flags & 2097152) {
40957                         result = typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2);
40958                     }
40959                     else if (source.flags & 2097152) {
40960                         result = someTypeRelatedToType(source, target, false, 1);
40961                     }
40962                     if (!result && (source.flags & 66846720 || target.flags & 66846720)) {
40963                         if (result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState)) {
40964                             resetErrorInfo(saveErrorInfo);
40965                         }
40966                     }
40967                 }
40968                 if (!result && source.flags & (2097152 | 262144)) {
40969                     var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 ? source.types : [source], !!(target.flags & 1048576));
40970                     if (constraint && (source.flags & 2097152 || target.flags & 1048576)) {
40971                         if (everyType(constraint, function (c) { return c !== source; })) {
40972                             if (result = isRelatedTo(constraint, target, false, undefined, intersectionState)) {
40973                                 resetErrorInfo(saveErrorInfo);
40974                             }
40975                         }
40976                     }
40977                 }
40978                 if (result && !inPropertyCheck && (target.flags & 2097152 && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
40979                     isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 && getApparentType(source).flags & 3670016 && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152); }))) {
40980                     inPropertyCheck = true;
40981                     result &= recursiveTypeRelatedTo(source, target, reportErrors, 4);
40982                     inPropertyCheck = false;
40983                 }
40984                 reportErrorResults(source, target, result, isComparingJsxAttributes);
40985                 return result;
40986                 function reportErrorResults(source, target, result, isComparingJsxAttributes) {
40987                     if (!result && reportErrors) {
40988                         source = originalSource.aliasSymbol ? originalSource : source;
40989                         target = originalTarget.aliasSymbol ? originalTarget : target;
40990                         var maybeSuppress = overrideNextErrorInfo > 0;
40991                         if (maybeSuppress) {
40992                             overrideNextErrorInfo--;
40993                         }
40994                         if (source.flags & 524288 && target.flags & 524288) {
40995                             var currentError = errorInfo;
40996                             tryElaborateArrayLikeErrors(source, target, reportErrors);
40997                             if (errorInfo !== currentError) {
40998                                 maybeSuppress = !!errorInfo;
40999                             }
41000                         }
41001                         if (source.flags & 524288 && target.flags & 131068) {
41002                             tryElaborateErrorsForPrimitivesAndObjects(source, target);
41003                         }
41004                         else if (source.symbol && source.flags & 524288 && globalObjectType === source) {
41005                             reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead);
41006                         }
41007                         else if (isComparingJsxAttributes && target.flags & 2097152) {
41008                             var targetTypes = target.types;
41009                             var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode);
41010                             var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode);
41011                             if (intrinsicAttributes !== errorType && intrinsicClassAttributes !== errorType &&
41012                                 (ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) {
41013                                 return result;
41014                             }
41015                         }
41016                         else {
41017                             errorInfo = elaborateNeverIntersection(errorInfo, originalTarget);
41018                         }
41019                         if (!headMessage && maybeSuppress) {
41020                             lastSkippedInfo = [source, target];
41021                             return result;
41022                         }
41023                         reportRelationError(headMessage, source, target);
41024                     }
41025                 }
41026             }
41027             function isIdenticalTo(source, target) {
41028                 var flags = source.flags & target.flags;
41029                 if (!(flags & 66584576)) {
41030                     return 0;
41031                 }
41032                 if (flags & 3145728) {
41033                     var result_5 = eachTypeRelatedToSomeType(source, target);
41034                     if (result_5) {
41035                         result_5 &= eachTypeRelatedToSomeType(target, source);
41036                     }
41037                     return result_5;
41038                 }
41039                 return recursiveTypeRelatedTo(source, target, false, 0);
41040             }
41041             function getTypeOfPropertyInTypes(types, name) {
41042                 var appendPropType = function (propTypes, type) {
41043                     type = getApparentType(type);
41044                     var prop = type.flags & 3145728 ? getPropertyOfUnionOrIntersectionType(type, name) : getPropertyOfObjectType(type, name);
41045                     var propType = prop && getTypeOfSymbol(prop) || isNumericLiteralName(name) && getIndexTypeOfType(type, 1) || getIndexTypeOfType(type, 0) || undefinedType;
41046                     return ts.append(propTypes, propType);
41047                 };
41048                 return getUnionType(ts.reduceLeft(types, appendPropType, undefined) || ts.emptyArray);
41049             }
41050             function hasExcessProperties(source, target, reportErrors) {
41051                 if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 16384) {
41052                     return false;
41053                 }
41054                 var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096);
41055                 if ((relation === assignableRelation || relation === comparableRelation) &&
41056                     (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) {
41057                     return false;
41058                 }
41059                 var reducedTarget = target;
41060                 var checkTypes;
41061                 if (target.flags & 1048576) {
41062                     reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target);
41063                     checkTypes = reducedTarget.flags & 1048576 ? reducedTarget.types : [reducedTarget];
41064                 }
41065                 var _loop_13 = function (prop) {
41066                     if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) {
41067                         if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) {
41068                             if (reportErrors) {
41069                                 var errorTarget = filterType(reducedTarget, isExcessPropertyCheckTarget);
41070                                 if (!errorNode)
41071                                     return { value: ts.Debug.fail() };
41072                                 if (ts.isJsxAttributes(errorNode) || ts.isJsxOpeningLikeElement(errorNode) || ts.isJsxOpeningLikeElement(errorNode.parent)) {
41073                                     if (prop.valueDeclaration && ts.isJsxAttribute(prop.valueDeclaration) && ts.getSourceFileOfNode(errorNode) === ts.getSourceFileOfNode(prop.valueDeclaration.name)) {
41074                                         errorNode = prop.valueDeclaration.name;
41075                                     }
41076                                     reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(errorTarget));
41077                                 }
41078                                 else {
41079                                     var objectLiteralDeclaration_1 = source.symbol && ts.firstOrUndefined(source.symbol.declarations);
41080                                     var suggestion = void 0;
41081                                     if (prop.valueDeclaration && ts.findAncestor(prop.valueDeclaration, function (d) { return d === objectLiteralDeclaration_1; }) && ts.getSourceFileOfNode(objectLiteralDeclaration_1) === ts.getSourceFileOfNode(errorNode)) {
41082                                         var propDeclaration = prop.valueDeclaration;
41083                                         ts.Debug.assertNode(propDeclaration, ts.isObjectLiteralElementLike);
41084                                         errorNode = propDeclaration;
41085                                         var name = propDeclaration.name;
41086                                         if (ts.isIdentifier(name)) {
41087                                             suggestion = getSuggestionForNonexistentProperty(name, errorTarget);
41088                                         }
41089                                     }
41090                                     if (suggestion !== undefined) {
41091                                         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);
41092                                     }
41093                                     else {
41094                                         reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(errorTarget));
41095                                     }
41096                                 }
41097                             }
41098                             return { value: true };
41099                         }
41100                         if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), reportErrors)) {
41101                             if (reportErrors) {
41102                                 reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(prop));
41103                             }
41104                             return { value: true };
41105                         }
41106                     }
41107                 };
41108                 for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) {
41109                     var prop = _a[_i];
41110                     var state_5 = _loop_13(prop);
41111                     if (typeof state_5 === "object")
41112                         return state_5.value;
41113                 }
41114                 return false;
41115             }
41116             function shouldCheckAsExcessProperty(prop, container) {
41117                 return prop.valueDeclaration && container.valueDeclaration && prop.valueDeclaration.parent === container.valueDeclaration;
41118             }
41119             function eachTypeRelatedToSomeType(source, target) {
41120                 var result = -1;
41121                 var sourceTypes = source.types;
41122                 for (var _i = 0, sourceTypes_1 = sourceTypes; _i < sourceTypes_1.length; _i++) {
41123                     var sourceType = sourceTypes_1[_i];
41124                     var related = typeRelatedToSomeType(sourceType, target, false);
41125                     if (!related) {
41126                         return 0;
41127                     }
41128                     result &= related;
41129                 }
41130                 return result;
41131             }
41132             function typeRelatedToSomeType(source, target, reportErrors) {
41133                 var targetTypes = target.types;
41134                 if (target.flags & 1048576 && containsType(targetTypes, source)) {
41135                     return -1;
41136                 }
41137                 for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) {
41138                     var type = targetTypes_1[_i];
41139                     var related = isRelatedTo(source, type, false);
41140                     if (related) {
41141                         return related;
41142                     }
41143                 }
41144                 if (reportErrors) {
41145                     var bestMatchingType = getBestMatchingType(source, target, isRelatedTo);
41146                     isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], true);
41147                 }
41148                 return 0;
41149             }
41150             function typeRelatedToEachType(source, target, reportErrors, intersectionState) {
41151                 var result = -1;
41152                 var targetTypes = target.types;
41153                 for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) {
41154                     var targetType = targetTypes_2[_i];
41155                     var related = isRelatedTo(source, targetType, reportErrors, undefined, intersectionState);
41156                     if (!related) {
41157                         return 0;
41158                     }
41159                     result &= related;
41160                 }
41161                 return result;
41162             }
41163             function someTypeRelatedToType(source, target, reportErrors, intersectionState) {
41164                 var sourceTypes = source.types;
41165                 if (source.flags & 1048576 && containsType(sourceTypes, target)) {
41166                     return -1;
41167                 }
41168                 var len = sourceTypes.length;
41169                 for (var i = 0; i < len; i++) {
41170                     var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1, undefined, intersectionState);
41171                     if (related) {
41172                         return related;
41173                     }
41174                 }
41175                 return 0;
41176             }
41177             function eachTypeRelatedToType(source, target, reportErrors, intersectionState) {
41178                 var result = -1;
41179                 var sourceTypes = source.types;
41180                 for (var i = 0; i < sourceTypes.length; i++) {
41181                     var sourceType = sourceTypes[i];
41182                     if (target.flags & 1048576 && target.types.length === sourceTypes.length) {
41183                         var related_1 = isRelatedTo(sourceType, target.types[i], false, undefined, intersectionState);
41184                         if (related_1) {
41185                             result &= related_1;
41186                             continue;
41187                         }
41188                     }
41189                     var related = isRelatedTo(sourceType, target, reportErrors, undefined, intersectionState);
41190                     if (!related) {
41191                         return 0;
41192                     }
41193                     result &= related;
41194                 }
41195                 return result;
41196             }
41197             function typeArgumentsRelatedTo(sources, targets, variances, reportErrors, intersectionState) {
41198                 if (sources === void 0) { sources = ts.emptyArray; }
41199                 if (targets === void 0) { targets = ts.emptyArray; }
41200                 if (variances === void 0) { variances = ts.emptyArray; }
41201                 if (sources.length !== targets.length && relation === identityRelation) {
41202                     return 0;
41203                 }
41204                 var length = sources.length <= targets.length ? sources.length : targets.length;
41205                 var result = -1;
41206                 for (var i = 0; i < length; i++) {
41207                     var varianceFlags = i < variances.length ? variances[i] : 1;
41208                     var variance = varianceFlags & 7;
41209                     if (variance !== 4) {
41210                         var s = sources[i];
41211                         var t = targets[i];
41212                         var related = -1;
41213                         if (varianceFlags & 8) {
41214                             related = relation === identityRelation ? isRelatedTo(s, t, false) : compareTypesIdentical(s, t);
41215                         }
41216                         else if (variance === 1) {
41217                             related = isRelatedTo(s, t, reportErrors, undefined, intersectionState);
41218                         }
41219                         else if (variance === 2) {
41220                             related = isRelatedTo(t, s, reportErrors, undefined, intersectionState);
41221                         }
41222                         else if (variance === 3) {
41223                             related = isRelatedTo(t, s, false);
41224                             if (!related) {
41225                                 related = isRelatedTo(s, t, reportErrors, undefined, intersectionState);
41226                             }
41227                         }
41228                         else {
41229                             related = isRelatedTo(s, t, reportErrors, undefined, intersectionState);
41230                             if (related) {
41231                                 related &= isRelatedTo(t, s, reportErrors, undefined, intersectionState);
41232                             }
41233                         }
41234                         if (!related) {
41235                             return 0;
41236                         }
41237                         result &= related;
41238                     }
41239                 }
41240                 return result;
41241             }
41242             function recursiveTypeRelatedTo(source, target, reportErrors, intersectionState) {
41243                 if (overflow) {
41244                     return 0;
41245                 }
41246                 var id = getRelationKey(source, target, intersectionState | (inPropertyCheck ? 8 : 0), relation);
41247                 var entry = relation.get(id);
41248                 if (entry !== undefined) {
41249                     if (reportErrors && entry & 2 && !(entry & 4)) {
41250                     }
41251                     else {
41252                         if (outofbandVarianceMarkerHandler) {
41253                             var saved = entry & 24;
41254                             if (saved & 8) {
41255                                 instantiateType(source, makeFunctionTypeMapper(reportUnmeasurableMarkers));
41256                             }
41257                             if (saved & 16) {
41258                                 instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers));
41259                             }
41260                         }
41261                         return entry & 1 ? -1 : 0;
41262                     }
41263                 }
41264                 if (!maybeKeys) {
41265                     maybeKeys = [];
41266                     sourceStack = [];
41267                     targetStack = [];
41268                 }
41269                 else {
41270                     for (var i = 0; i < maybeCount; i++) {
41271                         if (id === maybeKeys[i]) {
41272                             return 1;
41273                         }
41274                     }
41275                     if (depth === 100) {
41276                         overflow = true;
41277                         return 0;
41278                     }
41279                 }
41280                 var maybeStart = maybeCount;
41281                 maybeKeys[maybeCount] = id;
41282                 maybeCount++;
41283                 sourceStack[depth] = source;
41284                 targetStack[depth] = target;
41285                 depth++;
41286                 var saveExpandingFlags = expandingFlags;
41287                 if (!(expandingFlags & 1) && isDeeplyNestedType(source, sourceStack, depth))
41288                     expandingFlags |= 1;
41289                 if (!(expandingFlags & 2) && isDeeplyNestedType(target, targetStack, depth))
41290                     expandingFlags |= 2;
41291                 var originalHandler;
41292                 var propagatingVarianceFlags = 0;
41293                 if (outofbandVarianceMarkerHandler) {
41294                     originalHandler = outofbandVarianceMarkerHandler;
41295                     outofbandVarianceMarkerHandler = function (onlyUnreliable) {
41296                         propagatingVarianceFlags |= onlyUnreliable ? 16 : 8;
41297                         return originalHandler(onlyUnreliable);
41298                     };
41299                 }
41300                 var result = expandingFlags !== 3 ? structuredTypeRelatedTo(source, target, reportErrors, intersectionState) : 1;
41301                 if (outofbandVarianceMarkerHandler) {
41302                     outofbandVarianceMarkerHandler = originalHandler;
41303                 }
41304                 expandingFlags = saveExpandingFlags;
41305                 depth--;
41306                 if (result) {
41307                     if (result === -1 || depth === 0) {
41308                         for (var i = maybeStart; i < maybeCount; i++) {
41309                             relation.set(maybeKeys[i], 1 | propagatingVarianceFlags);
41310                         }
41311                         maybeCount = maybeStart;
41312                     }
41313                 }
41314                 else {
41315                     relation.set(id, (reportErrors ? 4 : 0) | 2 | propagatingVarianceFlags);
41316                     maybeCount = maybeStart;
41317                 }
41318                 return result;
41319             }
41320             function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
41321                 if (intersectionState & 4) {
41322                     return propertiesRelatedTo(source, target, reportErrors, undefined, 0);
41323                 }
41324                 var flags = source.flags & target.flags;
41325                 if (relation === identityRelation && !(flags & 524288)) {
41326                     if (flags & 4194304) {
41327                         return isRelatedTo(source.type, target.type, false);
41328                     }
41329                     var result_6 = 0;
41330                     if (flags & 8388608) {
41331                         if (result_6 = isRelatedTo(source.objectType, target.objectType, false)) {
41332                             if (result_6 &= isRelatedTo(source.indexType, target.indexType, false)) {
41333                                 return result_6;
41334                             }
41335                         }
41336                     }
41337                     if (flags & 16777216) {
41338                         if (source.root.isDistributive === target.root.isDistributive) {
41339                             if (result_6 = isRelatedTo(source.checkType, target.checkType, false)) {
41340                                 if (result_6 &= isRelatedTo(source.extendsType, target.extendsType, false)) {
41341                                     if (result_6 &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), false)) {
41342                                         if (result_6 &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), false)) {
41343                                             return result_6;
41344                                         }
41345                                     }
41346                                 }
41347                             }
41348                         }
41349                     }
41350                     if (flags & 33554432) {
41351                         return isRelatedTo(source.substitute, target.substitute, false);
41352                     }
41353                     return 0;
41354                 }
41355                 var result;
41356                 var originalErrorInfo;
41357                 var varianceCheckFailed = false;
41358                 var saveErrorInfo = captureErrorCalculationState();
41359                 if (source.flags & (524288 | 16777216) && source.aliasSymbol &&
41360                     source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol &&
41361                     !(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) {
41362                     var variances = getAliasVariances(source.aliasSymbol);
41363                     if (variances === ts.emptyArray) {
41364                         return 1;
41365                     }
41366                     var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, intersectionState);
41367                     if (varianceResult !== undefined) {
41368                         return varianceResult;
41369                     }
41370                 }
41371                 if (target.flags & 262144) {
41372                     if (ts.getObjectFlags(source) & 32 && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source))) {
41373                         if (!(getMappedTypeModifiers(source) & 4)) {
41374                             var templateType = getTemplateTypeFromMappedType(source);
41375                             var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source));
41376                             if (result = isRelatedTo(templateType, indexedAccessType, reportErrors)) {
41377                                 return result;
41378                             }
41379                         }
41380                     }
41381                 }
41382                 else if (target.flags & 4194304) {
41383                     if (source.flags & 4194304) {
41384                         if (result = isRelatedTo(target.type, source.type, false)) {
41385                             return result;
41386                         }
41387                     }
41388                     var constraint = getSimplifiedTypeOrConstraint(target.type);
41389                     if (constraint) {
41390                         if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), reportErrors) === -1) {
41391                             return -1;
41392                         }
41393                     }
41394                 }
41395                 else if (target.flags & 8388608) {
41396                     if (relation !== identityRelation) {
41397                         var objectType = target.objectType;
41398                         var indexType = target.indexType;
41399                         var baseObjectType = getBaseConstraintOfType(objectType) || objectType;
41400                         var baseIndexType = getBaseConstraintOfType(indexType) || indexType;
41401                         if (!isGenericObjectType(baseObjectType) && !isGenericIndexType(baseIndexType)) {
41402                             var accessFlags = 2 | (baseObjectType !== objectType ? 1 : 0);
41403                             var constraint = getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, undefined, accessFlags);
41404                             if (constraint && (result = isRelatedTo(source, constraint, reportErrors))) {
41405                                 return result;
41406                             }
41407                         }
41408                     }
41409                 }
41410                 else if (isGenericMappedType(target)) {
41411                     var template = getTemplateTypeFromMappedType(target);
41412                     var modifiers = getMappedTypeModifiers(target);
41413                     if (!(modifiers & 8)) {
41414                         if (template.flags & 8388608 && template.objectType === source &&
41415                             template.indexType === getTypeParameterFromMappedType(target)) {
41416                             return -1;
41417                         }
41418                         if (!isGenericMappedType(source)) {
41419                             var targetConstraint = getConstraintTypeFromMappedType(target);
41420                             var sourceKeys = getIndexType(source, undefined, true);
41421                             var includeOptional = modifiers & 4;
41422                             var filteredByApplicability = includeOptional ? intersectTypes(targetConstraint, sourceKeys) : undefined;
41423                             if (includeOptional
41424                                 ? !(filteredByApplicability.flags & 131072)
41425                                 : isRelatedTo(targetConstraint, sourceKeys)) {
41426                                 var typeParameter = getTypeParameterFromMappedType(target);
41427                                 var indexingType = filteredByApplicability ? getIntersectionType([filteredByApplicability, typeParameter]) : typeParameter;
41428                                 var indexedAccessType = getIndexedAccessType(source, indexingType);
41429                                 var templateType = getTemplateTypeFromMappedType(target);
41430                                 if (result = isRelatedTo(indexedAccessType, templateType, reportErrors)) {
41431                                     return result;
41432                                 }
41433                             }
41434                             originalErrorInfo = errorInfo;
41435                             resetErrorInfo(saveErrorInfo);
41436                         }
41437                     }
41438                 }
41439                 if (source.flags & 8650752) {
41440                     if (source.flags & 8388608 && target.flags & 8388608) {
41441                         if (result = isRelatedTo(source.objectType, target.objectType, reportErrors)) {
41442                             result &= isRelatedTo(source.indexType, target.indexType, reportErrors);
41443                         }
41444                         if (result) {
41445                             resetErrorInfo(saveErrorInfo);
41446                             return result;
41447                         }
41448                     }
41449                     else {
41450                         var constraint = getConstraintOfType(source);
41451                         if (!constraint || (source.flags & 262144 && constraint.flags & 1)) {
41452                             if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864))) {
41453                                 resetErrorInfo(saveErrorInfo);
41454                                 return result;
41455                             }
41456                         }
41457                         else if (result = isRelatedTo(constraint, target, false, undefined, intersectionState)) {
41458                             resetErrorInfo(saveErrorInfo);
41459                             return result;
41460                         }
41461                         else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, reportErrors, undefined, intersectionState)) {
41462                             resetErrorInfo(saveErrorInfo);
41463                             return result;
41464                         }
41465                     }
41466                 }
41467                 else if (source.flags & 4194304) {
41468                     if (result = isRelatedTo(keyofConstraintType, target, reportErrors)) {
41469                         resetErrorInfo(saveErrorInfo);
41470                         return result;
41471                     }
41472                 }
41473                 else if (source.flags & 16777216) {
41474                     if (target.flags & 16777216) {
41475                         var sourceParams = source.root.inferTypeParameters;
41476                         var sourceExtends = source.extendsType;
41477                         var mapper = void 0;
41478                         if (sourceParams) {
41479                             var ctx = createInferenceContext(sourceParams, undefined, 0, isRelatedTo);
41480                             inferTypes(ctx.inferences, target.extendsType, sourceExtends, 128 | 256);
41481                             sourceExtends = instantiateType(sourceExtends, ctx.mapper);
41482                             mapper = ctx.mapper;
41483                         }
41484                         if (isTypeIdenticalTo(sourceExtends, target.extendsType) &&
41485                             (isRelatedTo(source.checkType, target.checkType) || isRelatedTo(target.checkType, source.checkType))) {
41486                             if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), reportErrors)) {
41487                                 result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), reportErrors);
41488                             }
41489                             if (result) {
41490                                 resetErrorInfo(saveErrorInfo);
41491                                 return result;
41492                             }
41493                         }
41494                     }
41495                     else {
41496                         var distributiveConstraint = getConstraintOfDistributiveConditionalType(source);
41497                         if (distributiveConstraint) {
41498                             if (result = isRelatedTo(distributiveConstraint, target, reportErrors)) {
41499                                 resetErrorInfo(saveErrorInfo);
41500                                 return result;
41501                             }
41502                         }
41503                     }
41504                     var defaultConstraint = getDefaultConstraintOfConditionalType(source);
41505                     if (defaultConstraint) {
41506                         if (result = isRelatedTo(defaultConstraint, target, reportErrors)) {
41507                             resetErrorInfo(saveErrorInfo);
41508                             return result;
41509                         }
41510                     }
41511                 }
41512                 else {
41513                     if (relation !== subtypeRelation && relation !== strictSubtypeRelation && isPartialMappedType(target) && isEmptyObjectType(source)) {
41514                         return -1;
41515                     }
41516                     if (isGenericMappedType(target)) {
41517                         if (isGenericMappedType(source)) {
41518                             if (result = mappedTypeRelatedTo(source, target, reportErrors)) {
41519                                 resetErrorInfo(saveErrorInfo);
41520                                 return result;
41521                             }
41522                         }
41523                         return 0;
41524                     }
41525                     var sourceIsPrimitive = !!(source.flags & 131068);
41526                     if (relation !== identityRelation) {
41527                         source = getApparentType(source);
41528                     }
41529                     else if (isGenericMappedType(source)) {
41530                         return 0;
41531                     }
41532                     if (ts.getObjectFlags(source) & 4 && ts.getObjectFlags(target) & 4 && source.target === target.target &&
41533                         !(ts.getObjectFlags(source) & 8192 || ts.getObjectFlags(target) & 8192)) {
41534                         var variances = getVariances(source.target);
41535                         if (variances === ts.emptyArray) {
41536                             return 1;
41537                         }
41538                         var varianceResult = relateVariances(getTypeArguments(source), getTypeArguments(target), variances, intersectionState);
41539                         if (varianceResult !== undefined) {
41540                             return varianceResult;
41541                         }
41542                     }
41543                     else if (isReadonlyArrayType(target) ? isArrayType(source) || isTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) {
41544                         if (relation !== identityRelation) {
41545                             return isRelatedTo(getIndexTypeOfType(source, 1) || anyType, getIndexTypeOfType(target, 1) || anyType, reportErrors);
41546                         }
41547                         else {
41548                             return 0;
41549                         }
41550                     }
41551                     else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 32768 && !isEmptyObjectType(source)) {
41552                         return 0;
41553                     }
41554                     if (source.flags & (524288 | 2097152) && target.flags & 524288) {
41555                         var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive;
41556                         result = propertiesRelatedTo(source, target, reportStructuralErrors, undefined, intersectionState);
41557                         if (result) {
41558                             result &= signaturesRelatedTo(source, target, 0, reportStructuralErrors);
41559                             if (result) {
41560                                 result &= signaturesRelatedTo(source, target, 1, reportStructuralErrors);
41561                                 if (result) {
41562                                     result &= indexTypesRelatedTo(source, target, 0, sourceIsPrimitive, reportStructuralErrors, intersectionState);
41563                                     if (result) {
41564                                         result &= indexTypesRelatedTo(source, target, 1, sourceIsPrimitive, reportStructuralErrors, intersectionState);
41565                                     }
41566                                 }
41567                             }
41568                         }
41569                         if (varianceCheckFailed && result) {
41570                             errorInfo = originalErrorInfo || errorInfo || saveErrorInfo.errorInfo;
41571                         }
41572                         else if (result) {
41573                             return result;
41574                         }
41575                     }
41576                     if (source.flags & (524288 | 2097152) && target.flags & 1048576) {
41577                         var objectOnlyTarget = extractTypesOfKind(target, 524288 | 2097152 | 33554432);
41578                         if (objectOnlyTarget.flags & 1048576) {
41579                             var result_7 = typeRelatedToDiscriminatedType(source, objectOnlyTarget);
41580                             if (result_7) {
41581                                 return result_7;
41582                             }
41583                         }
41584                     }
41585                 }
41586                 return 0;
41587                 function relateVariances(sourceTypeArguments, targetTypeArguments, variances, intersectionState) {
41588                     if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, intersectionState)) {
41589                         return result;
41590                     }
41591                     if (ts.some(variances, function (v) { return !!(v & 24); })) {
41592                         originalErrorInfo = undefined;
41593                         resetErrorInfo(saveErrorInfo);
41594                         return undefined;
41595                     }
41596                     var allowStructuralFallback = targetTypeArguments && hasCovariantVoidArgument(targetTypeArguments, variances);
41597                     varianceCheckFailed = !allowStructuralFallback;
41598                     if (variances !== ts.emptyArray && !allowStructuralFallback) {
41599                         if (varianceCheckFailed && !(reportErrors && ts.some(variances, function (v) { return (v & 7) === 0; }))) {
41600                             return 0;
41601                         }
41602                         originalErrorInfo = errorInfo;
41603                         resetErrorInfo(saveErrorInfo);
41604                     }
41605                 }
41606             }
41607             function reportUnmeasurableMarkers(p) {
41608                 if (outofbandVarianceMarkerHandler && (p === markerSuperType || p === markerSubType || p === markerOtherType)) {
41609                     outofbandVarianceMarkerHandler(false);
41610                 }
41611                 return p;
41612             }
41613             function reportUnreliableMarkers(p) {
41614                 if (outofbandVarianceMarkerHandler && (p === markerSuperType || p === markerSubType || p === markerOtherType)) {
41615                     outofbandVarianceMarkerHandler(true);
41616                 }
41617                 return p;
41618             }
41619             function mappedTypeRelatedTo(source, target, reportErrors) {
41620                 var modifiersRelated = relation === comparableRelation || (relation === identityRelation ? getMappedTypeModifiers(source) === getMappedTypeModifiers(target) :
41621                     getCombinedMappedTypeOptionality(source) <= getCombinedMappedTypeOptionality(target));
41622                 if (modifiersRelated) {
41623                     var result_8;
41624                     var targetConstraint = getConstraintTypeFromMappedType(target);
41625                     var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers));
41626                     if (result_8 = isRelatedTo(targetConstraint, sourceConstraint, reportErrors)) {
41627                         var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]);
41628                         return result_8 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), reportErrors);
41629                     }
41630                 }
41631                 return 0;
41632             }
41633             function typeRelatedToDiscriminatedType(source, target) {
41634                 var sourceProperties = getPropertiesOfType(source);
41635                 var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target);
41636                 if (!sourcePropertiesFiltered)
41637                     return 0;
41638                 var numCombinations = 1;
41639                 for (var _i = 0, sourcePropertiesFiltered_1 = sourcePropertiesFiltered; _i < sourcePropertiesFiltered_1.length; _i++) {
41640                     var sourceProperty = sourcePropertiesFiltered_1[_i];
41641                     numCombinations *= countTypes(getTypeOfSymbol(sourceProperty));
41642                     if (numCombinations > 25) {
41643                         return 0;
41644                     }
41645                 }
41646                 var sourceDiscriminantTypes = new Array(sourcePropertiesFiltered.length);
41647                 var excludedProperties = ts.createUnderscoreEscapedMap();
41648                 for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
41649                     var sourceProperty = sourcePropertiesFiltered[i];
41650                     var sourcePropertyType = getTypeOfSymbol(sourceProperty);
41651                     sourceDiscriminantTypes[i] = sourcePropertyType.flags & 1048576
41652                         ? sourcePropertyType.types
41653                         : [sourcePropertyType];
41654                     excludedProperties.set(sourceProperty.escapedName, true);
41655                 }
41656                 var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes);
41657                 var matchingTypes = [];
41658                 var _loop_14 = function (combination) {
41659                     var hasMatch = false;
41660                     outer: for (var _i = 0, _a = target.types; _i < _a.length; _i++) {
41661                         var type = _a[_i];
41662                         var _loop_15 = function (i) {
41663                             var sourceProperty = sourcePropertiesFiltered[i];
41664                             var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
41665                             if (!targetProperty)
41666                                 return "continue-outer";
41667                             if (sourceProperty === targetProperty)
41668                                 return "continue";
41669                             var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, false, 0, strictNullChecks || relation === comparableRelation);
41670                             if (!related) {
41671                                 return "continue-outer";
41672                             }
41673                         };
41674                         for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
41675                             var state_7 = _loop_15(i);
41676                             switch (state_7) {
41677                                 case "continue-outer": continue outer;
41678                             }
41679                         }
41680                         ts.pushIfUnique(matchingTypes, type, ts.equateValues);
41681                         hasMatch = true;
41682                     }
41683                     if (!hasMatch) {
41684                         return { value: 0 };
41685                     }
41686                 };
41687                 for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) {
41688                     var combination = discriminantCombinations_1[_a];
41689                     var state_6 = _loop_14(combination);
41690                     if (typeof state_6 === "object")
41691                         return state_6.value;
41692                 }
41693                 var result = -1;
41694                 for (var _b = 0, matchingTypes_1 = matchingTypes; _b < matchingTypes_1.length; _b++) {
41695                     var type = matchingTypes_1[_b];
41696                     result &= propertiesRelatedTo(source, type, false, excludedProperties, 0);
41697                     if (result) {
41698                         result &= signaturesRelatedTo(source, type, 0, false);
41699                         if (result) {
41700                             result &= signaturesRelatedTo(source, type, 1, false);
41701                             if (result) {
41702                                 result &= indexTypesRelatedTo(source, type, 0, false, false, 0);
41703                                 if (result) {
41704                                     result &= indexTypesRelatedTo(source, type, 1, false, false, 0);
41705                                 }
41706                             }
41707                         }
41708                     }
41709                     if (!result) {
41710                         return result;
41711                     }
41712                 }
41713                 return result;
41714             }
41715             function excludeProperties(properties, excludedProperties) {
41716                 if (!excludedProperties || properties.length === 0)
41717                     return properties;
41718                 var result;
41719                 for (var i = 0; i < properties.length; i++) {
41720                     if (!excludedProperties.has(properties[i].escapedName)) {
41721                         if (result) {
41722                             result.push(properties[i]);
41723                         }
41724                     }
41725                     else if (!result) {
41726                         result = properties.slice(0, i);
41727                     }
41728                 }
41729                 return result || properties;
41730             }
41731             function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState) {
41732                 var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48);
41733                 var source = getTypeOfSourceProperty(sourceProp);
41734                 if (ts.getCheckFlags(targetProp) & 65536 && !getSymbolLinks(targetProp).type) {
41735                     var links = getSymbolLinks(targetProp);
41736                     ts.Debug.assertIsDefined(links.deferralParent);
41737                     ts.Debug.assertIsDefined(links.deferralConstituents);
41738                     var unionParent = !!(links.deferralParent.flags & 1048576);
41739                     var result_9 = unionParent ? 0 : -1;
41740                     var targetTypes = links.deferralConstituents;
41741                     for (var _i = 0, targetTypes_3 = targetTypes; _i < targetTypes_3.length; _i++) {
41742                         var targetType = targetTypes_3[_i];
41743                         var related = isRelatedTo(source, targetType, false, undefined, unionParent ? 0 : 2);
41744                         if (!unionParent) {
41745                             if (!related) {
41746                                 return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors);
41747                             }
41748                             result_9 &= related;
41749                         }
41750                         else {
41751                             if (related) {
41752                                 return related;
41753                             }
41754                         }
41755                     }
41756                     if (unionParent && !result_9 && targetIsOptional) {
41757                         result_9 = isRelatedTo(source, undefinedType);
41758                     }
41759                     if (unionParent && !result_9 && reportErrors) {
41760                         return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors);
41761                     }
41762                     return result_9;
41763                 }
41764                 else {
41765                     return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors, undefined, intersectionState);
41766                 }
41767             }
41768             function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) {
41769                 var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp);
41770                 var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp);
41771                 if (sourcePropFlags & 8 || targetPropFlags & 8) {
41772                     if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) {
41773                         if (reportErrors) {
41774                             if (sourcePropFlags & 8 && targetPropFlags & 8) {
41775                                 reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp));
41776                             }
41777                             else {
41778                                 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));
41779                             }
41780                         }
41781                         return 0;
41782                     }
41783                 }
41784                 else if (targetPropFlags & 16) {
41785                     if (!isValidOverrideOf(sourceProp, targetProp)) {
41786                         if (reportErrors) {
41787                             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));
41788                         }
41789                         return 0;
41790                     }
41791                 }
41792                 else if (sourcePropFlags & 16) {
41793                     if (reportErrors) {
41794                         reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target));
41795                     }
41796                     return 0;
41797                 }
41798                 var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState);
41799                 if (!related) {
41800                     if (reportErrors) {
41801                         reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp));
41802                     }
41803                     return 0;
41804                 }
41805                 if (!skipOptional && sourceProp.flags & 16777216 && !(targetProp.flags & 16777216)) {
41806                     if (reportErrors) {
41807                         reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target));
41808                     }
41809                     return 0;
41810                 }
41811                 return related;
41812             }
41813             function reportUnmatchedProperty(source, target, unmatchedProperty, requireOptionalProperties) {
41814                 var shouldSkipElaboration = false;
41815                 if (unmatchedProperty.valueDeclaration
41816                     && ts.isNamedDeclaration(unmatchedProperty.valueDeclaration)
41817                     && ts.isPrivateIdentifier(unmatchedProperty.valueDeclaration.name)
41818                     && source.symbol
41819                     && source.symbol.flags & 32) {
41820                     var privateIdentifierDescription = unmatchedProperty.valueDeclaration.name.escapedText;
41821                     var symbolTableKey = ts.getSymbolNameForPrivateIdentifier(source.symbol, privateIdentifierDescription);
41822                     if (symbolTableKey && getPropertyOfType(source, symbolTableKey)) {
41823                         var sourceName = ts.getDeclarationName(source.symbol.valueDeclaration);
41824                         var targetName = ts.getDeclarationName(target.symbol.valueDeclaration);
41825                         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));
41826                         return;
41827                     }
41828                 }
41829                 var props = ts.arrayFrom(getUnmatchedProperties(source, target, requireOptionalProperties, false));
41830                 if (!headMessage || (headMessage.code !== ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code &&
41831                     headMessage.code !== ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code)) {
41832                     shouldSkipElaboration = true;
41833                 }
41834                 if (props.length === 1) {
41835                     var propName = symbolToString(unmatchedProperty);
41836                     reportError.apply(void 0, __spreadArrays([ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName], getTypeNamesForErrorDisplay(source, target)));
41837                     if (ts.length(unmatchedProperty.declarations)) {
41838                         associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here, propName));
41839                     }
41840                     if (shouldSkipElaboration && errorInfo) {
41841                         overrideNextErrorInfo++;
41842                     }
41843                 }
41844                 else if (tryElaborateArrayLikeErrors(source, target, false)) {
41845                     if (props.length > 5) {
41846                         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);
41847                     }
41848                     else {
41849                         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(", "));
41850                     }
41851                     if (shouldSkipElaboration && errorInfo) {
41852                         overrideNextErrorInfo++;
41853                     }
41854                 }
41855             }
41856             function propertiesRelatedTo(source, target, reportErrors, excludedProperties, intersectionState) {
41857                 if (relation === identityRelation) {
41858                     return propertiesIdenticalTo(source, target, excludedProperties);
41859                 }
41860                 var requireOptionalProperties = (relation === subtypeRelation || relation === strictSubtypeRelation) && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source) && !isTupleType(source);
41861                 var unmatchedProperty = getUnmatchedProperty(source, target, requireOptionalProperties, false);
41862                 if (unmatchedProperty) {
41863                     if (reportErrors) {
41864                         reportUnmatchedProperty(source, target, unmatchedProperty, requireOptionalProperties);
41865                     }
41866                     return 0;
41867                 }
41868                 if (isObjectLiteralType(target)) {
41869                     for (var _i = 0, _a = excludeProperties(getPropertiesOfType(source), excludedProperties); _i < _a.length; _i++) {
41870                         var sourceProp = _a[_i];
41871                         if (!getPropertyOfObjectType(target, sourceProp.escapedName)) {
41872                             var sourceType = getTypeOfSymbol(sourceProp);
41873                             if (!(sourceType === undefinedType || sourceType === undefinedWideningType || sourceType === optionalType)) {
41874                                 if (reportErrors) {
41875                                     reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target));
41876                                 }
41877                                 return 0;
41878                             }
41879                         }
41880                     }
41881                 }
41882                 var result = -1;
41883                 if (isTupleType(target)) {
41884                     var targetRestType = getRestTypeOfTupleType(target);
41885                     if (targetRestType) {
41886                         if (!isTupleType(source)) {
41887                             return 0;
41888                         }
41889                         var sourceRestType = getRestTypeOfTupleType(source);
41890                         if (sourceRestType && !isRelatedTo(sourceRestType, targetRestType, reportErrors)) {
41891                             if (reportErrors) {
41892                                 reportError(ts.Diagnostics.Rest_signatures_are_incompatible);
41893                             }
41894                             return 0;
41895                         }
41896                         var targetCount = getTypeReferenceArity(target) - 1;
41897                         var sourceCount = getTypeReferenceArity(source) - (sourceRestType ? 1 : 0);
41898                         var sourceTypeArguments = getTypeArguments(source);
41899                         for (var i = targetCount; i < sourceCount; i++) {
41900                             var related = isRelatedTo(sourceTypeArguments[i], targetRestType, reportErrors);
41901                             if (!related) {
41902                                 if (reportErrors) {
41903                                     reportError(ts.Diagnostics.Property_0_is_incompatible_with_rest_element_type, "" + i);
41904                                 }
41905                                 return 0;
41906                             }
41907                             result &= related;
41908                         }
41909                     }
41910                 }
41911                 var properties = getPropertiesOfType(target);
41912                 var numericNamesOnly = isTupleType(source) && isTupleType(target);
41913                 for (var _b = 0, _c = excludeProperties(properties, excludedProperties); _b < _c.length; _b++) {
41914                     var targetProp = _c[_b];
41915                     var name = targetProp.escapedName;
41916                     if (!(targetProp.flags & 4194304) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) {
41917                         var sourceProp = getPropertyOfType(source, name);
41918                         if (sourceProp && sourceProp !== targetProp) {
41919                             var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation);
41920                             if (!related) {
41921                                 return 0;
41922                             }
41923                             result &= related;
41924                         }
41925                     }
41926                 }
41927                 return result;
41928             }
41929             function propertiesIdenticalTo(source, target, excludedProperties) {
41930                 if (!(source.flags & 524288 && target.flags & 524288)) {
41931                     return 0;
41932                 }
41933                 var sourceProperties = excludeProperties(getPropertiesOfObjectType(source), excludedProperties);
41934                 var targetProperties = excludeProperties(getPropertiesOfObjectType(target), excludedProperties);
41935                 if (sourceProperties.length !== targetProperties.length) {
41936                     return 0;
41937                 }
41938                 var result = -1;
41939                 for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) {
41940                     var sourceProp = sourceProperties_1[_i];
41941                     var targetProp = getPropertyOfObjectType(target, sourceProp.escapedName);
41942                     if (!targetProp) {
41943                         return 0;
41944                     }
41945                     var related = compareProperties(sourceProp, targetProp, isRelatedTo);
41946                     if (!related) {
41947                         return 0;
41948                     }
41949                     result &= related;
41950                 }
41951                 return result;
41952             }
41953             function signaturesRelatedTo(source, target, kind, reportErrors) {
41954                 if (relation === identityRelation) {
41955                     return signaturesIdenticalTo(source, target, kind);
41956                 }
41957                 if (target === anyFunctionType || source === anyFunctionType) {
41958                     return -1;
41959                 }
41960                 var sourceIsJSConstructor = source.symbol && isJSConstructor(source.symbol.valueDeclaration);
41961                 var targetIsJSConstructor = target.symbol && isJSConstructor(target.symbol.valueDeclaration);
41962                 var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1) ?
41963                     0 : kind);
41964                 var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1) ?
41965                     0 : kind);
41966                 if (kind === 1 && sourceSignatures.length && targetSignatures.length) {
41967                     if (ts.isAbstractConstructorType(source) && !ts.isAbstractConstructorType(target)) {
41968                         if (reportErrors) {
41969                             reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type);
41970                         }
41971                         return 0;
41972                     }
41973                     if (!constructorVisibilitiesAreCompatible(sourceSignatures[0], targetSignatures[0], reportErrors)) {
41974                         return 0;
41975                     }
41976                 }
41977                 var result = -1;
41978                 var saveErrorInfo = captureErrorCalculationState();
41979                 var incompatibleReporter = kind === 1 ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn;
41980                 if (ts.getObjectFlags(source) & 64 && ts.getObjectFlags(target) & 64 && source.symbol === target.symbol) {
41981                     for (var i = 0; i < targetSignatures.length; i++) {
41982                         var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], true, reportErrors, incompatibleReporter(sourceSignatures[i], targetSignatures[i]));
41983                         if (!related) {
41984                             return 0;
41985                         }
41986                         result &= related;
41987                     }
41988                 }
41989                 else if (sourceSignatures.length === 1 && targetSignatures.length === 1) {
41990                     var eraseGenerics = relation === comparableRelation || !!compilerOptions.noStrictGenericChecks;
41991                     result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors, incompatibleReporter(sourceSignatures[0], targetSignatures[0]));
41992                 }
41993                 else {
41994                     outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) {
41995                         var t = targetSignatures_1[_i];
41996                         var shouldElaborateErrors = reportErrors;
41997                         for (var _a = 0, sourceSignatures_1 = sourceSignatures; _a < sourceSignatures_1.length; _a++) {
41998                             var s = sourceSignatures_1[_a];
41999                             var related = signatureRelatedTo(s, t, true, shouldElaborateErrors, incompatibleReporter(s, t));
42000                             if (related) {
42001                                 result &= related;
42002                                 resetErrorInfo(saveErrorInfo);
42003                                 continue outer;
42004                             }
42005                             shouldElaborateErrors = false;
42006                         }
42007                         if (shouldElaborateErrors) {
42008                             reportError(ts.Diagnostics.Type_0_provides_no_match_for_the_signature_1, typeToString(source), signatureToString(t, undefined, undefined, kind));
42009                         }
42010                         return 0;
42011                     }
42012                 }
42013                 return result;
42014             }
42015             function reportIncompatibleCallSignatureReturn(siga, sigb) {
42016                 if (siga.parameters.length === 0 && sigb.parameters.length === 0) {
42017                     return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); };
42018                 }
42019                 return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); };
42020             }
42021             function reportIncompatibleConstructSignatureReturn(siga, sigb) {
42022                 if (siga.parameters.length === 0 && sigb.parameters.length === 0) {
42023                     return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); };
42024                 }
42025                 return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); };
42026             }
42027             function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) {
42028                 return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 : 0, reportErrors, reportError, incompatibleReporter, isRelatedTo, makeFunctionTypeMapper(reportUnreliableMarkers));
42029             }
42030             function signaturesIdenticalTo(source, target, kind) {
42031                 var sourceSignatures = getSignaturesOfType(source, kind);
42032                 var targetSignatures = getSignaturesOfType(target, kind);
42033                 if (sourceSignatures.length !== targetSignatures.length) {
42034                     return 0;
42035                 }
42036                 var result = -1;
42037                 for (var i = 0; i < sourceSignatures.length; i++) {
42038                     var related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], false, false, false, isRelatedTo);
42039                     if (!related) {
42040                         return 0;
42041                     }
42042                     result &= related;
42043                 }
42044                 return result;
42045             }
42046             function eachPropertyRelatedTo(source, target, kind, reportErrors) {
42047                 var result = -1;
42048                 var props = source.flags & 2097152 ? getPropertiesOfUnionOrIntersectionType(source) : getPropertiesOfObjectType(source);
42049                 for (var _i = 0, props_2 = props; _i < props_2.length; _i++) {
42050                     var prop = props_2[_i];
42051                     if (isIgnoredJsxProperty(source, prop)) {
42052                         continue;
42053                     }
42054                     var nameType = getSymbolLinks(prop).nameType;
42055                     if (nameType && nameType.flags & 8192) {
42056                         continue;
42057                     }
42058                     if (kind === 0 || isNumericLiteralName(prop.escapedName)) {
42059                         var related = isRelatedTo(getTypeOfSymbol(prop), target, reportErrors);
42060                         if (!related) {
42061                             if (reportErrors) {
42062                                 reportError(ts.Diagnostics.Property_0_is_incompatible_with_index_signature, symbolToString(prop));
42063                             }
42064                             return 0;
42065                         }
42066                         result &= related;
42067                     }
42068                 }
42069                 return result;
42070             }
42071             function indexTypeRelatedTo(sourceType, targetType, reportErrors) {
42072                 var related = isRelatedTo(sourceType, targetType, reportErrors);
42073                 if (!related && reportErrors) {
42074                     reportError(ts.Diagnostics.Index_signatures_are_incompatible);
42075                 }
42076                 return related;
42077             }
42078             function indexTypesRelatedTo(source, target, kind, sourceIsPrimitive, reportErrors, intersectionState) {
42079                 if (relation === identityRelation) {
42080                     return indexTypesIdenticalTo(source, target, kind);
42081                 }
42082                 var targetType = getIndexTypeOfType(target, kind);
42083                 if (!targetType || targetType.flags & 1 && !sourceIsPrimitive) {
42084                     return -1;
42085                 }
42086                 if (isGenericMappedType(source)) {
42087                     return kind === 0 ? isRelatedTo(getTemplateTypeFromMappedType(source), targetType, reportErrors) : 0;
42088                 }
42089                 var indexType = getIndexTypeOfType(source, kind) || kind === 1 && getIndexTypeOfType(source, 0);
42090                 if (indexType) {
42091                     return indexTypeRelatedTo(indexType, targetType, reportErrors);
42092                 }
42093                 if (!(intersectionState & 1) && isObjectTypeWithInferableIndex(source)) {
42094                     var related = eachPropertyRelatedTo(source, targetType, kind, reportErrors);
42095                     if (related && kind === 0) {
42096                         var numberIndexType = getIndexTypeOfType(source, 1);
42097                         if (numberIndexType) {
42098                             related &= indexTypeRelatedTo(numberIndexType, targetType, reportErrors);
42099                         }
42100                     }
42101                     return related;
42102                 }
42103                 if (reportErrors) {
42104                     reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source));
42105                 }
42106                 return 0;
42107             }
42108             function indexTypesIdenticalTo(source, target, indexKind) {
42109                 var targetInfo = getIndexInfoOfType(target, indexKind);
42110                 var sourceInfo = getIndexInfoOfType(source, indexKind);
42111                 if (!sourceInfo && !targetInfo) {
42112                     return -1;
42113                 }
42114                 if (sourceInfo && targetInfo && sourceInfo.isReadonly === targetInfo.isReadonly) {
42115                     return isRelatedTo(sourceInfo.type, targetInfo.type);
42116                 }
42117                 return 0;
42118             }
42119             function constructorVisibilitiesAreCompatible(sourceSignature, targetSignature, reportErrors) {
42120                 if (!sourceSignature.declaration || !targetSignature.declaration) {
42121                     return true;
42122                 }
42123                 var sourceAccessibility = ts.getSelectedModifierFlags(sourceSignature.declaration, 24);
42124                 var targetAccessibility = ts.getSelectedModifierFlags(targetSignature.declaration, 24);
42125                 if (targetAccessibility === 8) {
42126                     return true;
42127                 }
42128                 if (targetAccessibility === 16 && sourceAccessibility !== 8) {
42129                     return true;
42130                 }
42131                 if (targetAccessibility !== 16 && !sourceAccessibility) {
42132                     return true;
42133                 }
42134                 if (reportErrors) {
42135                     reportError(ts.Diagnostics.Cannot_assign_a_0_constructor_type_to_a_1_constructor_type, visibilityToString(sourceAccessibility), visibilityToString(targetAccessibility));
42136                 }
42137                 return false;
42138             }
42139         }
42140         function getBestMatchingType(source, target, isRelatedTo) {
42141             if (isRelatedTo === void 0) { isRelatedTo = compareTypesAssignable; }
42142             return findMatchingDiscriminantType(source, target, isRelatedTo, true) ||
42143                 findMatchingTypeReferenceOrTypeAliasReference(source, target) ||
42144                 findBestTypeForObjectLiteral(source, target) ||
42145                 findBestTypeForInvokable(source, target) ||
42146                 findMostOverlappyType(source, target);
42147         }
42148         function discriminateTypeByDiscriminableItems(target, discriminators, related, defaultValue, skipPartial) {
42149             var discriminable = target.types.map(function (_) { return undefined; });
42150             for (var _i = 0, discriminators_1 = discriminators; _i < discriminators_1.length; _i++) {
42151                 var _a = discriminators_1[_i], getDiscriminatingType = _a[0], propertyName = _a[1];
42152                 var targetProp = getUnionOrIntersectionProperty(target, propertyName);
42153                 if (skipPartial && targetProp && ts.getCheckFlags(targetProp) & 16) {
42154                     continue;
42155                 }
42156                 var i = 0;
42157                 for (var _b = 0, _c = target.types; _b < _c.length; _b++) {
42158                     var type = _c[_b];
42159                     var targetType = getTypeOfPropertyOfType(type, propertyName);
42160                     if (targetType && related(getDiscriminatingType(), targetType)) {
42161                         discriminable[i] = discriminable[i] === undefined ? true : discriminable[i];
42162                     }
42163                     else {
42164                         discriminable[i] = false;
42165                     }
42166                     i++;
42167                 }
42168             }
42169             var match = discriminable.indexOf(true);
42170             return match === -1 || discriminable.indexOf(true, match + 1) !== -1 ? defaultValue : target.types[match];
42171         }
42172         function isWeakType(type) {
42173             if (type.flags & 524288) {
42174                 var resolved = resolveStructuredTypeMembers(type);
42175                 return resolved.callSignatures.length === 0 && resolved.constructSignatures.length === 0 &&
42176                     !resolved.stringIndexInfo && !resolved.numberIndexInfo &&
42177                     resolved.properties.length > 0 &&
42178                     ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216); });
42179             }
42180             if (type.flags & 2097152) {
42181                 return ts.every(type.types, isWeakType);
42182             }
42183             return false;
42184         }
42185         function hasCommonProperties(source, target, isComparingJsxAttributes) {
42186             for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) {
42187                 var prop = _a[_i];
42188                 if (isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) {
42189                     return true;
42190                 }
42191             }
42192             return false;
42193         }
42194         function getMarkerTypeReference(type, source, target) {
42195             var result = createTypeReference(type, ts.map(type.typeParameters, function (t) { return t === source ? target : t; }));
42196             result.objectFlags |= 8192;
42197             return result;
42198         }
42199         function getAliasVariances(symbol) {
42200             var links = getSymbolLinks(symbol);
42201             return getVariancesWorker(links.typeParameters, links, function (_links, param, marker) {
42202                 var type = getTypeAliasInstantiation(symbol, instantiateTypes(links.typeParameters, makeUnaryTypeMapper(param, marker)));
42203                 type.aliasTypeArgumentsContainsMarker = true;
42204                 return type;
42205             });
42206         }
42207         function getVariancesWorker(typeParameters, cache, createMarkerType) {
42208             if (typeParameters === void 0) { typeParameters = ts.emptyArray; }
42209             var variances = cache.variances;
42210             if (!variances) {
42211                 cache.variances = ts.emptyArray;
42212                 variances = [];
42213                 var _loop_16 = function (tp) {
42214                     var unmeasurable = false;
42215                     var unreliable = false;
42216                     var oldHandler = outofbandVarianceMarkerHandler;
42217                     outofbandVarianceMarkerHandler = function (onlyUnreliable) { return onlyUnreliable ? unreliable = true : unmeasurable = true; };
42218                     var typeWithSuper = createMarkerType(cache, tp, markerSuperType);
42219                     var typeWithSub = createMarkerType(cache, tp, markerSubType);
42220                     var variance = (isTypeAssignableTo(typeWithSub, typeWithSuper) ? 1 : 0) |
42221                         (isTypeAssignableTo(typeWithSuper, typeWithSub) ? 2 : 0);
42222                     if (variance === 3 && isTypeAssignableTo(createMarkerType(cache, tp, markerOtherType), typeWithSuper)) {
42223                         variance = 4;
42224                     }
42225                     outofbandVarianceMarkerHandler = oldHandler;
42226                     if (unmeasurable || unreliable) {
42227                         if (unmeasurable) {
42228                             variance |= 8;
42229                         }
42230                         if (unreliable) {
42231                             variance |= 16;
42232                         }
42233                     }
42234                     variances.push(variance);
42235                 };
42236                 for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) {
42237                     var tp = typeParameters_1[_i];
42238                     _loop_16(tp);
42239                 }
42240                 cache.variances = variances;
42241             }
42242             return variances;
42243         }
42244         function getVariances(type) {
42245             if (type === globalArrayType || type === globalReadonlyArrayType || type.objectFlags & 8) {
42246                 return arrayVariances;
42247             }
42248             return getVariancesWorker(type.typeParameters, type, getMarkerTypeReference);
42249         }
42250         function hasCovariantVoidArgument(typeArguments, variances) {
42251             for (var i = 0; i < variances.length; i++) {
42252                 if ((variances[i] & 7) === 1 && typeArguments[i].flags & 16384) {
42253                     return true;
42254                 }
42255             }
42256             return false;
42257         }
42258         function isUnconstrainedTypeParameter(type) {
42259             return type.flags & 262144 && !getConstraintOfTypeParameter(type);
42260         }
42261         function isNonDeferredTypeReference(type) {
42262             return !!(ts.getObjectFlags(type) & 4) && !type.node;
42263         }
42264         function isTypeReferenceWithGenericArguments(type) {
42265             return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); });
42266         }
42267         function getTypeReferenceId(type, typeParameters, depth) {
42268             if (depth === void 0) { depth = 0; }
42269             var result = "" + type.target.id;
42270             for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) {
42271                 var t = _a[_i];
42272                 if (isUnconstrainedTypeParameter(t)) {
42273                     var index = typeParameters.indexOf(t);
42274                     if (index < 0) {
42275                         index = typeParameters.length;
42276                         typeParameters.push(t);
42277                     }
42278                     result += "=" + index;
42279                 }
42280                 else if (depth < 4 && isTypeReferenceWithGenericArguments(t)) {
42281                     result += "<" + getTypeReferenceId(t, typeParameters, depth + 1) + ">";
42282                 }
42283                 else {
42284                     result += "-" + t.id;
42285                 }
42286             }
42287             return result;
42288         }
42289         function getRelationKey(source, target, intersectionState, relation) {
42290             if (relation === identityRelation && source.id > target.id) {
42291                 var temp = source;
42292                 source = target;
42293                 target = temp;
42294             }
42295             var postFix = intersectionState ? ":" + intersectionState : "";
42296             if (isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target)) {
42297                 var typeParameters = [];
42298                 return getTypeReferenceId(source, typeParameters) + "," + getTypeReferenceId(target, typeParameters) + postFix;
42299             }
42300             return source.id + "," + target.id + postFix;
42301         }
42302         function forEachProperty(prop, callback) {
42303             if (ts.getCheckFlags(prop) & 6) {
42304                 for (var _i = 0, _a = prop.containingType.types; _i < _a.length; _i++) {
42305                     var t = _a[_i];
42306                     var p = getPropertyOfType(t, prop.escapedName);
42307                     var result = p && forEachProperty(p, callback);
42308                     if (result) {
42309                         return result;
42310                     }
42311                 }
42312                 return undefined;
42313             }
42314             return callback(prop);
42315         }
42316         function getDeclaringClass(prop) {
42317             return prop.parent && prop.parent.flags & 32 ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined;
42318         }
42319         function isPropertyInClassDerivedFrom(prop, baseClass) {
42320             return forEachProperty(prop, function (sp) {
42321                 var sourceClass = getDeclaringClass(sp);
42322                 return sourceClass ? hasBaseType(sourceClass, baseClass) : false;
42323             });
42324         }
42325         function isValidOverrideOf(sourceProp, targetProp) {
42326             return !forEachProperty(targetProp, function (tp) { return ts.getDeclarationModifierFlagsFromSymbol(tp) & 16 ?
42327                 !isPropertyInClassDerivedFrom(sourceProp, getDeclaringClass(tp)) : false; });
42328         }
42329         function isClassDerivedFromDeclaringClasses(checkClass, prop) {
42330             return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p) & 16 ?
42331                 !hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass;
42332         }
42333         function isDeeplyNestedType(type, stack, depth) {
42334             if (depth >= 5 && type.flags & 524288 && !isObjectOrArrayLiteralType(type)) {
42335                 var symbol = type.symbol;
42336                 if (symbol) {
42337                     var count = 0;
42338                     for (var i = 0; i < depth; i++) {
42339                         var t = stack[i];
42340                         if (t.flags & 524288 && t.symbol === symbol) {
42341                             count++;
42342                             if (count >= 5)
42343                                 return true;
42344                         }
42345                     }
42346                 }
42347             }
42348             if (depth >= 5 && type.flags & 8388608) {
42349                 var root = getRootObjectTypeFromIndexedAccessChain(type);
42350                 var count = 0;
42351                 for (var i = 0; i < depth; i++) {
42352                     var t = stack[i];
42353                     if (getRootObjectTypeFromIndexedAccessChain(t) === root) {
42354                         count++;
42355                         if (count >= 5)
42356                             return true;
42357                     }
42358                 }
42359             }
42360             return false;
42361         }
42362         function getRootObjectTypeFromIndexedAccessChain(type) {
42363             var t = type;
42364             while (t.flags & 8388608) {
42365                 t = t.objectType;
42366             }
42367             return t;
42368         }
42369         function isPropertyIdenticalTo(sourceProp, targetProp) {
42370             return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0;
42371         }
42372         function compareProperties(sourceProp, targetProp, compareTypes) {
42373             if (sourceProp === targetProp) {
42374                 return -1;
42375             }
42376             var sourcePropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(sourceProp) & 24;
42377             var targetPropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(targetProp) & 24;
42378             if (sourcePropAccessibility !== targetPropAccessibility) {
42379                 return 0;
42380             }
42381             if (sourcePropAccessibility) {
42382                 if (getTargetSymbol(sourceProp) !== getTargetSymbol(targetProp)) {
42383                     return 0;
42384                 }
42385             }
42386             else {
42387                 if ((sourceProp.flags & 16777216) !== (targetProp.flags & 16777216)) {
42388                     return 0;
42389                 }
42390             }
42391             if (isReadonlySymbol(sourceProp) !== isReadonlySymbol(targetProp)) {
42392                 return 0;
42393             }
42394             return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp));
42395         }
42396         function isMatchingSignature(source, target, partialMatch) {
42397             var sourceParameterCount = getParameterCount(source);
42398             var targetParameterCount = getParameterCount(target);
42399             var sourceMinArgumentCount = getMinArgumentCount(source);
42400             var targetMinArgumentCount = getMinArgumentCount(target);
42401             var sourceHasRestParameter = hasEffectiveRestParameter(source);
42402             var targetHasRestParameter = hasEffectiveRestParameter(target);
42403             if (sourceParameterCount === targetParameterCount &&
42404                 sourceMinArgumentCount === targetMinArgumentCount &&
42405                 sourceHasRestParameter === targetHasRestParameter) {
42406                 return true;
42407             }
42408             if (partialMatch && sourceMinArgumentCount <= targetMinArgumentCount) {
42409                 return true;
42410             }
42411             return false;
42412         }
42413         function compareSignaturesIdentical(source, target, partialMatch, ignoreThisTypes, ignoreReturnTypes, compareTypes) {
42414             if (source === target) {
42415                 return -1;
42416             }
42417             if (!(isMatchingSignature(source, target, partialMatch))) {
42418                 return 0;
42419             }
42420             if (ts.length(source.typeParameters) !== ts.length(target.typeParameters)) {
42421                 return 0;
42422             }
42423             if (target.typeParameters) {
42424                 var mapper = createTypeMapper(source.typeParameters, target.typeParameters);
42425                 for (var i = 0; i < target.typeParameters.length; i++) {
42426                     var s = source.typeParameters[i];
42427                     var t = target.typeParameters[i];
42428                     if (!(s === t || compareTypes(instantiateType(getConstraintFromTypeParameter(s), mapper) || unknownType, getConstraintFromTypeParameter(t) || unknownType) &&
42429                         compareTypes(instantiateType(getDefaultFromTypeParameter(s), mapper) || unknownType, getDefaultFromTypeParameter(t) || unknownType))) {
42430                         return 0;
42431                     }
42432                 }
42433                 source = instantiateSignature(source, mapper, true);
42434             }
42435             var result = -1;
42436             if (!ignoreThisTypes) {
42437                 var sourceThisType = getThisTypeOfSignature(source);
42438                 if (sourceThisType) {
42439                     var targetThisType = getThisTypeOfSignature(target);
42440                     if (targetThisType) {
42441                         var related = compareTypes(sourceThisType, targetThisType);
42442                         if (!related) {
42443                             return 0;
42444                         }
42445                         result &= related;
42446                     }
42447                 }
42448             }
42449             var targetLen = getParameterCount(target);
42450             for (var i = 0; i < targetLen; i++) {
42451                 var s = getTypeAtPosition(source, i);
42452                 var t = getTypeAtPosition(target, i);
42453                 var related = compareTypes(t, s);
42454                 if (!related) {
42455                     return 0;
42456                 }
42457                 result &= related;
42458             }
42459             if (!ignoreReturnTypes) {
42460                 var sourceTypePredicate = getTypePredicateOfSignature(source);
42461                 var targetTypePredicate = getTypePredicateOfSignature(target);
42462                 result &= sourceTypePredicate || targetTypePredicate ?
42463                     compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes) :
42464                     compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target));
42465             }
42466             return result;
42467         }
42468         function compareTypePredicatesIdentical(source, target, compareTypes) {
42469             return !(source && target && typePredicateKindsMatch(source, target)) ? 0 :
42470                 source.type === target.type ? -1 :
42471                     source.type && target.type ? compareTypes(source.type, target.type) :
42472                         0;
42473         }
42474         function literalTypesWithSameBaseType(types) {
42475             var commonBaseType;
42476             for (var _i = 0, types_12 = types; _i < types_12.length; _i++) {
42477                 var t = types_12[_i];
42478                 var baseType = getBaseTypeOfLiteralType(t);
42479                 if (!commonBaseType) {
42480                     commonBaseType = baseType;
42481                 }
42482                 if (baseType === t || baseType !== commonBaseType) {
42483                     return false;
42484                 }
42485             }
42486             return true;
42487         }
42488         function getSupertypeOrUnion(types) {
42489             return literalTypesWithSameBaseType(types) ?
42490                 getUnionType(types) :
42491                 ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(s, t) ? t : s; });
42492         }
42493         function getCommonSupertype(types) {
42494             if (!strictNullChecks) {
42495                 return getSupertypeOrUnion(types);
42496             }
42497             var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304); });
42498             return primaryTypes.length ?
42499                 getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 98304) :
42500                 getUnionType(types, 2);
42501         }
42502         function getCommonSubtype(types) {
42503             return ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(t, s) ? t : s; });
42504         }
42505         function isArrayType(type) {
42506             return !!(ts.getObjectFlags(type) & 4) && (type.target === globalArrayType || type.target === globalReadonlyArrayType);
42507         }
42508         function isReadonlyArrayType(type) {
42509             return !!(ts.getObjectFlags(type) & 4) && type.target === globalReadonlyArrayType;
42510         }
42511         function isMutableArrayOrTuple(type) {
42512             return isArrayType(type) && !isReadonlyArrayType(type) || isTupleType(type) && !type.target.readonly;
42513         }
42514         function getElementTypeOfArrayType(type) {
42515             return isArrayType(type) ? getTypeArguments(type)[0] : undefined;
42516         }
42517         function isArrayLikeType(type) {
42518             return isArrayType(type) || !(type.flags & 98304) && isTypeAssignableTo(type, anyReadonlyArrayType);
42519         }
42520         function isEmptyArrayLiteralType(type) {
42521             var elementType = isArrayType(type) ? getTypeArguments(type)[0] : undefined;
42522             return elementType === undefinedWideningType || elementType === implicitNeverType;
42523         }
42524         function isTupleLikeType(type) {
42525             return isTupleType(type) || !!getPropertyOfType(type, "0");
42526         }
42527         function isArrayOrTupleLikeType(type) {
42528             return isArrayLikeType(type) || isTupleLikeType(type);
42529         }
42530         function getTupleElementType(type, index) {
42531             var propType = getTypeOfPropertyOfType(type, "" + index);
42532             if (propType) {
42533                 return propType;
42534             }
42535             if (everyType(type, isTupleType)) {
42536                 return mapType(type, function (t) { return getRestTypeOfTupleType(t) || undefinedType; });
42537             }
42538             return undefined;
42539         }
42540         function isNeitherUnitTypeNorNever(type) {
42541             return !(type.flags & (109440 | 131072));
42542         }
42543         function isUnitType(type) {
42544             return !!(type.flags & 109440);
42545         }
42546         function isLiteralType(type) {
42547             return type.flags & 16 ? true :
42548                 type.flags & 1048576 ? type.flags & 1024 ? true : ts.every(type.types, isUnitType) :
42549                     isUnitType(type);
42550         }
42551         function getBaseTypeOfLiteralType(type) {
42552             return type.flags & 1024 ? getBaseTypeOfEnumLiteralType(type) :
42553                 type.flags & 128 ? stringType :
42554                     type.flags & 256 ? numberType :
42555                         type.flags & 2048 ? bigintType :
42556                             type.flags & 512 ? booleanType :
42557                                 type.flags & 1048576 ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) :
42558                                     type;
42559         }
42560         function getWidenedLiteralType(type) {
42561             return type.flags & 1024 && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) :
42562                 type.flags & 128 && isFreshLiteralType(type) ? stringType :
42563                     type.flags & 256 && isFreshLiteralType(type) ? numberType :
42564                         type.flags & 2048 && isFreshLiteralType(type) ? bigintType :
42565                             type.flags & 512 && isFreshLiteralType(type) ? booleanType :
42566                                 type.flags & 1048576 ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) :
42567                                     type;
42568         }
42569         function getWidenedUniqueESSymbolType(type) {
42570             return type.flags & 8192 ? esSymbolType :
42571                 type.flags & 1048576 ? getUnionType(ts.sameMap(type.types, getWidenedUniqueESSymbolType)) :
42572                     type;
42573         }
42574         function getWidenedLiteralLikeTypeForContextualType(type, contextualType) {
42575             if (!isLiteralOfContextualType(type, contextualType)) {
42576                 type = getWidenedUniqueESSymbolType(getWidenedLiteralType(type));
42577             }
42578             return type;
42579         }
42580         function getWidenedLiteralLikeTypeForContextualReturnTypeIfNeeded(type, contextualSignatureReturnType, isAsync) {
42581             if (type && isUnitType(type)) {
42582                 var contextualType = !contextualSignatureReturnType ? undefined :
42583                     isAsync ? getPromisedTypeOfPromise(contextualSignatureReturnType) :
42584                         contextualSignatureReturnType;
42585                 type = getWidenedLiteralLikeTypeForContextualType(type, contextualType);
42586             }
42587             return type;
42588         }
42589         function getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(type, contextualSignatureReturnType, kind, isAsyncGenerator) {
42590             if (type && isUnitType(type)) {
42591                 var contextualType = !contextualSignatureReturnType ? undefined :
42592                     getIterationTypeOfGeneratorFunctionReturnType(kind, contextualSignatureReturnType, isAsyncGenerator);
42593                 type = getWidenedLiteralLikeTypeForContextualType(type, contextualType);
42594             }
42595             return type;
42596         }
42597         function isTupleType(type) {
42598             return !!(ts.getObjectFlags(type) & 4 && type.target.objectFlags & 8);
42599         }
42600         function getRestTypeOfTupleType(type) {
42601             return type.target.hasRestElement ? getTypeArguments(type)[type.target.typeParameters.length - 1] : undefined;
42602         }
42603         function getRestArrayTypeOfTupleType(type) {
42604             var restType = getRestTypeOfTupleType(type);
42605             return restType && createArrayType(restType);
42606         }
42607         function getLengthOfTupleType(type) {
42608             return getTypeReferenceArity(type) - (type.target.hasRestElement ? 1 : 0);
42609         }
42610         function isZeroBigInt(_a) {
42611             var value = _a.value;
42612             return value.base10Value === "0";
42613         }
42614         function getFalsyFlagsOfTypes(types) {
42615             var result = 0;
42616             for (var _i = 0, types_13 = types; _i < types_13.length; _i++) {
42617                 var t = types_13[_i];
42618                 result |= getFalsyFlags(t);
42619             }
42620             return result;
42621         }
42622         function getFalsyFlags(type) {
42623             return type.flags & 1048576 ? getFalsyFlagsOfTypes(type.types) :
42624                 type.flags & 128 ? type.value === "" ? 128 : 0 :
42625                     type.flags & 256 ? type.value === 0 ? 256 : 0 :
42626                         type.flags & 2048 ? isZeroBigInt(type) ? 2048 : 0 :
42627                             type.flags & 512 ? (type === falseType || type === regularFalseType) ? 512 : 0 :
42628                                 type.flags & 117724;
42629         }
42630         function removeDefinitelyFalsyTypes(type) {
42631             return getFalsyFlags(type) & 117632 ?
42632                 filterType(type, function (t) { return !(getFalsyFlags(t) & 117632); }) :
42633                 type;
42634         }
42635         function extractDefinitelyFalsyTypes(type) {
42636             return mapType(type, getDefinitelyFalsyPartOfType);
42637         }
42638         function getDefinitelyFalsyPartOfType(type) {
42639             return type.flags & 4 ? emptyStringType :
42640                 type.flags & 8 ? zeroType :
42641                     type.flags & 64 ? zeroBigIntType :
42642                         type === regularFalseType ||
42643                             type === falseType ||
42644                             type.flags & (16384 | 32768 | 65536) ||
42645                             type.flags & 128 && type.value === "" ||
42646                             type.flags & 256 && type.value === 0 ||
42647                             type.flags & 2048 && isZeroBigInt(type) ? type :
42648                             neverType;
42649         }
42650         function getNullableType(type, flags) {
42651             var missing = (flags & ~type.flags) & (32768 | 65536);
42652             return missing === 0 ? type :
42653                 missing === 32768 ? getUnionType([type, undefinedType]) :
42654                     missing === 65536 ? getUnionType([type, nullType]) :
42655                         getUnionType([type, undefinedType, nullType]);
42656         }
42657         function getOptionalType(type) {
42658             ts.Debug.assert(strictNullChecks);
42659             return type.flags & 32768 ? type : getUnionType([type, undefinedType]);
42660         }
42661         function getGlobalNonNullableTypeInstantiation(type) {
42662             if (!deferredGlobalNonNullableTypeAlias) {
42663                 deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288, undefined) || unknownSymbol;
42664             }
42665             if (deferredGlobalNonNullableTypeAlias !== unknownSymbol) {
42666                 return getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]);
42667             }
42668             return getTypeWithFacts(type, 2097152);
42669         }
42670         function getNonNullableType(type) {
42671             return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type;
42672         }
42673         function addOptionalTypeMarker(type) {
42674             return strictNullChecks ? getUnionType([type, optionalType]) : type;
42675         }
42676         function isNotOptionalTypeMarker(type) {
42677             return type !== optionalType;
42678         }
42679         function removeOptionalTypeMarker(type) {
42680             return strictNullChecks ? filterType(type, isNotOptionalTypeMarker) : type;
42681         }
42682         function propagateOptionalTypeMarker(type, node, wasOptional) {
42683             return wasOptional ? ts.isOutermostOptionalChain(node) ? getOptionalType(type) : addOptionalTypeMarker(type) : type;
42684         }
42685         function getOptionalExpressionType(exprType, expression) {
42686             return ts.isExpressionOfOptionalChainRoot(expression) ? getNonNullableType(exprType) :
42687                 ts.isOptionalChain(expression) ? removeOptionalTypeMarker(exprType) :
42688                     exprType;
42689         }
42690         function isCoercibleUnderDoubleEquals(source, target) {
42691             return ((source.flags & (8 | 4 | 512)) !== 0)
42692                 && ((target.flags & (8 | 4 | 16)) !== 0);
42693         }
42694         function isObjectTypeWithInferableIndex(type) {
42695             return type.flags & 2097152 ? ts.every(type.types, isObjectTypeWithInferableIndex) :
42696                 !!(type.symbol && (type.symbol.flags & (4096 | 2048 | 384 | 512)) !== 0 &&
42697                     !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 2048 && isObjectTypeWithInferableIndex(type.source));
42698         }
42699         function createSymbolWithType(source, type) {
42700             var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8);
42701             symbol.declarations = source.declarations;
42702             symbol.parent = source.parent;
42703             symbol.type = type;
42704             symbol.target = source;
42705             if (source.valueDeclaration) {
42706                 symbol.valueDeclaration = source.valueDeclaration;
42707             }
42708             var nameType = getSymbolLinks(source).nameType;
42709             if (nameType) {
42710                 symbol.nameType = nameType;
42711             }
42712             return symbol;
42713         }
42714         function transformTypeOfMembers(type, f) {
42715             var members = ts.createSymbolTable();
42716             for (var _i = 0, _a = getPropertiesOfObjectType(type); _i < _a.length; _i++) {
42717                 var property = _a[_i];
42718                 var original = getTypeOfSymbol(property);
42719                 var updated = f(original);
42720                 members.set(property.escapedName, updated === original ? property : createSymbolWithType(property, updated));
42721             }
42722             return members;
42723         }
42724         function getRegularTypeOfObjectLiteral(type) {
42725             if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 32768)) {
42726                 return type;
42727             }
42728             var regularType = type.regularType;
42729             if (regularType) {
42730                 return regularType;
42731             }
42732             var resolved = type;
42733             var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral);
42734             var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.stringIndexInfo, resolved.numberIndexInfo);
42735             regularNew.flags = resolved.flags;
42736             regularNew.objectFlags |= resolved.objectFlags & ~32768;
42737             type.regularType = regularNew;
42738             return regularNew;
42739         }
42740         function createWideningContext(parent, propertyName, siblings) {
42741             return { parent: parent, propertyName: propertyName, siblings: siblings, resolvedProperties: undefined };
42742         }
42743         function getSiblingsOfContext(context) {
42744             if (!context.siblings) {
42745                 var siblings_1 = [];
42746                 for (var _i = 0, _a = getSiblingsOfContext(context.parent); _i < _a.length; _i++) {
42747                     var type = _a[_i];
42748                     if (isObjectLiteralType(type)) {
42749                         var prop = getPropertyOfObjectType(type, context.propertyName);
42750                         if (prop) {
42751                             forEachType(getTypeOfSymbol(prop), function (t) {
42752                                 siblings_1.push(t);
42753                             });
42754                         }
42755                     }
42756                 }
42757                 context.siblings = siblings_1;
42758             }
42759             return context.siblings;
42760         }
42761         function getPropertiesOfContext(context) {
42762             if (!context.resolvedProperties) {
42763                 var names = ts.createMap();
42764                 for (var _i = 0, _a = getSiblingsOfContext(context); _i < _a.length; _i++) {
42765                     var t = _a[_i];
42766                     if (isObjectLiteralType(t) && !(ts.getObjectFlags(t) & 1024)) {
42767                         for (var _b = 0, _c = getPropertiesOfType(t); _b < _c.length; _b++) {
42768                             var prop = _c[_b];
42769                             names.set(prop.escapedName, prop);
42770                         }
42771                     }
42772                 }
42773                 context.resolvedProperties = ts.arrayFrom(names.values());
42774             }
42775             return context.resolvedProperties;
42776         }
42777         function getWidenedProperty(prop, context) {
42778             if (!(prop.flags & 4)) {
42779                 return prop;
42780             }
42781             var original = getTypeOfSymbol(prop);
42782             var propContext = context && createWideningContext(context, prop.escapedName, undefined);
42783             var widened = getWidenedTypeWithContext(original, propContext);
42784             return widened === original ? prop : createSymbolWithType(prop, widened);
42785         }
42786         function getUndefinedProperty(prop) {
42787             var cached = undefinedProperties.get(prop.escapedName);
42788             if (cached) {
42789                 return cached;
42790             }
42791             var result = createSymbolWithType(prop, undefinedType);
42792             result.flags |= 16777216;
42793             undefinedProperties.set(prop.escapedName, result);
42794             return result;
42795         }
42796         function getWidenedTypeOfObjectLiteral(type, context) {
42797             var members = ts.createSymbolTable();
42798             for (var _i = 0, _a = getPropertiesOfObjectType(type); _i < _a.length; _i++) {
42799                 var prop = _a[_i];
42800                 members.set(prop.escapedName, getWidenedProperty(prop, context));
42801             }
42802             if (context) {
42803                 for (var _b = 0, _c = getPropertiesOfContext(context); _b < _c.length; _b++) {
42804                     var prop = _c[_b];
42805                     if (!members.has(prop.escapedName)) {
42806                         members.set(prop.escapedName, getUndefinedProperty(prop));
42807                     }
42808                 }
42809             }
42810             var stringIndexInfo = getIndexInfoOfType(type, 0);
42811             var numberIndexInfo = getIndexInfoOfType(type, 1);
42812             var result = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, stringIndexInfo && createIndexInfo(getWidenedType(stringIndexInfo.type), stringIndexInfo.isReadonly), numberIndexInfo && createIndexInfo(getWidenedType(numberIndexInfo.type), numberIndexInfo.isReadonly));
42813             result.objectFlags |= (ts.getObjectFlags(type) & (16384 | 2097152));
42814             return result;
42815         }
42816         function getWidenedType(type) {
42817             return getWidenedTypeWithContext(type, undefined);
42818         }
42819         function getWidenedTypeWithContext(type, context) {
42820             if (ts.getObjectFlags(type) & 1572864) {
42821                 if (context === undefined && type.widened) {
42822                     return type.widened;
42823                 }
42824                 var result = void 0;
42825                 if (type.flags & (1 | 98304)) {
42826                     result = anyType;
42827                 }
42828                 else if (isObjectLiteralType(type)) {
42829                     result = getWidenedTypeOfObjectLiteral(type, context);
42830                 }
42831                 else if (type.flags & 1048576) {
42832                     var unionContext_1 = context || createWideningContext(undefined, undefined, type.types);
42833                     var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 ? t : getWidenedTypeWithContext(t, unionContext_1); });
42834                     result = getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 : 1);
42835                 }
42836                 else if (type.flags & 2097152) {
42837                     result = getIntersectionType(ts.sameMap(type.types, getWidenedType));
42838                 }
42839                 else if (isArrayType(type) || isTupleType(type)) {
42840                     result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType));
42841                 }
42842                 if (result && context === undefined) {
42843                     type.widened = result;
42844                 }
42845                 return result || type;
42846             }
42847             return type;
42848         }
42849         function reportWideningErrorsInType(type) {
42850             var errorReported = false;
42851             if (ts.getObjectFlags(type) & 524288) {
42852                 if (type.flags & 1048576) {
42853                     if (ts.some(type.types, isEmptyObjectType)) {
42854                         errorReported = true;
42855                     }
42856                     else {
42857                         for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
42858                             var t = _a[_i];
42859                             if (reportWideningErrorsInType(t)) {
42860                                 errorReported = true;
42861                             }
42862                         }
42863                     }
42864                 }
42865                 if (isArrayType(type) || isTupleType(type)) {
42866                     for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) {
42867                         var t = _c[_b];
42868                         if (reportWideningErrorsInType(t)) {
42869                             errorReported = true;
42870                         }
42871                     }
42872                 }
42873                 if (isObjectLiteralType(type)) {
42874                     for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) {
42875                         var p = _e[_d];
42876                         var t = getTypeOfSymbol(p);
42877                         if (ts.getObjectFlags(t) & 524288) {
42878                             if (!reportWideningErrorsInType(t)) {
42879                                 error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, symbolToString(p), typeToString(getWidenedType(t)));
42880                             }
42881                             errorReported = true;
42882                         }
42883                     }
42884                 }
42885             }
42886             return errorReported;
42887         }
42888         function reportImplicitAny(declaration, type, wideningKind) {
42889             var typeAsString = typeToString(getWidenedType(type));
42890             if (ts.isInJSFile(declaration) && !ts.isCheckJsEnabledForFile(ts.getSourceFileOfNode(declaration), compilerOptions)) {
42891                 return;
42892             }
42893             var diagnostic;
42894             switch (declaration.kind) {
42895                 case 209:
42896                 case 159:
42897                 case 158:
42898                     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;
42899                     break;
42900                 case 156:
42901                     var param = declaration;
42902                     if (ts.isIdentifier(param.name) &&
42903                         (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) &&
42904                         param.parent.parameters.indexOf(param) > -1 &&
42905                         (resolveName(param, param.name.escapedText, 788968, undefined, param.name.escapedText, true) ||
42906                             param.name.originalKeywordKind && ts.isTypeNodeKind(param.name.originalKeywordKind))) {
42907                         var newName = "arg" + param.parent.parameters.indexOf(param);
42908                         errorOrSuggestion(noImplicitAny, declaration, ts.Diagnostics.Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1, newName, ts.declarationNameToString(param.name));
42909                         return;
42910                     }
42911                     diagnostic = declaration.dotDotDotToken ?
42912                         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 :
42913                         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;
42914                     break;
42915                 case 191:
42916                     diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type;
42917                     if (!noImplicitAny) {
42918                         return;
42919                     }
42920                     break;
42921                 case 300:
42922                     error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString);
42923                     return;
42924                 case 244:
42925                 case 161:
42926                 case 160:
42927                 case 163:
42928                 case 164:
42929                 case 201:
42930                 case 202:
42931                     if (noImplicitAny && !declaration.name) {
42932                         if (wideningKind === 3) {
42933                             error(declaration, ts.Diagnostics.Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation, typeAsString);
42934                         }
42935                         else {
42936                             error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString);
42937                         }
42938                         return;
42939                     }
42940                     diagnostic = !noImplicitAny ? ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage :
42941                         wideningKind === 3 ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type :
42942                             ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type;
42943                     break;
42944                 case 186:
42945                     if (noImplicitAny) {
42946                         error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type);
42947                     }
42948                     return;
42949                 default:
42950                     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;
42951             }
42952             errorOrSuggestion(noImplicitAny, declaration, diagnostic, ts.declarationNameToString(ts.getNameOfDeclaration(declaration)), typeAsString);
42953         }
42954         function reportErrorsFromWidening(declaration, type, wideningKind) {
42955             if (produceDiagnostics && noImplicitAny && ts.getObjectFlags(type) & 524288 && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) {
42956                 if (!reportWideningErrorsInType(type)) {
42957                     reportImplicitAny(declaration, type, wideningKind);
42958                 }
42959             }
42960         }
42961         function applyToParameterTypes(source, target, callback) {
42962             var sourceCount = getParameterCount(source);
42963             var targetCount = getParameterCount(target);
42964             var sourceRestType = getEffectiveRestType(source);
42965             var targetRestType = getEffectiveRestType(target);
42966             var targetNonRestCount = targetRestType ? targetCount - 1 : targetCount;
42967             var paramCount = sourceRestType ? targetNonRestCount : Math.min(sourceCount, targetNonRestCount);
42968             var sourceThisType = getThisTypeOfSignature(source);
42969             if (sourceThisType) {
42970                 var targetThisType = getThisTypeOfSignature(target);
42971                 if (targetThisType) {
42972                     callback(sourceThisType, targetThisType);
42973                 }
42974             }
42975             for (var i = 0; i < paramCount; i++) {
42976                 callback(getTypeAtPosition(source, i), getTypeAtPosition(target, i));
42977             }
42978             if (targetRestType) {
42979                 callback(getRestTypeAtPosition(source, paramCount), targetRestType);
42980             }
42981         }
42982         function applyToReturnTypes(source, target, callback) {
42983             var sourceTypePredicate = getTypePredicateOfSignature(source);
42984             var targetTypePredicate = getTypePredicateOfSignature(target);
42985             if (sourceTypePredicate && targetTypePredicate && typePredicateKindsMatch(sourceTypePredicate, targetTypePredicate) && sourceTypePredicate.type && targetTypePredicate.type) {
42986                 callback(sourceTypePredicate.type, targetTypePredicate.type);
42987             }
42988             else {
42989                 callback(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target));
42990             }
42991         }
42992         function createInferenceContext(typeParameters, signature, flags, compareTypes) {
42993             return createInferenceContextWorker(typeParameters.map(createInferenceInfo), signature, flags, compareTypes || compareTypesAssignable);
42994         }
42995         function cloneInferenceContext(context, extraFlags) {
42996             if (extraFlags === void 0) { extraFlags = 0; }
42997             return context && createInferenceContextWorker(ts.map(context.inferences, cloneInferenceInfo), context.signature, context.flags | extraFlags, context.compareTypes);
42998         }
42999         function createInferenceContextWorker(inferences, signature, flags, compareTypes) {
43000             var context = {
43001                 inferences: inferences,
43002                 signature: signature,
43003                 flags: flags,
43004                 compareTypes: compareTypes,
43005                 mapper: makeFunctionTypeMapper(function (t) { return mapToInferredType(context, t, true); }),
43006                 nonFixingMapper: makeFunctionTypeMapper(function (t) { return mapToInferredType(context, t, false); }),
43007             };
43008             return context;
43009         }
43010         function mapToInferredType(context, t, fix) {
43011             var inferences = context.inferences;
43012             for (var i = 0; i < inferences.length; i++) {
43013                 var inference = inferences[i];
43014                 if (t === inference.typeParameter) {
43015                     if (fix && !inference.isFixed) {
43016                         clearCachedInferences(inferences);
43017                         inference.isFixed = true;
43018                     }
43019                     return getInferredType(context, i);
43020                 }
43021             }
43022             return t;
43023         }
43024         function clearCachedInferences(inferences) {
43025             for (var _i = 0, inferences_1 = inferences; _i < inferences_1.length; _i++) {
43026                 var inference = inferences_1[_i];
43027                 if (!inference.isFixed) {
43028                     inference.inferredType = undefined;
43029                 }
43030             }
43031         }
43032         function createInferenceInfo(typeParameter) {
43033             return {
43034                 typeParameter: typeParameter,
43035                 candidates: undefined,
43036                 contraCandidates: undefined,
43037                 inferredType: undefined,
43038                 priority: undefined,
43039                 topLevel: true,
43040                 isFixed: false
43041             };
43042         }
43043         function cloneInferenceInfo(inference) {
43044             return {
43045                 typeParameter: inference.typeParameter,
43046                 candidates: inference.candidates && inference.candidates.slice(),
43047                 contraCandidates: inference.contraCandidates && inference.contraCandidates.slice(),
43048                 inferredType: inference.inferredType,
43049                 priority: inference.priority,
43050                 topLevel: inference.topLevel,
43051                 isFixed: inference.isFixed
43052             };
43053         }
43054         function cloneInferredPartOfContext(context) {
43055             var inferences = ts.filter(context.inferences, hasInferenceCandidates);
43056             return inferences.length ?
43057                 createInferenceContextWorker(ts.map(inferences, cloneInferenceInfo), context.signature, context.flags, context.compareTypes) :
43058                 undefined;
43059         }
43060         function getMapperFromContext(context) {
43061             return context && context.mapper;
43062         }
43063         function couldContainTypeVariables(type) {
43064             var objectFlags = ts.getObjectFlags(type);
43065             if (objectFlags & 67108864) {
43066                 return !!(objectFlags & 134217728);
43067             }
43068             var result = !!(type.flags & 63176704 ||
43069                 objectFlags & 4 && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) ||
43070                 objectFlags & 16 && type.symbol && type.symbol.flags & (16 | 8192 | 32 | 2048 | 4096) && type.symbol.declarations ||
43071                 objectFlags & (32 | 131072) ||
43072                 type.flags & 3145728 && !(type.flags & 1024) && ts.some(type.types, couldContainTypeVariables));
43073             if (type.flags & 3899393) {
43074                 type.objectFlags |= 67108864 | (result ? 134217728 : 0);
43075             }
43076             return result;
43077         }
43078         function isTypeParameterAtTopLevel(type, typeParameter) {
43079             return !!(type === typeParameter ||
43080                 type.flags & 3145728 && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }) ||
43081                 type.flags & 16777216 && (isTypeParameterAtTopLevel(getTrueTypeFromConditionalType(type), typeParameter) ||
43082                     isTypeParameterAtTopLevel(getFalseTypeFromConditionalType(type), typeParameter)));
43083         }
43084         function createEmptyObjectTypeFromStringLiteral(type) {
43085             var members = ts.createSymbolTable();
43086             forEachType(type, function (t) {
43087                 if (!(t.flags & 128)) {
43088                     return;
43089                 }
43090                 var name = ts.escapeLeadingUnderscores(t.value);
43091                 var literalProp = createSymbol(4, name);
43092                 literalProp.type = anyType;
43093                 if (t.symbol) {
43094                     literalProp.declarations = t.symbol.declarations;
43095                     literalProp.valueDeclaration = t.symbol.valueDeclaration;
43096                 }
43097                 members.set(name, literalProp);
43098             });
43099             var indexInfo = type.flags & 4 ? createIndexInfo(emptyObjectType, false) : undefined;
43100             return createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, indexInfo, undefined);
43101         }
43102         function inferTypeForHomomorphicMappedType(source, target, constraint) {
43103             var key = source.id + "," + target.id + "," + constraint.id;
43104             if (reverseMappedCache.has(key)) {
43105                 return reverseMappedCache.get(key);
43106             }
43107             reverseMappedCache.set(key, undefined);
43108             var type = createReverseMappedType(source, target, constraint);
43109             reverseMappedCache.set(key, type);
43110             return type;
43111         }
43112         function isPartiallyInferableType(type) {
43113             return !(ts.getObjectFlags(type) & 2097152) ||
43114                 isObjectLiteralType(type) && ts.some(getPropertiesOfType(type), function (prop) { return isPartiallyInferableType(getTypeOfSymbol(prop)); });
43115         }
43116         function createReverseMappedType(source, target, constraint) {
43117             if (!(getIndexInfoOfType(source, 0) || getPropertiesOfType(source).length !== 0 && isPartiallyInferableType(source))) {
43118                 return undefined;
43119             }
43120             if (isArrayType(source)) {
43121                 return createArrayType(inferReverseMappedType(getTypeArguments(source)[0], target, constraint), isReadonlyArrayType(source));
43122             }
43123             if (isTupleType(source)) {
43124                 var elementTypes = ts.map(getTypeArguments(source), function (t) { return inferReverseMappedType(t, target, constraint); });
43125                 var minLength = getMappedTypeModifiers(target) & 4 ?
43126                     getTypeReferenceArity(source) - (source.target.hasRestElement ? 1 : 0) : source.target.minLength;
43127                 return createTupleType(elementTypes, minLength, source.target.hasRestElement, source.target.readonly, source.target.associatedNames);
43128             }
43129             var reversed = createObjectType(2048 | 16, undefined);
43130             reversed.source = source;
43131             reversed.mappedType = target;
43132             reversed.constraintType = constraint;
43133             return reversed;
43134         }
43135         function getTypeOfReverseMappedSymbol(symbol) {
43136             return inferReverseMappedType(symbol.propertyType, symbol.mappedType, symbol.constraintType);
43137         }
43138         function inferReverseMappedType(sourceType, target, constraint) {
43139             var typeParameter = getIndexedAccessType(constraint.type, getTypeParameterFromMappedType(target));
43140             var templateType = getTemplateTypeFromMappedType(target);
43141             var inference = createInferenceInfo(typeParameter);
43142             inferTypes([inference], sourceType, templateType);
43143             return getTypeFromInference(inference) || unknownType;
43144         }
43145         function getUnmatchedProperties(source, target, requireOptionalProperties, matchDiscriminantProperties) {
43146             var properties, _i, properties_2, targetProp, sourceProp, targetType, sourceType;
43147             return __generator(this, function (_a) {
43148                 switch (_a.label) {
43149                     case 0:
43150                         properties = getPropertiesOfType(target);
43151                         _i = 0, properties_2 = properties;
43152                         _a.label = 1;
43153                     case 1:
43154                         if (!(_i < properties_2.length)) return [3, 6];
43155                         targetProp = properties_2[_i];
43156                         if (isStaticPrivateIdentifierProperty(targetProp)) {
43157                             return [3, 5];
43158                         }
43159                         if (!(requireOptionalProperties || !(targetProp.flags & 16777216 || ts.getCheckFlags(targetProp) & 48))) return [3, 5];
43160                         sourceProp = getPropertyOfType(source, targetProp.escapedName);
43161                         if (!!sourceProp) return [3, 3];
43162                         return [4, targetProp];
43163                     case 2:
43164                         _a.sent();
43165                         return [3, 5];
43166                     case 3:
43167                         if (!matchDiscriminantProperties) return [3, 5];
43168                         targetType = getTypeOfSymbol(targetProp);
43169                         if (!(targetType.flags & 109440)) return [3, 5];
43170                         sourceType = getTypeOfSymbol(sourceProp);
43171                         if (!!(sourceType.flags & 1 || getRegularTypeOfLiteralType(sourceType) === getRegularTypeOfLiteralType(targetType))) return [3, 5];
43172                         return [4, targetProp];
43173                     case 4:
43174                         _a.sent();
43175                         _a.label = 5;
43176                     case 5:
43177                         _i++;
43178                         return [3, 1];
43179                     case 6: return [2];
43180                 }
43181             });
43182         }
43183         function getUnmatchedProperty(source, target, requireOptionalProperties, matchDiscriminantProperties) {
43184             var result = getUnmatchedProperties(source, target, requireOptionalProperties, matchDiscriminantProperties).next();
43185             if (!result.done)
43186                 return result.value;
43187         }
43188         function tupleTypesDefinitelyUnrelated(source, target) {
43189             return target.target.minLength > source.target.minLength ||
43190                 !getRestTypeOfTupleType(target) && (!!getRestTypeOfTupleType(source) || getLengthOfTupleType(target) < getLengthOfTupleType(source));
43191         }
43192         function typesDefinitelyUnrelated(source, target) {
43193             return isTupleType(source) && isTupleType(target) && tupleTypesDefinitelyUnrelated(source, target) ||
43194                 !!getUnmatchedProperty(source, target, false, true) &&
43195                     !!getUnmatchedProperty(target, source, false, true);
43196         }
43197         function getTypeFromInference(inference) {
43198             return inference.candidates ? getUnionType(inference.candidates, 2) :
43199                 inference.contraCandidates ? getIntersectionType(inference.contraCandidates) :
43200                     undefined;
43201         }
43202         function hasSkipDirectInferenceFlag(node) {
43203             return !!getNodeLinks(node).skipDirectInference;
43204         }
43205         function isFromInferenceBlockedSource(type) {
43206             return !!(type.symbol && ts.some(type.symbol.declarations, hasSkipDirectInferenceFlag));
43207         }
43208         function inferTypes(inferences, originalSource, originalTarget, priority, contravariant) {
43209             if (priority === void 0) { priority = 0; }
43210             if (contravariant === void 0) { contravariant = false; }
43211             var symbolOrTypeStack;
43212             var visited;
43213             var bivariant = false;
43214             var propagationType;
43215             var inferencePriority = 512;
43216             var allowComplexConstraintInference = true;
43217             inferFromTypes(originalSource, originalTarget);
43218             function inferFromTypes(source, target) {
43219                 if (!couldContainTypeVariables(target)) {
43220                     return;
43221                 }
43222                 if (source === wildcardType) {
43223                     var savePropagationType = propagationType;
43224                     propagationType = source;
43225                     inferFromTypes(target, target);
43226                     propagationType = savePropagationType;
43227                     return;
43228                 }
43229                 if (source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) {
43230                     inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol));
43231                     return;
43232                 }
43233                 if (source === target && source.flags & 3145728) {
43234                     for (var _i = 0, _a = source.types; _i < _a.length; _i++) {
43235                         var t = _a[_i];
43236                         inferFromTypes(t, t);
43237                     }
43238                     return;
43239                 }
43240                 if (target.flags & 1048576) {
43241                     var _b = inferFromMatchingTypes(source.flags & 1048576 ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1];
43242                     var _c = inferFromMatchingTypes(tempSources, tempTargets, isTypeCloselyMatchedBy), sources = _c[0], targets = _c[1];
43243                     if (targets.length === 0) {
43244                         return;
43245                     }
43246                     target = getUnionType(targets);
43247                     if (sources.length === 0) {
43248                         inferWithPriority(source, target, 1);
43249                         return;
43250                     }
43251                     source = getUnionType(sources);
43252                 }
43253                 else if (target.flags & 2097152 && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) {
43254                     if (!(source.flags & 1048576)) {
43255                         var _d = inferFromMatchingTypes(source.flags & 2097152 ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1];
43256                         if (sources.length === 0 || targets.length === 0) {
43257                             return;
43258                         }
43259                         source = getIntersectionType(sources);
43260                         target = getIntersectionType(targets);
43261                     }
43262                 }
43263                 else if (target.flags & (8388608 | 33554432)) {
43264                     target = getActualTypeVariable(target);
43265                 }
43266                 if (target.flags & 8650752) {
43267                     if (ts.getObjectFlags(source) & 2097152 || source === nonInferrableAnyType || source === silentNeverType ||
43268                         (priority & 32 && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) {
43269                         return;
43270                     }
43271                     var inference = getInferenceInfoForType(target);
43272                     if (inference) {
43273                         if (!inference.isFixed) {
43274                             if (inference.priority === undefined || priority < inference.priority) {
43275                                 inference.candidates = undefined;
43276                                 inference.contraCandidates = undefined;
43277                                 inference.topLevel = true;
43278                                 inference.priority = priority;
43279                             }
43280                             if (priority === inference.priority) {
43281                                 var candidate = propagationType || source;
43282                                 if (contravariant && !bivariant) {
43283                                     if (!ts.contains(inference.contraCandidates, candidate)) {
43284                                         inference.contraCandidates = ts.append(inference.contraCandidates, candidate);
43285                                         clearCachedInferences(inferences);
43286                                     }
43287                                 }
43288                                 else if (!ts.contains(inference.candidates, candidate)) {
43289                                     inference.candidates = ts.append(inference.candidates, candidate);
43290                                     clearCachedInferences(inferences);
43291                                 }
43292                             }
43293                             if (!(priority & 32) && target.flags & 262144 && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) {
43294                                 inference.topLevel = false;
43295                                 clearCachedInferences(inferences);
43296                             }
43297                         }
43298                         inferencePriority = Math.min(inferencePriority, priority);
43299                         return;
43300                     }
43301                     else {
43302                         var simplified = getSimplifiedType(target, false);
43303                         if (simplified !== target) {
43304                             invokeOnce(source, simplified, inferFromTypes);
43305                         }
43306                         else if (target.flags & 8388608) {
43307                             var indexType = getSimplifiedType(target.indexType, false);
43308                             if (indexType.flags & 63176704) {
43309                                 var simplified_1 = distributeIndexOverObjectType(getSimplifiedType(target.objectType, false), indexType, false);
43310                                 if (simplified_1 && simplified_1 !== target) {
43311                                     invokeOnce(source, simplified_1, inferFromTypes);
43312                                 }
43313                             }
43314                         }
43315                     }
43316                 }
43317                 if (ts.getObjectFlags(source) & 4 && ts.getObjectFlags(target) & 4 && (source.target === target.target || isArrayType(source) && isArrayType(target)) &&
43318                     !(source.node && target.node)) {
43319                     inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target));
43320                 }
43321                 else if (source.flags & 4194304 && target.flags & 4194304) {
43322                     contravariant = !contravariant;
43323                     inferFromTypes(source.type, target.type);
43324                     contravariant = !contravariant;
43325                 }
43326                 else if ((isLiteralType(source) || source.flags & 4) && target.flags & 4194304) {
43327                     var empty = createEmptyObjectTypeFromStringLiteral(source);
43328                     contravariant = !contravariant;
43329                     inferWithPriority(empty, target.type, 64);
43330                     contravariant = !contravariant;
43331                 }
43332                 else if (source.flags & 8388608 && target.flags & 8388608) {
43333                     inferFromTypes(source.objectType, target.objectType);
43334                     inferFromTypes(source.indexType, target.indexType);
43335                 }
43336                 else if (source.flags & 16777216 && target.flags & 16777216) {
43337                     inferFromTypes(source.checkType, target.checkType);
43338                     inferFromTypes(source.extendsType, target.extendsType);
43339                     inferFromTypes(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target));
43340                     inferFromTypes(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target));
43341                 }
43342                 else if (target.flags & 16777216) {
43343                     var savePriority = priority;
43344                     priority |= contravariant ? 16 : 0;
43345                     var targetTypes = [getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)];
43346                     inferToMultipleTypes(source, targetTypes, target.flags);
43347                     priority = savePriority;
43348                 }
43349                 else if (target.flags & 3145728) {
43350                     inferToMultipleTypes(source, target.types, target.flags);
43351                 }
43352                 else if (source.flags & 1048576) {
43353                     var sourceTypes = source.types;
43354                     for (var _e = 0, sourceTypes_2 = sourceTypes; _e < sourceTypes_2.length; _e++) {
43355                         var sourceType = sourceTypes_2[_e];
43356                         inferFromTypes(sourceType, target);
43357                     }
43358                 }
43359                 else {
43360                     source = getReducedType(source);
43361                     if (!(priority & 128 && source.flags & (2097152 | 63176704))) {
43362                         var apparentSource = getApparentType(source);
43363                         if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 | 2097152))) {
43364                             allowComplexConstraintInference = false;
43365                             return inferFromTypes(apparentSource, target);
43366                         }
43367                         source = apparentSource;
43368                     }
43369                     if (source.flags & (524288 | 2097152)) {
43370                         invokeOnce(source, target, inferFromObjectTypes);
43371                     }
43372                 }
43373                 if (source.flags & 25165824) {
43374                     var simplified = getSimplifiedType(source, contravariant);
43375                     if (simplified !== source) {
43376                         inferFromTypes(simplified, target);
43377                     }
43378                 }
43379             }
43380             function inferWithPriority(source, target, newPriority) {
43381                 var savePriority = priority;
43382                 priority |= newPriority;
43383                 inferFromTypes(source, target);
43384                 priority = savePriority;
43385             }
43386             function invokeOnce(source, target, action) {
43387                 var key = source.id + "," + target.id;
43388                 var status = visited && visited.get(key);
43389                 if (status !== undefined) {
43390                     inferencePriority = Math.min(inferencePriority, status);
43391                     return;
43392                 }
43393                 (visited || (visited = ts.createMap())).set(key, -1);
43394                 var saveInferencePriority = inferencePriority;
43395                 inferencePriority = 512;
43396                 action(source, target);
43397                 visited.set(key, inferencePriority);
43398                 inferencePriority = Math.min(inferencePriority, saveInferencePriority);
43399             }
43400             function inferFromMatchingTypes(sources, targets, matches) {
43401                 var matchedSources;
43402                 var matchedTargets;
43403                 for (var _i = 0, targets_1 = targets; _i < targets_1.length; _i++) {
43404                     var t = targets_1[_i];
43405                     for (var _a = 0, sources_1 = sources; _a < sources_1.length; _a++) {
43406                         var s = sources_1[_a];
43407                         if (matches(s, t)) {
43408                             inferFromTypes(s, t);
43409                             matchedSources = ts.appendIfUnique(matchedSources, s);
43410                             matchedTargets = ts.appendIfUnique(matchedTargets, t);
43411                         }
43412                     }
43413                 }
43414                 return [
43415                     matchedSources ? ts.filter(sources, function (t) { return !ts.contains(matchedSources, t); }) : sources,
43416                     matchedTargets ? ts.filter(targets, function (t) { return !ts.contains(matchedTargets, t); }) : targets,
43417                 ];
43418             }
43419             function inferFromTypeArguments(sourceTypes, targetTypes, variances) {
43420                 var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length;
43421                 for (var i = 0; i < count; i++) {
43422                     if (i < variances.length && (variances[i] & 7) === 2) {
43423                         inferFromContravariantTypes(sourceTypes[i], targetTypes[i]);
43424                     }
43425                     else {
43426                         inferFromTypes(sourceTypes[i], targetTypes[i]);
43427                     }
43428                 }
43429             }
43430             function inferFromContravariantTypes(source, target) {
43431                 if (strictFunctionTypes || priority & 256) {
43432                     contravariant = !contravariant;
43433                     inferFromTypes(source, target);
43434                     contravariant = !contravariant;
43435                 }
43436                 else {
43437                     inferFromTypes(source, target);
43438                 }
43439             }
43440             function getInferenceInfoForType(type) {
43441                 if (type.flags & 8650752) {
43442                     for (var _i = 0, inferences_2 = inferences; _i < inferences_2.length; _i++) {
43443                         var inference = inferences_2[_i];
43444                         if (type === inference.typeParameter) {
43445                             return inference;
43446                         }
43447                     }
43448                 }
43449                 return undefined;
43450             }
43451             function getSingleTypeVariableFromIntersectionTypes(types) {
43452                 var typeVariable;
43453                 for (var _i = 0, types_14 = types; _i < types_14.length; _i++) {
43454                     var type = types_14[_i];
43455                     var t = type.flags & 2097152 && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); });
43456                     if (!t || typeVariable && t !== typeVariable) {
43457                         return undefined;
43458                     }
43459                     typeVariable = t;
43460                 }
43461                 return typeVariable;
43462             }
43463             function inferToMultipleTypes(source, targets, targetFlags) {
43464                 var typeVariableCount = 0;
43465                 if (targetFlags & 1048576) {
43466                     var nakedTypeVariable = void 0;
43467                     var sources = source.flags & 1048576 ? source.types : [source];
43468                     var matched_1 = new Array(sources.length);
43469                     var inferenceCircularity = false;
43470                     for (var _i = 0, targets_2 = targets; _i < targets_2.length; _i++) {
43471                         var t = targets_2[_i];
43472                         if (getInferenceInfoForType(t)) {
43473                             nakedTypeVariable = t;
43474                             typeVariableCount++;
43475                         }
43476                         else {
43477                             for (var i = 0; i < sources.length; i++) {
43478                                 var saveInferencePriority = inferencePriority;
43479                                 inferencePriority = 512;
43480                                 inferFromTypes(sources[i], t);
43481                                 if (inferencePriority === priority)
43482                                     matched_1[i] = true;
43483                                 inferenceCircularity = inferenceCircularity || inferencePriority === -1;
43484                                 inferencePriority = Math.min(inferencePriority, saveInferencePriority);
43485                             }
43486                         }
43487                     }
43488                     if (typeVariableCount === 0) {
43489                         var intersectionTypeVariable = getSingleTypeVariableFromIntersectionTypes(targets);
43490                         if (intersectionTypeVariable) {
43491                             inferWithPriority(source, intersectionTypeVariable, 1);
43492                         }
43493                         return;
43494                     }
43495                     if (typeVariableCount === 1 && !inferenceCircularity) {
43496                         var unmatched = ts.flatMap(sources, function (s, i) { return matched_1[i] ? undefined : s; });
43497                         if (unmatched.length) {
43498                             inferFromTypes(getUnionType(unmatched), nakedTypeVariable);
43499                             return;
43500                         }
43501                     }
43502                 }
43503                 else {
43504                     for (var _a = 0, targets_3 = targets; _a < targets_3.length; _a++) {
43505                         var t = targets_3[_a];
43506                         if (getInferenceInfoForType(t)) {
43507                             typeVariableCount++;
43508                         }
43509                         else {
43510                             inferFromTypes(source, t);
43511                         }
43512                     }
43513                 }
43514                 if (targetFlags & 2097152 ? typeVariableCount === 1 : typeVariableCount > 0) {
43515                     for (var _b = 0, targets_4 = targets; _b < targets_4.length; _b++) {
43516                         var t = targets_4[_b];
43517                         if (getInferenceInfoForType(t)) {
43518                             inferWithPriority(source, t, 1);
43519                         }
43520                     }
43521                 }
43522             }
43523             function inferToMappedType(source, target, constraintType) {
43524                 if (constraintType.flags & 1048576) {
43525                     var result = false;
43526                     for (var _i = 0, _a = constraintType.types; _i < _a.length; _i++) {
43527                         var type = _a[_i];
43528                         result = inferToMappedType(source, target, type) || result;
43529                     }
43530                     return result;
43531                 }
43532                 if (constraintType.flags & 4194304) {
43533                     var inference = getInferenceInfoForType(constraintType.type);
43534                     if (inference && !inference.isFixed && !isFromInferenceBlockedSource(source)) {
43535                         var inferredType = inferTypeForHomomorphicMappedType(source, target, constraintType);
43536                         if (inferredType) {
43537                             inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 2097152 ?
43538                                 4 :
43539                                 2);
43540                         }
43541                     }
43542                     return true;
43543                 }
43544                 if (constraintType.flags & 262144) {
43545                     inferWithPriority(getIndexType(source), constraintType, 8);
43546                     var extendedConstraint = getConstraintOfType(constraintType);
43547                     if (extendedConstraint && inferToMappedType(source, target, extendedConstraint)) {
43548                         return true;
43549                     }
43550                     var propTypes = ts.map(getPropertiesOfType(source), getTypeOfSymbol);
43551                     var stringIndexType = getIndexTypeOfType(source, 0);
43552                     var numberIndexInfo = getNonEnumNumberIndexInfo(source);
43553                     var numberIndexType = numberIndexInfo && numberIndexInfo.type;
43554                     inferFromTypes(getUnionType(ts.append(ts.append(propTypes, stringIndexType), numberIndexType)), getTemplateTypeFromMappedType(target));
43555                     return true;
43556                 }
43557                 return false;
43558             }
43559             function inferFromObjectTypes(source, target) {
43560                 var isNonConstructorObject = target.flags & 524288 &&
43561                     !(ts.getObjectFlags(target) & 16 && target.symbol && target.symbol.flags & 32);
43562                 var symbolOrType = isNonConstructorObject ? isTupleType(target) ? target.target : target.symbol : undefined;
43563                 if (symbolOrType) {
43564                     if (ts.contains(symbolOrTypeStack, symbolOrType)) {
43565                         inferencePriority = -1;
43566                         return;
43567                     }
43568                     (symbolOrTypeStack || (symbolOrTypeStack = [])).push(symbolOrType);
43569                     inferFromObjectTypesWorker(source, target);
43570                     symbolOrTypeStack.pop();
43571                 }
43572                 else {
43573                     inferFromObjectTypesWorker(source, target);
43574                 }
43575             }
43576             function inferFromObjectTypesWorker(source, target) {
43577                 if (ts.getObjectFlags(source) & 4 && ts.getObjectFlags(target) & 4 && (source.target === target.target || isArrayType(source) && isArrayType(target))) {
43578                     inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target));
43579                     return;
43580                 }
43581                 if (isGenericMappedType(source) && isGenericMappedType(target)) {
43582                     inferFromTypes(getConstraintTypeFromMappedType(source), getConstraintTypeFromMappedType(target));
43583                     inferFromTypes(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target));
43584                 }
43585                 if (ts.getObjectFlags(target) & 32) {
43586                     var constraintType = getConstraintTypeFromMappedType(target);
43587                     if (inferToMappedType(source, target, constraintType)) {
43588                         return;
43589                     }
43590                 }
43591                 if (!typesDefinitelyUnrelated(source, target)) {
43592                     if (isArrayType(source) || isTupleType(source)) {
43593                         if (isTupleType(target)) {
43594                             var sourceLength = isTupleType(source) ? getLengthOfTupleType(source) : 0;
43595                             var targetLength = getLengthOfTupleType(target);
43596                             var sourceRestType = isTupleType(source) ? getRestTypeOfTupleType(source) : getElementTypeOfArrayType(source);
43597                             var targetRestType = getRestTypeOfTupleType(target);
43598                             var fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength;
43599                             for (var i = 0; i < fixedLength; i++) {
43600                                 inferFromTypes(i < sourceLength ? getTypeArguments(source)[i] : sourceRestType, getTypeArguments(target)[i]);
43601                             }
43602                             if (targetRestType) {
43603                                 var types = fixedLength < sourceLength ? getTypeArguments(source).slice(fixedLength, sourceLength) : [];
43604                                 if (sourceRestType) {
43605                                     types.push(sourceRestType);
43606                                 }
43607                                 if (types.length) {
43608                                     inferFromTypes(getUnionType(types), targetRestType);
43609                                 }
43610                             }
43611                             return;
43612                         }
43613                         if (isArrayType(target)) {
43614                             inferFromIndexTypes(source, target);
43615                             return;
43616                         }
43617                     }
43618                     inferFromProperties(source, target);
43619                     inferFromSignatures(source, target, 0);
43620                     inferFromSignatures(source, target, 1);
43621                     inferFromIndexTypes(source, target);
43622                 }
43623             }
43624             function inferFromProperties(source, target) {
43625                 var properties = getPropertiesOfObjectType(target);
43626                 for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) {
43627                     var targetProp = properties_3[_i];
43628                     var sourceProp = getPropertyOfType(source, targetProp.escapedName);
43629                     if (sourceProp) {
43630                         inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp));
43631                     }
43632                 }
43633             }
43634             function inferFromSignatures(source, target, kind) {
43635                 var sourceSignatures = getSignaturesOfType(source, kind);
43636                 var targetSignatures = getSignaturesOfType(target, kind);
43637                 var sourceLen = sourceSignatures.length;
43638                 var targetLen = targetSignatures.length;
43639                 var len = sourceLen < targetLen ? sourceLen : targetLen;
43640                 var skipParameters = !!(ts.getObjectFlags(source) & 2097152);
43641                 for (var i = 0; i < len; i++) {
43642                     inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i]), skipParameters);
43643                 }
43644             }
43645             function inferFromSignature(source, target, skipParameters) {
43646                 if (!skipParameters) {
43647                     var saveBivariant = bivariant;
43648                     var kind = target.declaration ? target.declaration.kind : 0;
43649                     bivariant = bivariant || kind === 161 || kind === 160 || kind === 162;
43650                     applyToParameterTypes(source, target, inferFromContravariantTypes);
43651                     bivariant = saveBivariant;
43652                 }
43653                 applyToReturnTypes(source, target, inferFromTypes);
43654             }
43655             function inferFromIndexTypes(source, target) {
43656                 var targetStringIndexType = getIndexTypeOfType(target, 0);
43657                 if (targetStringIndexType) {
43658                     var sourceIndexType = getIndexTypeOfType(source, 0) ||
43659                         getImplicitIndexTypeOfType(source, 0);
43660                     if (sourceIndexType) {
43661                         inferFromTypes(sourceIndexType, targetStringIndexType);
43662                     }
43663                 }
43664                 var targetNumberIndexType = getIndexTypeOfType(target, 1);
43665                 if (targetNumberIndexType) {
43666                     var sourceIndexType = getIndexTypeOfType(source, 1) ||
43667                         getIndexTypeOfType(source, 0) ||
43668                         getImplicitIndexTypeOfType(source, 1);
43669                     if (sourceIndexType) {
43670                         inferFromTypes(sourceIndexType, targetNumberIndexType);
43671                     }
43672                 }
43673             }
43674         }
43675         function isTypeOrBaseIdenticalTo(s, t) {
43676             return isTypeIdenticalTo(s, t) || !!(t.flags & 4 && s.flags & 128 || t.flags & 8 && s.flags & 256);
43677         }
43678         function isTypeCloselyMatchedBy(s, t) {
43679             return !!(s.flags & 524288 && t.flags & 524288 && s.symbol && s.symbol === t.symbol ||
43680                 s.aliasSymbol && s.aliasTypeArguments && s.aliasSymbol === t.aliasSymbol);
43681         }
43682         function hasPrimitiveConstraint(type) {
43683             var constraint = getConstraintOfTypeParameter(type);
43684             return !!constraint && maybeTypeOfKind(constraint.flags & 16777216 ? getDefaultConstraintOfConditionalType(constraint) : constraint, 131068 | 4194304);
43685         }
43686         function isObjectLiteralType(type) {
43687             return !!(ts.getObjectFlags(type) & 128);
43688         }
43689         function isObjectOrArrayLiteralType(type) {
43690             return !!(ts.getObjectFlags(type) & (128 | 65536));
43691         }
43692         function unionObjectAndArrayLiteralCandidates(candidates) {
43693             if (candidates.length > 1) {
43694                 var objectLiterals = ts.filter(candidates, isObjectOrArrayLiteralType);
43695                 if (objectLiterals.length) {
43696                     var literalsType = getUnionType(objectLiterals, 2);
43697                     return ts.concatenate(ts.filter(candidates, function (t) { return !isObjectOrArrayLiteralType(t); }), [literalsType]);
43698                 }
43699             }
43700             return candidates;
43701         }
43702         function getContravariantInference(inference) {
43703             return inference.priority & 104 ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates);
43704         }
43705         function getCovariantInference(inference, signature) {
43706             var candidates = unionObjectAndArrayLiteralCandidates(inference.candidates);
43707             var primitiveConstraint = hasPrimitiveConstraint(inference.typeParameter);
43708             var widenLiteralTypes = !primitiveConstraint && inference.topLevel &&
43709                 (inference.isFixed || !isTypeParameterAtTopLevel(getReturnTypeOfSignature(signature), inference.typeParameter));
43710             var baseCandidates = primitiveConstraint ? ts.sameMap(candidates, getRegularTypeOfLiteralType) :
43711                 widenLiteralTypes ? ts.sameMap(candidates, getWidenedLiteralType) :
43712                     candidates;
43713             var unwidenedType = inference.priority & 104 ?
43714                 getUnionType(baseCandidates, 2) :
43715                 getCommonSupertype(baseCandidates);
43716             return getWidenedType(unwidenedType);
43717         }
43718         function getInferredType(context, index) {
43719             var inference = context.inferences[index];
43720             if (!inference.inferredType) {
43721                 var inferredType = void 0;
43722                 var signature = context.signature;
43723                 if (signature) {
43724                     var inferredCovariantType = inference.candidates ? getCovariantInference(inference, signature) : undefined;
43725                     if (inference.contraCandidates) {
43726                         var inferredContravariantType = getContravariantInference(inference);
43727                         inferredType = inferredCovariantType && !(inferredCovariantType.flags & 131072) &&
43728                             isTypeSubtypeOf(inferredCovariantType, inferredContravariantType) ?
43729                             inferredCovariantType : inferredContravariantType;
43730                     }
43731                     else if (inferredCovariantType) {
43732                         inferredType = inferredCovariantType;
43733                     }
43734                     else if (context.flags & 1) {
43735                         inferredType = silentNeverType;
43736                     }
43737                     else {
43738                         var defaultType = getDefaultFromTypeParameter(inference.typeParameter);
43739                         if (defaultType) {
43740                             inferredType = instantiateType(defaultType, mergeTypeMappers(createBackreferenceMapper(context, index), context.nonFixingMapper));
43741                         }
43742                     }
43743                 }
43744                 else {
43745                     inferredType = getTypeFromInference(inference);
43746                 }
43747                 inference.inferredType = inferredType || getDefaultTypeArgumentType(!!(context.flags & 2));
43748                 var constraint = getConstraintOfTypeParameter(inference.typeParameter);
43749                 if (constraint) {
43750                     var instantiatedConstraint = instantiateType(constraint, context.nonFixingMapper);
43751                     if (!inferredType || !context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
43752                         inference.inferredType = inferredType = instantiatedConstraint;
43753                     }
43754                 }
43755             }
43756             return inference.inferredType;
43757         }
43758         function getDefaultTypeArgumentType(isInJavaScriptFile) {
43759             return isInJavaScriptFile ? anyType : unknownType;
43760         }
43761         function getInferredTypes(context) {
43762             var result = [];
43763             for (var i = 0; i < context.inferences.length; i++) {
43764                 result.push(getInferredType(context, i));
43765             }
43766             return result;
43767         }
43768         function getCannotFindNameDiagnosticForName(node) {
43769             switch (node.escapedText) {
43770                 case "document":
43771                 case "console":
43772                     return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom;
43773                 case "$":
43774                     return compilerOptions.types
43775                         ? 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
43776                         : ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery;
43777                 case "describe":
43778                 case "suite":
43779                 case "it":
43780                 case "test":
43781                     return compilerOptions.types
43782                         ? 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
43783                         : 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;
43784                 case "process":
43785                 case "require":
43786                 case "Buffer":
43787                 case "module":
43788                     return compilerOptions.types
43789                         ? 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
43790                         : ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode;
43791                 case "Map":
43792                 case "Set":
43793                 case "Promise":
43794                 case "Symbol":
43795                 case "WeakMap":
43796                 case "WeakSet":
43797                 case "Iterator":
43798                 case "AsyncIterator":
43799                     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;
43800                 default:
43801                     if (node.parent.kind === 282) {
43802                         return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer;
43803                     }
43804                     else {
43805                         return ts.Diagnostics.Cannot_find_name_0;
43806                     }
43807             }
43808         }
43809         function getResolvedSymbol(node) {
43810             var links = getNodeLinks(node);
43811             if (!links.resolvedSymbol) {
43812                 links.resolvedSymbol = !ts.nodeIsMissing(node) &&
43813                     resolveName(node, node.escapedText, 111551 | 1048576, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), false, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol;
43814             }
43815             return links.resolvedSymbol;
43816         }
43817         function isInTypeQuery(node) {
43818             return !!ts.findAncestor(node, function (n) { return n.kind === 172 ? true : n.kind === 75 || n.kind === 153 ? false : "quit"; });
43819         }
43820         function getFlowCacheKey(node, declaredType, initialType, flowContainer) {
43821             switch (node.kind) {
43822                 case 75:
43823                     var symbol = getResolvedSymbol(node);
43824                     return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined;
43825                 case 104:
43826                     return "0";
43827                 case 218:
43828                 case 200:
43829                     return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer);
43830                 case 194:
43831                 case 195:
43832                     var propName = getAccessedPropertyName(node);
43833                     if (propName !== undefined) {
43834                         var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer);
43835                         return key && key + "." + propName;
43836                     }
43837             }
43838             return undefined;
43839         }
43840         function isMatchingReference(source, target) {
43841             switch (target.kind) {
43842                 case 200:
43843                 case 218:
43844                     return isMatchingReference(source, target.expression);
43845             }
43846             switch (source.kind) {
43847                 case 75:
43848                     return target.kind === 75 && getResolvedSymbol(source) === getResolvedSymbol(target) ||
43849                         (target.kind === 242 || target.kind === 191) &&
43850                             getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target);
43851                 case 104:
43852                     return target.kind === 104;
43853                 case 102:
43854                     return target.kind === 102;
43855                 case 218:
43856                 case 200:
43857                     return isMatchingReference(source.expression, target);
43858                 case 194:
43859                 case 195:
43860                     return ts.isAccessExpression(target) &&
43861                         getAccessedPropertyName(source) === getAccessedPropertyName(target) &&
43862                         isMatchingReference(source.expression, target.expression);
43863             }
43864             return false;
43865         }
43866         function containsTruthyCheck(source, target) {
43867             return isMatchingReference(source, target) ||
43868                 (target.kind === 209 && target.operatorToken.kind === 55 &&
43869                     (containsTruthyCheck(source, target.left) || containsTruthyCheck(source, target.right)));
43870         }
43871         function getAccessedPropertyName(access) {
43872             return access.kind === 194 ? access.name.escapedText :
43873                 ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) :
43874                     undefined;
43875         }
43876         function containsMatchingReference(source, target) {
43877             while (ts.isAccessExpression(source)) {
43878                 source = source.expression;
43879                 if (isMatchingReference(source, target)) {
43880                     return true;
43881                 }
43882             }
43883             return false;
43884         }
43885         function optionalChainContainsReference(source, target) {
43886             while (ts.isOptionalChain(source)) {
43887                 source = source.expression;
43888                 if (isMatchingReference(source, target)) {
43889                     return true;
43890                 }
43891             }
43892             return false;
43893         }
43894         function isDiscriminantProperty(type, name) {
43895             if (type && type.flags & 1048576) {
43896                 var prop = getUnionOrIntersectionProperty(type, name);
43897                 if (prop && ts.getCheckFlags(prop) & 2) {
43898                     if (prop.isDiscriminantProperty === undefined) {
43899                         prop.isDiscriminantProperty =
43900                             (prop.checkFlags & 192) === 192 &&
43901                                 !maybeTypeOfKind(getTypeOfSymbol(prop), 63176704);
43902                     }
43903                     return !!prop.isDiscriminantProperty;
43904                 }
43905             }
43906             return false;
43907         }
43908         function findDiscriminantProperties(sourceProperties, target) {
43909             var result;
43910             for (var _i = 0, sourceProperties_2 = sourceProperties; _i < sourceProperties_2.length; _i++) {
43911                 var sourceProperty = sourceProperties_2[_i];
43912                 if (isDiscriminantProperty(target, sourceProperty.escapedName)) {
43913                     if (result) {
43914                         result.push(sourceProperty);
43915                         continue;
43916                     }
43917                     result = [sourceProperty];
43918                 }
43919             }
43920             return result;
43921         }
43922         function isOrContainsMatchingReference(source, target) {
43923             return isMatchingReference(source, target) || containsMatchingReference(source, target);
43924         }
43925         function hasMatchingArgument(callExpression, reference) {
43926             if (callExpression.arguments) {
43927                 for (var _i = 0, _a = callExpression.arguments; _i < _a.length; _i++) {
43928                     var argument = _a[_i];
43929                     if (isOrContainsMatchingReference(reference, argument)) {
43930                         return true;
43931                     }
43932                 }
43933             }
43934             if (callExpression.expression.kind === 194 &&
43935                 isOrContainsMatchingReference(reference, callExpression.expression.expression)) {
43936                 return true;
43937             }
43938             return false;
43939         }
43940         function getFlowNodeId(flow) {
43941             if (!flow.id || flow.id < 0) {
43942                 flow.id = nextFlowId;
43943                 nextFlowId++;
43944             }
43945             return flow.id;
43946         }
43947         function typeMaybeAssignableTo(source, target) {
43948             if (!(source.flags & 1048576)) {
43949                 return isTypeAssignableTo(source, target);
43950             }
43951             for (var _i = 0, _a = source.types; _i < _a.length; _i++) {
43952                 var t = _a[_i];
43953                 if (isTypeAssignableTo(t, target)) {
43954                     return true;
43955                 }
43956             }
43957             return false;
43958         }
43959         function getAssignmentReducedType(declaredType, assignedType) {
43960             if (declaredType !== assignedType) {
43961                 if (assignedType.flags & 131072) {
43962                     return assignedType;
43963                 }
43964                 var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); });
43965                 if (assignedType.flags & 512 && isFreshLiteralType(assignedType)) {
43966                     reducedType = mapType(reducedType, getFreshTypeOfLiteralType);
43967                 }
43968                 if (isTypeAssignableTo(assignedType, reducedType)) {
43969                     return reducedType;
43970                 }
43971             }
43972             return declaredType;
43973         }
43974         function getTypeFactsOfTypes(types) {
43975             var result = 0;
43976             for (var _i = 0, types_15 = types; _i < types_15.length; _i++) {
43977                 var t = types_15[_i];
43978                 result |= getTypeFacts(t);
43979             }
43980             return result;
43981         }
43982         function isFunctionObjectType(type) {
43983             var resolved = resolveStructuredTypeMembers(type);
43984             return !!(resolved.callSignatures.length || resolved.constructSignatures.length ||
43985                 resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType));
43986         }
43987         function getTypeFacts(type) {
43988             var flags = type.flags;
43989             if (flags & 4) {
43990                 return strictNullChecks ? 16317953 : 16776705;
43991             }
43992             if (flags & 128) {
43993                 var isEmpty = type.value === "";
43994                 return strictNullChecks ?
43995                     isEmpty ? 12123649 : 7929345 :
43996                     isEmpty ? 12582401 : 16776705;
43997             }
43998             if (flags & (8 | 32)) {
43999                 return strictNullChecks ? 16317698 : 16776450;
44000             }
44001             if (flags & 256) {
44002                 var isZero = type.value === 0;
44003                 return strictNullChecks ?
44004                     isZero ? 12123394 : 7929090 :
44005                     isZero ? 12582146 : 16776450;
44006             }
44007             if (flags & 64) {
44008                 return strictNullChecks ? 16317188 : 16775940;
44009             }
44010             if (flags & 2048) {
44011                 var isZero = isZeroBigInt(type);
44012                 return strictNullChecks ?
44013                     isZero ? 12122884 : 7928580 :
44014                     isZero ? 12581636 : 16775940;
44015             }
44016             if (flags & 16) {
44017                 return strictNullChecks ? 16316168 : 16774920;
44018             }
44019             if (flags & 528) {
44020                 return strictNullChecks ?
44021                     (type === falseType || type === regularFalseType) ? 12121864 : 7927560 :
44022                     (type === falseType || type === regularFalseType) ? 12580616 : 16774920;
44023             }
44024             if (flags & 524288) {
44025                 return ts.getObjectFlags(type) & 16 && isEmptyObjectType(type) ?
44026                     strictNullChecks ? 16318463 : 16777215 :
44027                     isFunctionObjectType(type) ?
44028                         strictNullChecks ? 7880640 : 16728000 :
44029                         strictNullChecks ? 7888800 : 16736160;
44030             }
44031             if (flags & (16384 | 32768)) {
44032                 return 9830144;
44033             }
44034             if (flags & 65536) {
44035                 return 9363232;
44036             }
44037             if (flags & 12288) {
44038                 return strictNullChecks ? 7925520 : 16772880;
44039             }
44040             if (flags & 67108864) {
44041                 return strictNullChecks ? 7888800 : 16736160;
44042             }
44043             if (flags & 131072) {
44044                 return 0;
44045             }
44046             if (flags & 63176704) {
44047                 return getTypeFacts(getBaseConstraintOfType(type) || unknownType);
44048             }
44049             if (flags & 3145728) {
44050                 return getTypeFactsOfTypes(type.types);
44051             }
44052             return 16777215;
44053         }
44054         function getTypeWithFacts(type, include) {
44055             return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
44056         }
44057         function getTypeWithDefault(type, defaultExpression) {
44058             if (defaultExpression) {
44059                 var defaultType = getTypeOfExpression(defaultExpression);
44060                 return getUnionType([getTypeWithFacts(type, 524288), defaultType]);
44061             }
44062             return type;
44063         }
44064         function getTypeOfDestructuredProperty(type, name) {
44065             var nameType = getLiteralTypeFromPropertyName(name);
44066             if (!isTypeUsableAsPropertyName(nameType))
44067                 return errorType;
44068             var text = getPropertyNameFromType(nameType);
44069             return getConstraintForLocation(getTypeOfPropertyOfType(type, text), name) ||
44070                 isNumericLiteralName(text) && getIndexTypeOfType(type, 1) ||
44071                 getIndexTypeOfType(type, 0) ||
44072                 errorType;
44073         }
44074         function getTypeOfDestructuredArrayElement(type, index) {
44075             return everyType(type, isTupleLikeType) && getTupleElementType(type, index) ||
44076                 checkIteratedTypeOrElementType(65, type, undefinedType, undefined) ||
44077                 errorType;
44078         }
44079         function getTypeOfDestructuredSpreadExpression(type) {
44080             return createArrayType(checkIteratedTypeOrElementType(65, type, undefinedType, undefined) || errorType);
44081         }
44082         function getAssignedTypeOfBinaryExpression(node) {
44083             var isDestructuringDefaultAssignment = node.parent.kind === 192 && isDestructuringAssignmentTarget(node.parent) ||
44084                 node.parent.kind === 281 && isDestructuringAssignmentTarget(node.parent.parent);
44085             return isDestructuringDefaultAssignment ?
44086                 getTypeWithDefault(getAssignedType(node), node.right) :
44087                 getTypeOfExpression(node.right);
44088         }
44089         function isDestructuringAssignmentTarget(parent) {
44090             return parent.parent.kind === 209 && parent.parent.left === parent ||
44091                 parent.parent.kind === 232 && parent.parent.initializer === parent;
44092         }
44093         function getAssignedTypeOfArrayLiteralElement(node, element) {
44094             return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element));
44095         }
44096         function getAssignedTypeOfSpreadExpression(node) {
44097             return getTypeOfDestructuredSpreadExpression(getAssignedType(node.parent));
44098         }
44099         function getAssignedTypeOfPropertyAssignment(node) {
44100             return getTypeOfDestructuredProperty(getAssignedType(node.parent), node.name);
44101         }
44102         function getAssignedTypeOfShorthandPropertyAssignment(node) {
44103             return getTypeWithDefault(getAssignedTypeOfPropertyAssignment(node), node.objectAssignmentInitializer);
44104         }
44105         function getAssignedType(node) {
44106             var parent = node.parent;
44107             switch (parent.kind) {
44108                 case 231:
44109                     return stringType;
44110                 case 232:
44111                     return checkRightHandSideOfForOf(parent) || errorType;
44112                 case 209:
44113                     return getAssignedTypeOfBinaryExpression(parent);
44114                 case 203:
44115                     return undefinedType;
44116                 case 192:
44117                     return getAssignedTypeOfArrayLiteralElement(parent, node);
44118                 case 213:
44119                     return getAssignedTypeOfSpreadExpression(parent);
44120                 case 281:
44121                     return getAssignedTypeOfPropertyAssignment(parent);
44122                 case 282:
44123                     return getAssignedTypeOfShorthandPropertyAssignment(parent);
44124             }
44125             return errorType;
44126         }
44127         function getInitialTypeOfBindingElement(node) {
44128             var pattern = node.parent;
44129             var parentType = getInitialType(pattern.parent);
44130             var type = pattern.kind === 189 ?
44131                 getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) :
44132                 !node.dotDotDotToken ?
44133                     getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) :
44134                     getTypeOfDestructuredSpreadExpression(parentType);
44135             return getTypeWithDefault(type, node.initializer);
44136         }
44137         function getTypeOfInitializer(node) {
44138             var links = getNodeLinks(node);
44139             return links.resolvedType || getTypeOfExpression(node);
44140         }
44141         function getInitialTypeOfVariableDeclaration(node) {
44142             if (node.initializer) {
44143                 return getTypeOfInitializer(node.initializer);
44144             }
44145             if (node.parent.parent.kind === 231) {
44146                 return stringType;
44147             }
44148             if (node.parent.parent.kind === 232) {
44149                 return checkRightHandSideOfForOf(node.parent.parent) || errorType;
44150             }
44151             return errorType;
44152         }
44153         function getInitialType(node) {
44154             return node.kind === 242 ?
44155                 getInitialTypeOfVariableDeclaration(node) :
44156                 getInitialTypeOfBindingElement(node);
44157         }
44158         function isEmptyArrayAssignment(node) {
44159             return node.kind === 242 && node.initializer &&
44160                 isEmptyArrayLiteral(node.initializer) ||
44161                 node.kind !== 191 && node.parent.kind === 209 &&
44162                     isEmptyArrayLiteral(node.parent.right);
44163         }
44164         function getReferenceCandidate(node) {
44165             switch (node.kind) {
44166                 case 200:
44167                     return getReferenceCandidate(node.expression);
44168                 case 209:
44169                     switch (node.operatorToken.kind) {
44170                         case 62:
44171                             return getReferenceCandidate(node.left);
44172                         case 27:
44173                             return getReferenceCandidate(node.right);
44174                     }
44175             }
44176             return node;
44177         }
44178         function getReferenceRoot(node) {
44179             var parent = node.parent;
44180             return parent.kind === 200 ||
44181                 parent.kind === 209 && parent.operatorToken.kind === 62 && parent.left === node ||
44182                 parent.kind === 209 && parent.operatorToken.kind === 27 && parent.right === node ?
44183                 getReferenceRoot(parent) : node;
44184         }
44185         function getTypeOfSwitchClause(clause) {
44186             if (clause.kind === 277) {
44187                 return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression));
44188             }
44189             return neverType;
44190         }
44191         function getSwitchClauseTypes(switchStatement) {
44192             var links = getNodeLinks(switchStatement);
44193             if (!links.switchTypes) {
44194                 links.switchTypes = [];
44195                 for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) {
44196                     var clause = _a[_i];
44197                     links.switchTypes.push(getTypeOfSwitchClause(clause));
44198                 }
44199             }
44200             return links.switchTypes;
44201         }
44202         function getSwitchClauseTypeOfWitnesses(switchStatement, retainDefault) {
44203             var witnesses = [];
44204             for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) {
44205                 var clause = _a[_i];
44206                 if (clause.kind === 277) {
44207                     if (ts.isStringLiteralLike(clause.expression)) {
44208                         witnesses.push(clause.expression.text);
44209                         continue;
44210                     }
44211                     return ts.emptyArray;
44212                 }
44213                 if (retainDefault)
44214                     witnesses.push(undefined);
44215             }
44216             return witnesses;
44217         }
44218         function eachTypeContainedIn(source, types) {
44219             return source.flags & 1048576 ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source);
44220         }
44221         function isTypeSubsetOf(source, target) {
44222             return source === target || target.flags & 1048576 && isTypeSubsetOfUnion(source, target);
44223         }
44224         function isTypeSubsetOfUnion(source, target) {
44225             if (source.flags & 1048576) {
44226                 for (var _i = 0, _a = source.types; _i < _a.length; _i++) {
44227                     var t = _a[_i];
44228                     if (!containsType(target.types, t)) {
44229                         return false;
44230                     }
44231                 }
44232                 return true;
44233             }
44234             if (source.flags & 1024 && getBaseTypeOfEnumLiteralType(source) === target) {
44235                 return true;
44236             }
44237             return containsType(target.types, source);
44238         }
44239         function forEachType(type, f) {
44240             return type.flags & 1048576 ? ts.forEach(type.types, f) : f(type);
44241         }
44242         function everyType(type, f) {
44243             return type.flags & 1048576 ? ts.every(type.types, f) : f(type);
44244         }
44245         function filterType(type, f) {
44246             if (type.flags & 1048576) {
44247                 var types = type.types;
44248                 var filtered = ts.filter(types, f);
44249                 return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.objectFlags);
44250             }
44251             return type.flags & 131072 || f(type) ? type : neverType;
44252         }
44253         function countTypes(type) {
44254             return type.flags & 1048576 ? type.types.length : 1;
44255         }
44256         function mapType(type, mapper, noReductions) {
44257             if (type.flags & 131072) {
44258                 return type;
44259             }
44260             if (!(type.flags & 1048576)) {
44261                 return mapper(type);
44262             }
44263             var mappedTypes;
44264             for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
44265                 var t = _a[_i];
44266                 var mapped = mapper(t);
44267                 if (mapped) {
44268                     if (!mappedTypes) {
44269                         mappedTypes = [mapped];
44270                     }
44271                     else {
44272                         mappedTypes.push(mapped);
44273                     }
44274                 }
44275             }
44276             return mappedTypes && getUnionType(mappedTypes, noReductions ? 0 : 1);
44277         }
44278         function extractTypesOfKind(type, kind) {
44279             return filterType(type, function (t) { return (t.flags & kind) !== 0; });
44280         }
44281         function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) {
44282             if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 128) ||
44283                 isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 256) ||
44284                 isTypeSubsetOf(bigintType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 2048)) {
44285                 return mapType(typeWithPrimitives, function (t) {
44286                     return t.flags & 4 ? extractTypesOfKind(typeWithLiterals, 4 | 128) :
44287                         t.flags & 8 ? extractTypesOfKind(typeWithLiterals, 8 | 256) :
44288                             t.flags & 64 ? extractTypesOfKind(typeWithLiterals, 64 | 2048) : t;
44289                 });
44290             }
44291             return typeWithPrimitives;
44292         }
44293         function isIncomplete(flowType) {
44294             return flowType.flags === 0;
44295         }
44296         function getTypeFromFlowType(flowType) {
44297             return flowType.flags === 0 ? flowType.type : flowType;
44298         }
44299         function createFlowType(type, incomplete) {
44300             return incomplete ? { flags: 0, type: type } : type;
44301         }
44302         function createEvolvingArrayType(elementType) {
44303             var result = createObjectType(256);
44304             result.elementType = elementType;
44305             return result;
44306         }
44307         function getEvolvingArrayType(elementType) {
44308             return evolvingArrayTypes[elementType.id] || (evolvingArrayTypes[elementType.id] = createEvolvingArrayType(elementType));
44309         }
44310         function addEvolvingArrayElementType(evolvingArrayType, node) {
44311             var elementType = getBaseTypeOfLiteralType(getContextFreeTypeOfExpression(node));
44312             return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType]));
44313         }
44314         function createFinalArrayType(elementType) {
44315             return elementType.flags & 131072 ?
44316                 autoArrayType :
44317                 createArrayType(elementType.flags & 1048576 ?
44318                     getUnionType(elementType.types, 2) :
44319                     elementType);
44320         }
44321         function getFinalArrayType(evolvingArrayType) {
44322             return evolvingArrayType.finalArrayType || (evolvingArrayType.finalArrayType = createFinalArrayType(evolvingArrayType.elementType));
44323         }
44324         function finalizeEvolvingArrayType(type) {
44325             return ts.getObjectFlags(type) & 256 ? getFinalArrayType(type) : type;
44326         }
44327         function getElementTypeOfEvolvingArrayType(type) {
44328             return ts.getObjectFlags(type) & 256 ? type.elementType : neverType;
44329         }
44330         function isEvolvingArrayTypeList(types) {
44331             var hasEvolvingArrayType = false;
44332             for (var _i = 0, types_16 = types; _i < types_16.length; _i++) {
44333                 var t = types_16[_i];
44334                 if (!(t.flags & 131072)) {
44335                     if (!(ts.getObjectFlags(t) & 256)) {
44336                         return false;
44337                     }
44338                     hasEvolvingArrayType = true;
44339                 }
44340             }
44341             return hasEvolvingArrayType;
44342         }
44343         function getUnionOrEvolvingArrayType(types, subtypeReduction) {
44344             return isEvolvingArrayTypeList(types) ?
44345                 getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType))) :
44346                 getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction);
44347         }
44348         function isEvolvingArrayOperationTarget(node) {
44349             var root = getReferenceRoot(node);
44350             var parent = root.parent;
44351             var isLengthPushOrUnshift = ts.isPropertyAccessExpression(parent) && (parent.name.escapedText === "length" ||
44352                 parent.parent.kind === 196
44353                     && ts.isIdentifier(parent.name)
44354                     && ts.isPushOrUnshiftIdentifier(parent.name));
44355             var isElementAssignment = parent.kind === 195 &&
44356                 parent.expression === root &&
44357                 parent.parent.kind === 209 &&
44358                 parent.parent.operatorToken.kind === 62 &&
44359                 parent.parent.left === parent &&
44360                 !ts.isAssignmentTarget(parent.parent) &&
44361                 isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296);
44362             return isLengthPushOrUnshift || isElementAssignment;
44363         }
44364         function isDeclarationWithExplicitTypeAnnotation(declaration) {
44365             return (declaration.kind === 242 || declaration.kind === 156 ||
44366                 declaration.kind === 159 || declaration.kind === 158) &&
44367                 !!ts.getEffectiveTypeAnnotationNode(declaration);
44368         }
44369         function getExplicitTypeOfSymbol(symbol, diagnostic) {
44370             if (symbol.flags & (16 | 8192 | 32 | 512)) {
44371                 return getTypeOfSymbol(symbol);
44372             }
44373             if (symbol.flags & (3 | 4)) {
44374                 var declaration = symbol.valueDeclaration;
44375                 if (declaration) {
44376                     if (isDeclarationWithExplicitTypeAnnotation(declaration)) {
44377                         return getTypeOfSymbol(symbol);
44378                     }
44379                     if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 232) {
44380                         var statement = declaration.parent.parent;
44381                         var expressionType = getTypeOfDottedName(statement.expression, undefined);
44382                         if (expressionType) {
44383                             var use = statement.awaitModifier ? 15 : 13;
44384                             return checkIteratedTypeOrElementType(use, expressionType, undefinedType, undefined);
44385                         }
44386                     }
44387                     if (diagnostic) {
44388                         ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(declaration, ts.Diagnostics._0_needs_an_explicit_type_annotation, symbolToString(symbol)));
44389                     }
44390                 }
44391             }
44392         }
44393         function getTypeOfDottedName(node, diagnostic) {
44394             if (!(node.flags & 16777216)) {
44395                 switch (node.kind) {
44396                     case 75:
44397                         var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node));
44398                         return getExplicitTypeOfSymbol(symbol.flags & 2097152 ? resolveAlias(symbol) : symbol, diagnostic);
44399                     case 104:
44400                         return getExplicitThisType(node);
44401                     case 102:
44402                         return checkSuperExpression(node);
44403                     case 194:
44404                         var type = getTypeOfDottedName(node.expression, diagnostic);
44405                         var prop = type && getPropertyOfType(type, node.name.escapedText);
44406                         return prop && getExplicitTypeOfSymbol(prop, diagnostic);
44407                     case 200:
44408                         return getTypeOfDottedName(node.expression, diagnostic);
44409                 }
44410             }
44411         }
44412         function getEffectsSignature(node) {
44413             var links = getNodeLinks(node);
44414             var signature = links.effectsSignature;
44415             if (signature === undefined) {
44416                 var funcType = void 0;
44417                 if (node.parent.kind === 226) {
44418                     funcType = getTypeOfDottedName(node.expression, undefined);
44419                 }
44420                 else if (node.expression.kind !== 102) {
44421                     if (ts.isOptionalChain(node)) {
44422                         funcType = checkNonNullType(getOptionalExpressionType(checkExpression(node.expression), node.expression), node.expression);
44423                     }
44424                     else {
44425                         funcType = checkNonNullExpression(node.expression);
44426                     }
44427                 }
44428                 var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0);
44429                 var candidate = signatures.length === 1 && !signatures[0].typeParameters ? signatures[0] :
44430                     ts.some(signatures, hasTypePredicateOrNeverReturnType) ? getResolvedSignature(node) :
44431                         undefined;
44432                 signature = links.effectsSignature = candidate && hasTypePredicateOrNeverReturnType(candidate) ? candidate : unknownSignature;
44433             }
44434             return signature === unknownSignature ? undefined : signature;
44435         }
44436         function hasTypePredicateOrNeverReturnType(signature) {
44437             return !!(getTypePredicateOfSignature(signature) ||
44438                 signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072);
44439         }
44440         function getTypePredicateArgument(predicate, callExpression) {
44441             if (predicate.kind === 1 || predicate.kind === 3) {
44442                 return callExpression.arguments[predicate.parameterIndex];
44443             }
44444             var invokedExpression = ts.skipParentheses(callExpression.expression);
44445             return ts.isAccessExpression(invokedExpression) ? ts.skipParentheses(invokedExpression.expression) : undefined;
44446         }
44447         function reportFlowControlError(node) {
44448             var block = ts.findAncestor(node, ts.isFunctionOrModuleBlock);
44449             var sourceFile = ts.getSourceFileOfNode(node);
44450             var span = ts.getSpanOfTokenAtPosition(sourceFile, block.statements.pos);
44451             diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.The_containing_function_or_module_body_is_too_large_for_control_flow_analysis));
44452         }
44453         function isReachableFlowNode(flow) {
44454             var result = isReachableFlowNodeWorker(flow, false);
44455             lastFlowNode = flow;
44456             lastFlowNodeReachable = result;
44457             return result;
44458         }
44459         function isFalseExpression(expr) {
44460             var node = ts.skipParentheses(expr);
44461             return node.kind === 91 || node.kind === 209 && (node.operatorToken.kind === 55 && (isFalseExpression(node.left) || isFalseExpression(node.right)) ||
44462                 node.operatorToken.kind === 56 && isFalseExpression(node.left) && isFalseExpression(node.right));
44463         }
44464         function isReachableFlowNodeWorker(flow, noCacheCheck) {
44465             while (true) {
44466                 if (flow === lastFlowNode) {
44467                     return lastFlowNodeReachable;
44468                 }
44469                 var flags = flow.flags;
44470                 if (flags & 4096) {
44471                     if (!noCacheCheck) {
44472                         var id = getFlowNodeId(flow);
44473                         var reachable = flowNodeReachable[id];
44474                         return reachable !== undefined ? reachable : (flowNodeReachable[id] = isReachableFlowNodeWorker(flow, true));
44475                     }
44476                     noCacheCheck = false;
44477                 }
44478                 if (flags & (16 | 96 | 256)) {
44479                     flow = flow.antecedent;
44480                 }
44481                 else if (flags & 512) {
44482                     var signature = getEffectsSignature(flow.node);
44483                     if (signature) {
44484                         var predicate = getTypePredicateOfSignature(signature);
44485                         if (predicate && predicate.kind === 3) {
44486                             var predicateArgument = flow.node.arguments[predicate.parameterIndex];
44487                             if (predicateArgument && isFalseExpression(predicateArgument)) {
44488                                 return false;
44489                             }
44490                         }
44491                         if (getReturnTypeOfSignature(signature).flags & 131072) {
44492                             return false;
44493                         }
44494                     }
44495                     flow = flow.antecedent;
44496                 }
44497                 else if (flags & 4) {
44498                     return ts.some(flow.antecedents, function (f) { return isReachableFlowNodeWorker(f, false); });
44499                 }
44500                 else if (flags & 8) {
44501                     flow = flow.antecedents[0];
44502                 }
44503                 else if (flags & 128) {
44504                     if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) {
44505                         return false;
44506                     }
44507                     flow = flow.antecedent;
44508                 }
44509                 else if (flags & 1024) {
44510                     lastFlowNode = undefined;
44511                     var target = flow.target;
44512                     var saveAntecedents = target.antecedents;
44513                     target.antecedents = flow.antecedents;
44514                     var result = isReachableFlowNodeWorker(flow.antecedent, false);
44515                     target.antecedents = saveAntecedents;
44516                     return result;
44517                 }
44518                 else {
44519                     return !(flags & 1);
44520                 }
44521             }
44522         }
44523         function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer, couldBeUninitialized) {
44524             if (initialType === void 0) { initialType = declaredType; }
44525             var key;
44526             var keySet = false;
44527             var flowDepth = 0;
44528             if (flowAnalysisDisabled) {
44529                 return errorType;
44530             }
44531             if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 133970943)) {
44532                 return declaredType;
44533             }
44534             flowInvocationCount++;
44535             var sharedFlowStart = sharedFlowCount;
44536             var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode));
44537             sharedFlowCount = sharedFlowStart;
44538             var resultType = ts.getObjectFlags(evolvedType) & 256 && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType);
44539             if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 218 && getTypeWithFacts(resultType, 2097152).flags & 131072) {
44540                 return declaredType;
44541             }
44542             return resultType;
44543             function getOrSetCacheKey() {
44544                 if (keySet) {
44545                     return key;
44546                 }
44547                 keySet = true;
44548                 return key = getFlowCacheKey(reference, declaredType, initialType, flowContainer);
44549             }
44550             function getTypeAtFlowNode(flow) {
44551                 if (flowDepth === 2000) {
44552                     flowAnalysisDisabled = true;
44553                     reportFlowControlError(reference);
44554                     return errorType;
44555                 }
44556                 flowDepth++;
44557                 while (true) {
44558                     var flags = flow.flags;
44559                     if (flags & 4096) {
44560                         for (var i = sharedFlowStart; i < sharedFlowCount; i++) {
44561                             if (sharedFlowNodes[i] === flow) {
44562                                 flowDepth--;
44563                                 return sharedFlowTypes[i];
44564                             }
44565                         }
44566                     }
44567                     var type = void 0;
44568                     if (flags & 16) {
44569                         type = getTypeAtFlowAssignment(flow);
44570                         if (!type) {
44571                             flow = flow.antecedent;
44572                             continue;
44573                         }
44574                     }
44575                     else if (flags & 512) {
44576                         type = getTypeAtFlowCall(flow);
44577                         if (!type) {
44578                             flow = flow.antecedent;
44579                             continue;
44580                         }
44581                     }
44582                     else if (flags & 96) {
44583                         type = getTypeAtFlowCondition(flow);
44584                     }
44585                     else if (flags & 128) {
44586                         type = getTypeAtSwitchClause(flow);
44587                     }
44588                     else if (flags & 12) {
44589                         if (flow.antecedents.length === 1) {
44590                             flow = flow.antecedents[0];
44591                             continue;
44592                         }
44593                         type = flags & 4 ?
44594                             getTypeAtFlowBranchLabel(flow) :
44595                             getTypeAtFlowLoopLabel(flow);
44596                     }
44597                     else if (flags & 256) {
44598                         type = getTypeAtFlowArrayMutation(flow);
44599                         if (!type) {
44600                             flow = flow.antecedent;
44601                             continue;
44602                         }
44603                     }
44604                     else if (flags & 1024) {
44605                         var target = flow.target;
44606                         var saveAntecedents = target.antecedents;
44607                         target.antecedents = flow.antecedents;
44608                         type = getTypeAtFlowNode(flow.antecedent);
44609                         target.antecedents = saveAntecedents;
44610                     }
44611                     else if (flags & 2) {
44612                         var container = flow.node;
44613                         if (container && container !== flowContainer &&
44614                             reference.kind !== 194 &&
44615                             reference.kind !== 195 &&
44616                             reference.kind !== 104) {
44617                             flow = container.flowNode;
44618                             continue;
44619                         }
44620                         type = initialType;
44621                     }
44622                     else {
44623                         type = convertAutoToAny(declaredType);
44624                     }
44625                     if (flags & 4096) {
44626                         sharedFlowNodes[sharedFlowCount] = flow;
44627                         sharedFlowTypes[sharedFlowCount] = type;
44628                         sharedFlowCount++;
44629                     }
44630                     flowDepth--;
44631                     return type;
44632                 }
44633             }
44634             function getInitialOrAssignedType(flow) {
44635                 var node = flow.node;
44636                 return getConstraintForLocation(node.kind === 242 || node.kind === 191 ?
44637                     getInitialType(node) :
44638                     getAssignedType(node), reference);
44639             }
44640             function getTypeAtFlowAssignment(flow) {
44641                 var node = flow.node;
44642                 if (isMatchingReference(reference, node)) {
44643                     if (!isReachableFlowNode(flow)) {
44644                         return unreachableNeverType;
44645                     }
44646                     if (ts.getAssignmentTargetKind(node) === 2) {
44647                         var flowType = getTypeAtFlowNode(flow.antecedent);
44648                         return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType));
44649                     }
44650                     if (declaredType === autoType || declaredType === autoArrayType) {
44651                         if (isEmptyArrayAssignment(node)) {
44652                             return getEvolvingArrayType(neverType);
44653                         }
44654                         var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(flow));
44655                         return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType;
44656                     }
44657                     if (declaredType.flags & 1048576) {
44658                         return getAssignmentReducedType(declaredType, getInitialOrAssignedType(flow));
44659                     }
44660                     return declaredType;
44661                 }
44662                 if (containsMatchingReference(reference, node)) {
44663                     if (!isReachableFlowNode(flow)) {
44664                         return unreachableNeverType;
44665                     }
44666                     if (ts.isVariableDeclaration(node) && (ts.isInJSFile(node) || ts.isVarConst(node))) {
44667                         var init = ts.getDeclaredExpandoInitializer(node);
44668                         if (init && (init.kind === 201 || init.kind === 202)) {
44669                             return getTypeAtFlowNode(flow.antecedent);
44670                         }
44671                     }
44672                     return declaredType;
44673                 }
44674                 if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 231 && isMatchingReference(reference, node.parent.parent.expression)) {
44675                     return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent)));
44676                 }
44677                 return undefined;
44678             }
44679             function narrowTypeByAssertion(type, expr) {
44680                 var node = ts.skipParentheses(expr);
44681                 if (node.kind === 91) {
44682                     return unreachableNeverType;
44683                 }
44684                 if (node.kind === 209) {
44685                     if (node.operatorToken.kind === 55) {
44686                         return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right);
44687                     }
44688                     if (node.operatorToken.kind === 56) {
44689                         return getUnionType([narrowTypeByAssertion(type, node.left), narrowTypeByAssertion(type, node.right)]);
44690                     }
44691                 }
44692                 return narrowType(type, node, true);
44693             }
44694             function getTypeAtFlowCall(flow) {
44695                 var signature = getEffectsSignature(flow.node);
44696                 if (signature) {
44697                     var predicate = getTypePredicateOfSignature(signature);
44698                     if (predicate && (predicate.kind === 2 || predicate.kind === 3)) {
44699                         var flowType = getTypeAtFlowNode(flow.antecedent);
44700                         var type = finalizeEvolvingArrayType(getTypeFromFlowType(flowType));
44701                         var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, true) :
44702                             predicate.kind === 3 && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) :
44703                                 type;
44704                         return narrowedType === type ? flowType : createFlowType(narrowedType, isIncomplete(flowType));
44705                     }
44706                     if (getReturnTypeOfSignature(signature).flags & 131072) {
44707                         return unreachableNeverType;
44708                     }
44709                 }
44710                 return undefined;
44711             }
44712             function getTypeAtFlowArrayMutation(flow) {
44713                 if (declaredType === autoType || declaredType === autoArrayType) {
44714                     var node = flow.node;
44715                     var expr = node.kind === 196 ?
44716                         node.expression.expression :
44717                         node.left.expression;
44718                     if (isMatchingReference(reference, getReferenceCandidate(expr))) {
44719                         var flowType = getTypeAtFlowNode(flow.antecedent);
44720                         var type = getTypeFromFlowType(flowType);
44721                         if (ts.getObjectFlags(type) & 256) {
44722                             var evolvedType_1 = type;
44723                             if (node.kind === 196) {
44724                                 for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) {
44725                                     var arg = _a[_i];
44726                                     evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg);
44727                                 }
44728                             }
44729                             else {
44730                                 var indexType = getContextFreeTypeOfExpression(node.left.argumentExpression);
44731                                 if (isTypeAssignableToKind(indexType, 296)) {
44732                                     evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right);
44733                                 }
44734                             }
44735                             return evolvedType_1 === type ? flowType : createFlowType(evolvedType_1, isIncomplete(flowType));
44736                         }
44737                         return flowType;
44738                     }
44739                 }
44740                 return undefined;
44741             }
44742             function getTypeAtFlowCondition(flow) {
44743                 var flowType = getTypeAtFlowNode(flow.antecedent);
44744                 var type = getTypeFromFlowType(flowType);
44745                 if (type.flags & 131072) {
44746                     return flowType;
44747                 }
44748                 var assumeTrue = (flow.flags & 32) !== 0;
44749                 var nonEvolvingType = finalizeEvolvingArrayType(type);
44750                 var narrowedType = narrowType(nonEvolvingType, flow.node, assumeTrue);
44751                 if (narrowedType === nonEvolvingType) {
44752                     return flowType;
44753                 }
44754                 var incomplete = isIncomplete(flowType);
44755                 var resultType = incomplete && narrowedType.flags & 131072 ? silentNeverType : narrowedType;
44756                 return createFlowType(resultType, incomplete);
44757             }
44758             function getTypeAtSwitchClause(flow) {
44759                 var expr = flow.switchStatement.expression;
44760                 var flowType = getTypeAtFlowNode(flow.antecedent);
44761                 var type = getTypeFromFlowType(flowType);
44762                 if (isMatchingReference(reference, expr)) {
44763                     type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
44764                 }
44765                 else if (expr.kind === 204 && isMatchingReference(reference, expr.expression)) {
44766                     type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
44767                 }
44768                 else {
44769                     if (strictNullChecks) {
44770                         if (optionalChainContainsReference(expr, reference)) {
44771                             type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 | 131072)); });
44772                         }
44773                         else if (expr.kind === 204 && optionalChainContainsReference(expr.expression, reference)) {
44774                             type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 || t.flags & 128 && t.value === "undefined"); });
44775                         }
44776                     }
44777                     if (isMatchingReferenceDiscriminant(expr, type)) {
44778                         type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); });
44779                     }
44780                 }
44781                 return createFlowType(type, isIncomplete(flowType));
44782             }
44783             function getTypeAtFlowBranchLabel(flow) {
44784                 var antecedentTypes = [];
44785                 var subtypeReduction = false;
44786                 var seenIncomplete = false;
44787                 var bypassFlow;
44788                 for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) {
44789                     var antecedent = _a[_i];
44790                     if (!bypassFlow && antecedent.flags & 128 && antecedent.clauseStart === antecedent.clauseEnd) {
44791                         bypassFlow = antecedent;
44792                         continue;
44793                     }
44794                     var flowType = getTypeAtFlowNode(antecedent);
44795                     var type = getTypeFromFlowType(flowType);
44796                     if (type === declaredType && declaredType === initialType) {
44797                         return type;
44798                     }
44799                     ts.pushIfUnique(antecedentTypes, type);
44800                     if (!isTypeSubsetOf(type, declaredType)) {
44801                         subtypeReduction = true;
44802                     }
44803                     if (isIncomplete(flowType)) {
44804                         seenIncomplete = true;
44805                     }
44806                 }
44807                 if (bypassFlow) {
44808                     var flowType = getTypeAtFlowNode(bypassFlow);
44809                     var type = getTypeFromFlowType(flowType);
44810                     if (!ts.contains(antecedentTypes, type) && !isExhaustiveSwitchStatement(bypassFlow.switchStatement)) {
44811                         if (type === declaredType && declaredType === initialType) {
44812                             return type;
44813                         }
44814                         antecedentTypes.push(type);
44815                         if (!isTypeSubsetOf(type, declaredType)) {
44816                             subtypeReduction = true;
44817                         }
44818                         if (isIncomplete(flowType)) {
44819                             seenIncomplete = true;
44820                         }
44821                     }
44822                 }
44823                 return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 : 1), seenIncomplete);
44824             }
44825             function getTypeAtFlowLoopLabel(flow) {
44826                 var id = getFlowNodeId(flow);
44827                 var cache = flowLoopCaches[id] || (flowLoopCaches[id] = ts.createMap());
44828                 var key = getOrSetCacheKey();
44829                 if (!key) {
44830                     return declaredType;
44831                 }
44832                 var cached = cache.get(key);
44833                 if (cached) {
44834                     return cached;
44835                 }
44836                 for (var i = flowLoopStart; i < flowLoopCount; i++) {
44837                     if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key && flowLoopTypes[i].length) {
44838                         return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], 1), true);
44839                     }
44840                 }
44841                 var antecedentTypes = [];
44842                 var subtypeReduction = false;
44843                 var firstAntecedentType;
44844                 for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) {
44845                     var antecedent = _a[_i];
44846                     var flowType = void 0;
44847                     if (!firstAntecedentType) {
44848                         flowType = firstAntecedentType = getTypeAtFlowNode(antecedent);
44849                     }
44850                     else {
44851                         flowLoopNodes[flowLoopCount] = flow;
44852                         flowLoopKeys[flowLoopCount] = key;
44853                         flowLoopTypes[flowLoopCount] = antecedentTypes;
44854                         flowLoopCount++;
44855                         var saveFlowTypeCache = flowTypeCache;
44856                         flowTypeCache = undefined;
44857                         flowType = getTypeAtFlowNode(antecedent);
44858                         flowTypeCache = saveFlowTypeCache;
44859                         flowLoopCount--;
44860                         var cached_1 = cache.get(key);
44861                         if (cached_1) {
44862                             return cached_1;
44863                         }
44864                     }
44865                     var type = getTypeFromFlowType(flowType);
44866                     ts.pushIfUnique(antecedentTypes, type);
44867                     if (!isTypeSubsetOf(type, declaredType)) {
44868                         subtypeReduction = true;
44869                     }
44870                     if (type === declaredType) {
44871                         break;
44872                     }
44873                 }
44874                 var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 : 1);
44875                 if (isIncomplete(firstAntecedentType)) {
44876                     return createFlowType(result, true);
44877                 }
44878                 cache.set(key, result);
44879                 return result;
44880             }
44881             function isMatchingReferenceDiscriminant(expr, computedType) {
44882                 if (!(computedType.flags & 1048576) || !ts.isAccessExpression(expr)) {
44883                     return false;
44884                 }
44885                 var name = getAccessedPropertyName(expr);
44886                 if (name === undefined) {
44887                     return false;
44888                 }
44889                 return isMatchingReference(reference, expr.expression) && isDiscriminantProperty(computedType, name);
44890             }
44891             function narrowTypeByDiscriminant(type, access, narrowType) {
44892                 var propName = getAccessedPropertyName(access);
44893                 if (propName === undefined) {
44894                     return type;
44895                 }
44896                 var propType = getTypeOfPropertyOfType(type, propName);
44897                 if (!propType) {
44898                     return type;
44899                 }
44900                 var narrowedPropType = narrowType(propType);
44901                 return filterType(type, function (t) {
44902                     var discriminantType = getTypeOfPropertyOrIndexSignature(t, propName);
44903                     return !(discriminantType.flags & 131072) && isTypeComparableTo(discriminantType, narrowedPropType);
44904                 });
44905             }
44906             function narrowTypeByTruthiness(type, expr, assumeTrue) {
44907                 if (isMatchingReference(reference, expr)) {
44908                     return getTypeWithFacts(type, assumeTrue ? 4194304 : 8388608);
44909                 }
44910                 if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) {
44911                     type = getTypeWithFacts(type, 2097152);
44912                 }
44913                 if (isMatchingReferenceDiscriminant(expr, declaredType)) {
44914                     return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 : 8388608); });
44915                 }
44916                 return type;
44917             }
44918             function isTypePresencePossible(type, propName, assumeTrue) {
44919                 if (getIndexInfoOfType(type, 0)) {
44920                     return true;
44921                 }
44922                 var prop = getPropertyOfType(type, propName);
44923                 if (prop) {
44924                     return prop.flags & 16777216 ? true : assumeTrue;
44925                 }
44926                 return !assumeTrue;
44927             }
44928             function narrowByInKeyword(type, literal, assumeTrue) {
44929                 if (type.flags & (1048576 | 524288) || isThisTypeParameter(type)) {
44930                     var propName_1 = ts.escapeLeadingUnderscores(literal.text);
44931                     return filterType(type, function (t) { return isTypePresencePossible(t, propName_1, assumeTrue); });
44932                 }
44933                 return type;
44934             }
44935             function narrowTypeByBinaryExpression(type, expr, assumeTrue) {
44936                 switch (expr.operatorToken.kind) {
44937                     case 62:
44938                         return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue);
44939                     case 34:
44940                     case 35:
44941                     case 36:
44942                     case 37:
44943                         var operator_1 = expr.operatorToken.kind;
44944                         var left_1 = getReferenceCandidate(expr.left);
44945                         var right_1 = getReferenceCandidate(expr.right);
44946                         if (left_1.kind === 204 && ts.isStringLiteralLike(right_1)) {
44947                             return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue);
44948                         }
44949                         if (right_1.kind === 204 && ts.isStringLiteralLike(left_1)) {
44950                             return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue);
44951                         }
44952                         if (isMatchingReference(reference, left_1)) {
44953                             return narrowTypeByEquality(type, operator_1, right_1, assumeTrue);
44954                         }
44955                         if (isMatchingReference(reference, right_1)) {
44956                             return narrowTypeByEquality(type, operator_1, left_1, assumeTrue);
44957                         }
44958                         if (strictNullChecks) {
44959                             if (optionalChainContainsReference(left_1, reference)) {
44960                                 type = narrowTypeByOptionalChainContainment(type, operator_1, right_1, assumeTrue);
44961                             }
44962                             else if (optionalChainContainsReference(right_1, reference)) {
44963                                 type = narrowTypeByOptionalChainContainment(type, operator_1, left_1, assumeTrue);
44964                             }
44965                         }
44966                         if (isMatchingReferenceDiscriminant(left_1, declaredType)) {
44967                             return narrowTypeByDiscriminant(type, left_1, function (t) { return narrowTypeByEquality(t, operator_1, right_1, assumeTrue); });
44968                         }
44969                         if (isMatchingReferenceDiscriminant(right_1, declaredType)) {
44970                             return narrowTypeByDiscriminant(type, right_1, function (t) { return narrowTypeByEquality(t, operator_1, left_1, assumeTrue); });
44971                         }
44972                         if (isMatchingConstructorReference(left_1)) {
44973                             return narrowTypeByConstructor(type, operator_1, right_1, assumeTrue);
44974                         }
44975                         if (isMatchingConstructorReference(right_1)) {
44976                             return narrowTypeByConstructor(type, operator_1, left_1, assumeTrue);
44977                         }
44978                         break;
44979                     case 98:
44980                         return narrowTypeByInstanceof(type, expr, assumeTrue);
44981                     case 97:
44982                         var target = getReferenceCandidate(expr.right);
44983                         if (ts.isStringLiteralLike(expr.left) && isMatchingReference(reference, target)) {
44984                             return narrowByInKeyword(type, expr.left, assumeTrue);
44985                         }
44986                         break;
44987                     case 27:
44988                         return narrowType(type, expr.right, assumeTrue);
44989                 }
44990                 return type;
44991             }
44992             function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) {
44993                 var equalsOperator = operator === 34 || operator === 36;
44994                 var nullableFlags = operator === 34 || operator === 35 ? 98304 : 32768;
44995                 var valueType = getTypeOfExpression(value);
44996                 var removeNullable = equalsOperator !== assumeTrue && everyType(valueType, function (t) { return !!(t.flags & nullableFlags); }) ||
44997                     equalsOperator === assumeTrue && everyType(valueType, function (t) { return !(t.flags & (3 | nullableFlags)); });
44998                 return removeNullable ? getTypeWithFacts(type, 2097152) : type;
44999             }
45000             function narrowTypeByEquality(type, operator, value, assumeTrue) {
45001                 if (type.flags & 1) {
45002                     return type;
45003                 }
45004                 if (operator === 35 || operator === 37) {
45005                     assumeTrue = !assumeTrue;
45006                 }
45007                 var valueType = getTypeOfExpression(value);
45008                 if ((type.flags & 2) && assumeTrue && (operator === 36 || operator === 37)) {
45009                     if (valueType.flags & (131068 | 67108864)) {
45010                         return valueType;
45011                     }
45012                     if (valueType.flags & 524288) {
45013                         return nonPrimitiveType;
45014                     }
45015                     return type;
45016                 }
45017                 if (valueType.flags & 98304) {
45018                     if (!strictNullChecks) {
45019                         return type;
45020                     }
45021                     var doubleEquals = operator === 34 || operator === 35;
45022                     var facts = doubleEquals ?
45023                         assumeTrue ? 262144 : 2097152 :
45024                         valueType.flags & 65536 ?
45025                             assumeTrue ? 131072 : 1048576 :
45026                             assumeTrue ? 65536 : 524288;
45027                     return getTypeWithFacts(type, facts);
45028                 }
45029                 if (type.flags & 67637251) {
45030                     return type;
45031                 }
45032                 if (assumeTrue) {
45033                     var filterFn = operator === 34 ?
45034                         (function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); }) :
45035                         function (t) { return areTypesComparable(t, valueType); };
45036                     var narrowedType = filterType(type, filterFn);
45037                     return narrowedType.flags & 131072 ? type : replacePrimitivesWithLiterals(narrowedType, valueType);
45038                 }
45039                 if (isUnitType(valueType)) {
45040                     var regularType_1 = getRegularTypeOfLiteralType(valueType);
45041                     return filterType(type, function (t) { return isUnitType(t) ? !areTypesComparable(t, valueType) : getRegularTypeOfLiteralType(t) !== regularType_1; });
45042                 }
45043                 return type;
45044             }
45045             function narrowTypeByTypeof(type, typeOfExpr, operator, literal, assumeTrue) {
45046                 if (operator === 35 || operator === 37) {
45047                     assumeTrue = !assumeTrue;
45048                 }
45049                 var target = getReferenceCandidate(typeOfExpr.expression);
45050                 if (!isMatchingReference(reference, target)) {
45051                     if (strictNullChecks && optionalChainContainsReference(target, reference) && assumeTrue === (literal.text !== "undefined")) {
45052                         return getTypeWithFacts(type, 2097152);
45053                     }
45054                     return type;
45055                 }
45056                 if (type.flags & 1 && literal.text === "function") {
45057                     return type;
45058                 }
45059                 if (assumeTrue && type.flags & 2 && literal.text === "object") {
45060                     if (typeOfExpr.parent.parent.kind === 209) {
45061                         var expr = typeOfExpr.parent.parent;
45062                         if (expr.operatorToken.kind === 55 && expr.right === typeOfExpr.parent && containsTruthyCheck(reference, expr.left)) {
45063                             return nonPrimitiveType;
45064                         }
45065                     }
45066                     return getUnionType([nonPrimitiveType, nullType]);
45067                 }
45068                 var facts = assumeTrue ?
45069                     typeofEQFacts.get(literal.text) || 128 :
45070                     typeofNEFacts.get(literal.text) || 32768;
45071                 return getTypeWithFacts(assumeTrue ? mapType(type, narrowTypeForTypeof) : type, facts);
45072                 function narrowTypeForTypeof(type) {
45073                     var targetType = literal.text === "function" ? globalFunctionType : typeofTypesByName.get(literal.text);
45074                     if (targetType) {
45075                         if (isTypeSubtypeOf(type, targetType)) {
45076                             return type;
45077                         }
45078                         if (isTypeSubtypeOf(targetType, type)) {
45079                             return targetType;
45080                         }
45081                         if (type.flags & 63176704) {
45082                             var constraint = getBaseConstraintOfType(type) || anyType;
45083                             if (isTypeSubtypeOf(targetType, constraint)) {
45084                                 return getIntersectionType([type, targetType]);
45085                             }
45086                         }
45087                     }
45088                     return type;
45089                 }
45090             }
45091             function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) {
45092                 var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck);
45093                 return everyClauseChecks ? getTypeWithFacts(type, 2097152) : type;
45094             }
45095             function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) {
45096                 var switchTypes = getSwitchClauseTypes(switchStatement);
45097                 if (!switchTypes.length) {
45098                     return type;
45099                 }
45100                 var clauseTypes = switchTypes.slice(clauseStart, clauseEnd);
45101                 var hasDefaultClause = clauseStart === clauseEnd || ts.contains(clauseTypes, neverType);
45102                 if ((type.flags & 2) && !hasDefaultClause) {
45103                     var groundClauseTypes = void 0;
45104                     for (var i = 0; i < clauseTypes.length; i += 1) {
45105                         var t = clauseTypes[i];
45106                         if (t.flags & (131068 | 67108864)) {
45107                             if (groundClauseTypes !== undefined) {
45108                                 groundClauseTypes.push(t);
45109                             }
45110                         }
45111                         else if (t.flags & 524288) {
45112                             if (groundClauseTypes === undefined) {
45113                                 groundClauseTypes = clauseTypes.slice(0, i);
45114                             }
45115                             groundClauseTypes.push(nonPrimitiveType);
45116                         }
45117                         else {
45118                             return type;
45119                         }
45120                     }
45121                     return getUnionType(groundClauseTypes === undefined ? clauseTypes : groundClauseTypes);
45122                 }
45123                 var discriminantType = getUnionType(clauseTypes);
45124                 var caseType = discriminantType.flags & 131072 ? neverType :
45125                     replacePrimitivesWithLiterals(filterType(type, function (t) { return areTypesComparable(discriminantType, t); }), discriminantType);
45126                 if (!hasDefaultClause) {
45127                     return caseType;
45128                 }
45129                 var defaultType = filterType(type, function (t) { return !(isUnitType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(t))); });
45130                 return caseType.flags & 131072 ? defaultType : getUnionType([caseType, defaultType]);
45131             }
45132             function getImpliedTypeFromTypeofCase(type, text) {
45133                 switch (text) {
45134                     case "function":
45135                         return type.flags & 1 ? type : globalFunctionType;
45136                     case "object":
45137                         return type.flags & 2 ? getUnionType([nonPrimitiveType, nullType]) : type;
45138                     default:
45139                         return typeofTypesByName.get(text) || type;
45140                 }
45141             }
45142             function narrowTypeForTypeofSwitch(candidate) {
45143                 return function (type) {
45144                     if (isTypeSubtypeOf(candidate, type)) {
45145                         return candidate;
45146                     }
45147                     if (type.flags & 63176704) {
45148                         var constraint = getBaseConstraintOfType(type) || anyType;
45149                         if (isTypeSubtypeOf(candidate, constraint)) {
45150                             return getIntersectionType([type, candidate]);
45151                         }
45152                     }
45153                     return type;
45154                 };
45155             }
45156             function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
45157                 var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement, true);
45158                 if (!switchWitnesses.length) {
45159                     return type;
45160                 }
45161                 var defaultCaseLocation = ts.findIndex(switchWitnesses, function (elem) { return elem === undefined; });
45162                 var hasDefaultClause = clauseStart === clauseEnd || (defaultCaseLocation >= clauseStart && defaultCaseLocation < clauseEnd);
45163                 var clauseWitnesses;
45164                 var switchFacts;
45165                 if (defaultCaseLocation > -1) {
45166                     var witnesses = switchWitnesses.filter(function (witness) { return witness !== undefined; });
45167                     var fixedClauseStart = defaultCaseLocation < clauseStart ? clauseStart - 1 : clauseStart;
45168                     var fixedClauseEnd = defaultCaseLocation < clauseEnd ? clauseEnd - 1 : clauseEnd;
45169                     clauseWitnesses = witnesses.slice(fixedClauseStart, fixedClauseEnd);
45170                     switchFacts = getFactsFromTypeofSwitch(fixedClauseStart, fixedClauseEnd, witnesses, hasDefaultClause);
45171                 }
45172                 else {
45173                     clauseWitnesses = switchWitnesses.slice(clauseStart, clauseEnd);
45174                     switchFacts = getFactsFromTypeofSwitch(clauseStart, clauseEnd, switchWitnesses, hasDefaultClause);
45175                 }
45176                 if (hasDefaultClause) {
45177                     return filterType(type, function (t) { return (getTypeFacts(t) & switchFacts) === switchFacts; });
45178                 }
45179                 var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return getImpliedTypeFromTypeofCase(type, text); })), switchFacts);
45180                 if (impliedType.flags & 1048576) {
45181                     impliedType = getAssignmentReducedType(impliedType, getBaseConstraintOrType(type));
45182                 }
45183                 return getTypeWithFacts(mapType(type, narrowTypeForTypeofSwitch(impliedType)), switchFacts);
45184             }
45185             function isMatchingConstructorReference(expr) {
45186                 return (ts.isPropertyAccessExpression(expr) && ts.idText(expr.name) === "constructor" ||
45187                     ts.isElementAccessExpression(expr) && ts.isStringLiteralLike(expr.argumentExpression) && expr.argumentExpression.text === "constructor") &&
45188                     isMatchingReference(reference, expr.expression);
45189             }
45190             function narrowTypeByConstructor(type, operator, identifier, assumeTrue) {
45191                 if (assumeTrue ? (operator !== 34 && operator !== 36) : (operator !== 35 && operator !== 37)) {
45192                     return type;
45193                 }
45194                 var identifierType = getTypeOfExpression(identifier);
45195                 if (!isFunctionType(identifierType) && !isConstructorType(identifierType)) {
45196                     return type;
45197                 }
45198                 var prototypeProperty = getPropertyOfType(identifierType, "prototype");
45199                 if (!prototypeProperty) {
45200                     return type;
45201                 }
45202                 var prototypeType = getTypeOfSymbol(prototypeProperty);
45203                 var candidate = !isTypeAny(prototypeType) ? prototypeType : undefined;
45204                 if (!candidate || candidate === globalObjectType || candidate === globalFunctionType) {
45205                     return type;
45206                 }
45207                 if (isTypeAny(type)) {
45208                     return candidate;
45209                 }
45210                 return filterType(type, function (t) { return isConstructedBy(t, candidate); });
45211                 function isConstructedBy(source, target) {
45212                     if (source.flags & 524288 && ts.getObjectFlags(source) & 1 ||
45213                         target.flags & 524288 && ts.getObjectFlags(target) & 1) {
45214                         return source.symbol === target.symbol;
45215                     }
45216                     return isTypeSubtypeOf(source, target);
45217                 }
45218             }
45219             function narrowTypeByInstanceof(type, expr, assumeTrue) {
45220                 var left = getReferenceCandidate(expr.left);
45221                 if (!isMatchingReference(reference, left)) {
45222                     if (assumeTrue && strictNullChecks && optionalChainContainsReference(left, reference)) {
45223                         return getTypeWithFacts(type, 2097152);
45224                     }
45225                     return type;
45226                 }
45227                 var rightType = getTypeOfExpression(expr.right);
45228                 if (!isTypeDerivedFrom(rightType, globalFunctionType)) {
45229                     return type;
45230                 }
45231                 var targetType;
45232                 var prototypeProperty = getPropertyOfType(rightType, "prototype");
45233                 if (prototypeProperty) {
45234                     var prototypePropertyType = getTypeOfSymbol(prototypeProperty);
45235                     if (!isTypeAny(prototypePropertyType)) {
45236                         targetType = prototypePropertyType;
45237                     }
45238                 }
45239                 if (isTypeAny(type) && (targetType === globalObjectType || targetType === globalFunctionType)) {
45240                     return type;
45241                 }
45242                 if (!targetType) {
45243                     var constructSignatures = getSignaturesOfType(rightType, 1);
45244                     targetType = constructSignatures.length ?
45245                         getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })) :
45246                         emptyObjectType;
45247                 }
45248                 return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom);
45249             }
45250             function getNarrowedType(type, candidate, assumeTrue, isRelated) {
45251                 if (!assumeTrue) {
45252                     return filterType(type, function (t) { return !isRelated(t, candidate); });
45253                 }
45254                 if (type.flags & 1048576) {
45255                     var assignableType = filterType(type, function (t) { return isRelated(t, candidate); });
45256                     if (!(assignableType.flags & 131072)) {
45257                         return assignableType;
45258                     }
45259                 }
45260                 return isTypeSubtypeOf(candidate, type) ? candidate :
45261                     isTypeAssignableTo(type, candidate) ? type :
45262                         isTypeAssignableTo(candidate, type) ? candidate :
45263                             getIntersectionType([type, candidate]);
45264             }
45265             function narrowTypeByCallExpression(type, callExpression, assumeTrue) {
45266                 if (hasMatchingArgument(callExpression, reference)) {
45267                     var signature = assumeTrue || !ts.isCallChain(callExpression) ? getEffectsSignature(callExpression) : undefined;
45268                     var predicate = signature && getTypePredicateOfSignature(signature);
45269                     if (predicate && (predicate.kind === 0 || predicate.kind === 1)) {
45270                         return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue);
45271                     }
45272                 }
45273                 return type;
45274             }
45275             function narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue) {
45276                 if (predicate.type && !(isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType))) {
45277                     var predicateArgument = getTypePredicateArgument(predicate, callExpression);
45278                     if (predicateArgument) {
45279                         if (isMatchingReference(reference, predicateArgument)) {
45280                             return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf);
45281                         }
45282                         if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) &&
45283                             !(getTypeFacts(predicate.type) & 65536)) {
45284                             type = getTypeWithFacts(type, 2097152);
45285                         }
45286                         if (isMatchingReferenceDiscriminant(predicateArgument, declaredType)) {
45287                             return narrowTypeByDiscriminant(type, predicateArgument, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, isTypeSubtypeOf); });
45288                         }
45289                     }
45290                 }
45291                 return type;
45292             }
45293             function narrowType(type, expr, assumeTrue) {
45294                 if (ts.isExpressionOfOptionalChainRoot(expr) ||
45295                     ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 && expr.parent.left === expr) {
45296                     return narrowTypeByOptionality(type, expr, assumeTrue);
45297                 }
45298                 switch (expr.kind) {
45299                     case 75:
45300                     case 104:
45301                     case 102:
45302                     case 194:
45303                     case 195:
45304                         return narrowTypeByTruthiness(type, expr, assumeTrue);
45305                     case 196:
45306                         return narrowTypeByCallExpression(type, expr, assumeTrue);
45307                     case 200:
45308                         return narrowType(type, expr.expression, assumeTrue);
45309                     case 209:
45310                         return narrowTypeByBinaryExpression(type, expr, assumeTrue);
45311                     case 207:
45312                         if (expr.operator === 53) {
45313                             return narrowType(type, expr.operand, !assumeTrue);
45314                         }
45315                         break;
45316                 }
45317                 return type;
45318             }
45319             function narrowTypeByOptionality(type, expr, assumePresent) {
45320                 if (isMatchingReference(reference, expr)) {
45321                     return getTypeWithFacts(type, assumePresent ? 2097152 : 262144);
45322                 }
45323                 if (isMatchingReferenceDiscriminant(expr, declaredType)) {
45324                     return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 : 262144); });
45325                 }
45326                 return type;
45327             }
45328         }
45329         function getTypeOfSymbolAtLocation(symbol, location) {
45330             symbol = symbol.exportSymbol || symbol;
45331             if (location.kind === 75) {
45332                 if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) {
45333                     location = location.parent;
45334                 }
45335                 if (ts.isExpressionNode(location) && !ts.isAssignmentTarget(location)) {
45336                     var type = getTypeOfExpression(location);
45337                     if (getExportSymbolOfValueSymbolIfExported(getNodeLinks(location).resolvedSymbol) === symbol) {
45338                         return type;
45339                     }
45340                 }
45341             }
45342             return getTypeOfSymbol(symbol);
45343         }
45344         function getControlFlowContainer(node) {
45345             return ts.findAncestor(node.parent, function (node) {
45346                 return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) ||
45347                     node.kind === 250 ||
45348                     node.kind === 290 ||
45349                     node.kind === 159;
45350             });
45351         }
45352         function isParameterAssigned(symbol) {
45353             var func = ts.getRootDeclaration(symbol.valueDeclaration).parent;
45354             var links = getNodeLinks(func);
45355             if (!(links.flags & 8388608)) {
45356                 links.flags |= 8388608;
45357                 if (!hasParentWithAssignmentsMarked(func)) {
45358                     markParameterAssignments(func);
45359                 }
45360             }
45361             return symbol.isAssigned || false;
45362         }
45363         function hasParentWithAssignmentsMarked(node) {
45364             return !!ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !!(getNodeLinks(node).flags & 8388608); });
45365         }
45366         function markParameterAssignments(node) {
45367             if (node.kind === 75) {
45368                 if (ts.isAssignmentTarget(node)) {
45369                     var symbol = getResolvedSymbol(node);
45370                     if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 156) {
45371                         symbol.isAssigned = true;
45372                     }
45373                 }
45374             }
45375             else {
45376                 ts.forEachChild(node, markParameterAssignments);
45377             }
45378         }
45379         function isConstVariable(symbol) {
45380             return symbol.flags & 3 && (getDeclarationNodeFlagsFromSymbol(symbol) & 2) !== 0 && getTypeOfSymbol(symbol) !== autoArrayType;
45381         }
45382         function removeOptionalityFromDeclaredType(declaredType, declaration) {
45383             if (pushTypeResolution(declaration.symbol, 2)) {
45384                 var annotationIncludesUndefined = strictNullChecks &&
45385                     declaration.kind === 156 &&
45386                     declaration.initializer &&
45387                     getFalsyFlags(declaredType) & 32768 &&
45388                     !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768);
45389                 popTypeResolution();
45390                 return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288) : declaredType;
45391             }
45392             else {
45393                 reportCircularityError(declaration.symbol);
45394                 return declaredType;
45395             }
45396         }
45397         function isConstraintPosition(node) {
45398             var parent = node.parent;
45399             return parent.kind === 194 ||
45400                 parent.kind === 196 && parent.expression === node ||
45401                 parent.kind === 195 && parent.expression === node ||
45402                 parent.kind === 191 && parent.name === node && !!parent.initializer;
45403         }
45404         function typeHasNullableConstraint(type) {
45405             return type.flags & 58982400 && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 98304);
45406         }
45407         function getConstraintForLocation(type, node) {
45408             if (type && isConstraintPosition(node) && forEachType(type, typeHasNullableConstraint)) {
45409                 return mapType(getWidenedType(type), getBaseConstraintOrType);
45410             }
45411             return type;
45412         }
45413         function isExportOrExportExpression(location) {
45414             return !!ts.findAncestor(location, function (e) { return e.parent && ts.isExportAssignment(e.parent) && e.parent.expression === e && ts.isEntityNameExpression(e); });
45415         }
45416         function markAliasReferenced(symbol, location) {
45417             if (isNonLocalAlias(symbol, 111551) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) {
45418                 if (compilerOptions.preserveConstEnums && isExportOrExportExpression(location) || !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) {
45419                     markAliasSymbolAsReferenced(symbol);
45420                 }
45421                 else {
45422                     markConstEnumAliasAsReferenced(symbol);
45423                 }
45424             }
45425         }
45426         function checkIdentifier(node) {
45427             var symbol = getResolvedSymbol(node);
45428             if (symbol === unknownSymbol) {
45429                 return errorType;
45430             }
45431             if (symbol === argumentsSymbol) {
45432                 var container = ts.getContainingFunction(node);
45433                 if (languageVersion < 2) {
45434                     if (container.kind === 202) {
45435                         error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression);
45436                     }
45437                     else if (ts.hasModifier(container, 256)) {
45438                         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);
45439                     }
45440                 }
45441                 getNodeLinks(container).flags |= 8192;
45442                 return getTypeOfSymbol(symbol);
45443             }
45444             if (!(node.parent && ts.isPropertyAccessExpression(node.parent) && node.parent.expression === node)) {
45445                 markAliasReferenced(symbol, node);
45446             }
45447             var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
45448             var declaration = localOrExportSymbol.valueDeclaration;
45449             if (localOrExportSymbol.flags & 32) {
45450                 if (declaration.kind === 245
45451                     && ts.nodeIsDecorated(declaration)) {
45452                     var container = ts.getContainingClass(node);
45453                     while (container !== undefined) {
45454                         if (container === declaration && container.name !== node) {
45455                             getNodeLinks(declaration).flags |= 16777216;
45456                             getNodeLinks(node).flags |= 33554432;
45457                             break;
45458                         }
45459                         container = ts.getContainingClass(container);
45460                     }
45461                 }
45462                 else if (declaration.kind === 214) {
45463                     var container = ts.getThisContainer(node, false);
45464                     while (container.kind !== 290) {
45465                         if (container.parent === declaration) {
45466                             if (container.kind === 159 && ts.hasModifier(container, 32)) {
45467                                 getNodeLinks(declaration).flags |= 16777216;
45468                                 getNodeLinks(node).flags |= 33554432;
45469                             }
45470                             break;
45471                         }
45472                         container = ts.getThisContainer(container, false);
45473                     }
45474                 }
45475             }
45476             checkNestedBlockScopedBinding(node, symbol);
45477             var type = getConstraintForLocation(getTypeOfSymbol(localOrExportSymbol), node);
45478             var assignmentKind = ts.getAssignmentTargetKind(node);
45479             if (assignmentKind) {
45480                 if (!(localOrExportSymbol.flags & 3) &&
45481                     !(ts.isInJSFile(node) && localOrExportSymbol.flags & 512)) {
45482                     error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable, symbolToString(symbol));
45483                     return errorType;
45484                 }
45485                 if (isReadonlySymbol(localOrExportSymbol)) {
45486                     if (localOrExportSymbol.flags & 3) {
45487                         error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant, symbolToString(symbol));
45488                     }
45489                     else {
45490                         error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(symbol));
45491                     }
45492                     return errorType;
45493                 }
45494             }
45495             var isAlias = localOrExportSymbol.flags & 2097152;
45496             if (localOrExportSymbol.flags & 3) {
45497                 if (assignmentKind === 1) {
45498                     return type;
45499                 }
45500             }
45501             else if (isAlias) {
45502                 declaration = ts.find(symbol.declarations, isSomeImportDeclaration);
45503             }
45504             else {
45505                 return type;
45506             }
45507             if (!declaration) {
45508                 return type;
45509             }
45510             var isParameter = ts.getRootDeclaration(declaration).kind === 156;
45511             var declarationContainer = getControlFlowContainer(declaration);
45512             var flowContainer = getControlFlowContainer(node);
45513             var isOuterVariable = flowContainer !== declarationContainer;
45514             var isSpreadDestructuringAssignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent);
45515             var isModuleExports = symbol.flags & 134217728;
45516             while (flowContainer !== declarationContainer && (flowContainer.kind === 201 ||
45517                 flowContainer.kind === 202 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) &&
45518                 (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) {
45519                 flowContainer = getControlFlowContainer(flowContainer);
45520             }
45521             var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) ||
45522                 type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 | 16384)) !== 0 ||
45523                     isInTypeQuery(node) || node.parent.kind === 263) ||
45524                 node.parent.kind === 218 ||
45525                 declaration.kind === 242 && declaration.exclamationToken ||
45526                 declaration.flags & 8388608;
45527             var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) :
45528                 type === autoType || type === autoArrayType ? undefinedType :
45529                     getOptionalType(type);
45530             var flowType = getFlowTypeOfReference(node, type, initialType, flowContainer, !assumeInitialized);
45531             if (!isEvolvingArrayOperationTarget(node) && (type === autoType || type === autoArrayType)) {
45532                 if (flowType === autoType || flowType === autoArrayType) {
45533                     if (noImplicitAny) {
45534                         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));
45535                         error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType));
45536                     }
45537                     return convertAutoToAny(flowType);
45538                 }
45539             }
45540             else if (!assumeInitialized && !(getFalsyFlags(type) & 32768) && getFalsyFlags(flowType) & 32768) {
45541                 error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol));
45542                 return type;
45543             }
45544             return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
45545         }
45546         function isInsideFunction(node, threshold) {
45547             return !!ts.findAncestor(node, function (n) { return n === threshold ? "quit" : ts.isFunctionLike(n); });
45548         }
45549         function getPartOfForStatementContainingNode(node, container) {
45550             return ts.findAncestor(node, function (n) { return n === container ? "quit" : n === container.initializer || n === container.condition || n === container.incrementor || n === container.statement; });
45551         }
45552         function checkNestedBlockScopedBinding(node, symbol) {
45553             if (languageVersion >= 2 ||
45554                 (symbol.flags & (2 | 32)) === 0 ||
45555                 ts.isSourceFile(symbol.valueDeclaration) ||
45556                 symbol.valueDeclaration.parent.kind === 280) {
45557                 return;
45558             }
45559             var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration);
45560             var usedInFunction = isInsideFunction(node.parent, container);
45561             var current = container;
45562             var containedInIterationStatement = false;
45563             while (current && !ts.nodeStartsNewLexicalEnvironment(current)) {
45564                 if (ts.isIterationStatement(current, false)) {
45565                     containedInIterationStatement = true;
45566                     break;
45567                 }
45568                 current = current.parent;
45569             }
45570             if (containedInIterationStatement) {
45571                 if (usedInFunction) {
45572                     var capturesBlockScopeBindingInLoopBody = true;
45573                     if (ts.isForStatement(container)) {
45574                         var varDeclList = ts.getAncestor(symbol.valueDeclaration, 243);
45575                         if (varDeclList && varDeclList.parent === container) {
45576                             var part = getPartOfForStatementContainingNode(node.parent, container);
45577                             if (part) {
45578                                 var links = getNodeLinks(part);
45579                                 links.flags |= 131072;
45580                                 var capturedBindings = links.capturedBlockScopeBindings || (links.capturedBlockScopeBindings = []);
45581                                 ts.pushIfUnique(capturedBindings, symbol);
45582                                 if (part === container.initializer) {
45583                                     capturesBlockScopeBindingInLoopBody = false;
45584                                 }
45585                             }
45586                         }
45587                     }
45588                     if (capturesBlockScopeBindingInLoopBody) {
45589                         getNodeLinks(current).flags |= 65536;
45590                     }
45591                 }
45592                 if (ts.isForStatement(container)) {
45593                     var varDeclList = ts.getAncestor(symbol.valueDeclaration, 243);
45594                     if (varDeclList && varDeclList.parent === container && isAssignedInBodyOfForStatement(node, container)) {
45595                         getNodeLinks(symbol.valueDeclaration).flags |= 4194304;
45596                     }
45597                 }
45598                 getNodeLinks(symbol.valueDeclaration).flags |= 524288;
45599             }
45600             if (usedInFunction) {
45601                 getNodeLinks(symbol.valueDeclaration).flags |= 262144;
45602             }
45603         }
45604         function isBindingCapturedByNode(node, decl) {
45605             var links = getNodeLinks(node);
45606             return !!links && ts.contains(links.capturedBlockScopeBindings, getSymbolOfNode(decl));
45607         }
45608         function isAssignedInBodyOfForStatement(node, container) {
45609             var current = node;
45610             while (current.parent.kind === 200) {
45611                 current = current.parent;
45612             }
45613             var isAssigned = false;
45614             if (ts.isAssignmentTarget(current)) {
45615                 isAssigned = true;
45616             }
45617             else if ((current.parent.kind === 207 || current.parent.kind === 208)) {
45618                 var expr = current.parent;
45619                 isAssigned = expr.operator === 45 || expr.operator === 46;
45620             }
45621             if (!isAssigned) {
45622                 return false;
45623             }
45624             return !!ts.findAncestor(current, function (n) { return n === container ? "quit" : n === container.statement; });
45625         }
45626         function captureLexicalThis(node, container) {
45627             getNodeLinks(node).flags |= 2;
45628             if (container.kind === 159 || container.kind === 162) {
45629                 var classNode = container.parent;
45630                 getNodeLinks(classNode).flags |= 4;
45631             }
45632             else {
45633                 getNodeLinks(container).flags |= 4;
45634             }
45635         }
45636         function findFirstSuperCall(n) {
45637             if (ts.isSuperCall(n)) {
45638                 return n;
45639             }
45640             else if (ts.isFunctionLike(n)) {
45641                 return undefined;
45642             }
45643             return ts.forEachChild(n, findFirstSuperCall);
45644         }
45645         function getSuperCallInConstructor(constructor) {
45646             var links = getNodeLinks(constructor);
45647             if (links.hasSuperCall === undefined) {
45648                 links.superCall = findFirstSuperCall(constructor.body);
45649                 links.hasSuperCall = links.superCall ? true : false;
45650             }
45651             return links.superCall;
45652         }
45653         function classDeclarationExtendsNull(classDecl) {
45654             var classSymbol = getSymbolOfNode(classDecl);
45655             var classInstanceType = getDeclaredTypeOfSymbol(classSymbol);
45656             var baseConstructorType = getBaseConstructorTypeOfClass(classInstanceType);
45657             return baseConstructorType === nullWideningType;
45658         }
45659         function checkThisBeforeSuper(node, container, diagnosticMessage) {
45660             var containingClassDecl = container.parent;
45661             var baseTypeNode = ts.getClassExtendsHeritageElement(containingClassDecl);
45662             if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) {
45663                 var superCall = getSuperCallInConstructor(container);
45664                 if (!superCall || superCall.end > node.pos) {
45665                     error(node, diagnosticMessage);
45666                 }
45667             }
45668         }
45669         function checkThisExpression(node) {
45670             var container = ts.getThisContainer(node, true);
45671             var capturedByArrowFunction = false;
45672             if (container.kind === 162) {
45673                 checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class);
45674             }
45675             if (container.kind === 202) {
45676                 container = ts.getThisContainer(container, false);
45677                 capturedByArrowFunction = true;
45678             }
45679             switch (container.kind) {
45680                 case 249:
45681                     error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body);
45682                     break;
45683                 case 248:
45684                     error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location);
45685                     break;
45686                 case 162:
45687                     if (isInConstructorArgumentInitializer(node, container)) {
45688                         error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments);
45689                     }
45690                     break;
45691                 case 159:
45692                 case 158:
45693                     if (ts.hasModifier(container, 32) && !(compilerOptions.target === 99 && compilerOptions.useDefineForClassFields)) {
45694                         error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer);
45695                     }
45696                     break;
45697                 case 154:
45698                     error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name);
45699                     break;
45700             }
45701             if (capturedByArrowFunction && languageVersion < 2) {
45702                 captureLexicalThis(node, container);
45703             }
45704             var type = tryGetThisTypeAt(node, true, container);
45705             if (noImplicitThis) {
45706                 var globalThisType_1 = getTypeOfSymbol(globalThisSymbol);
45707                 if (type === globalThisType_1 && capturedByArrowFunction) {
45708                     error(node, ts.Diagnostics.The_containing_arrow_function_captures_the_global_value_of_this);
45709                 }
45710                 else if (!type) {
45711                     var diag = error(node, ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation);
45712                     if (!ts.isSourceFile(container)) {
45713                         var outsideThis = tryGetThisTypeAt(container);
45714                         if (outsideThis && outsideThis !== globalThisType_1) {
45715                             ts.addRelatedInfo(diag, ts.createDiagnosticForNode(container, ts.Diagnostics.An_outer_value_of_this_is_shadowed_by_this_container));
45716                         }
45717                     }
45718                 }
45719             }
45720             return type || anyType;
45721         }
45722         function tryGetThisTypeAt(node, includeGlobalThis, container) {
45723             if (includeGlobalThis === void 0) { includeGlobalThis = true; }
45724             if (container === void 0) { container = ts.getThisContainer(node, false); }
45725             var isInJS = ts.isInJSFile(node);
45726             if (ts.isFunctionLike(container) &&
45727                 (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) {
45728                 var className = getClassNameFromPrototypeMethod(container);
45729                 if (isInJS && className) {
45730                     var classSymbol = checkExpression(className).symbol;
45731                     if (classSymbol && classSymbol.members && (classSymbol.flags & 16)) {
45732                         var classType = getDeclaredTypeOfSymbol(classSymbol).thisType;
45733                         if (classType) {
45734                             return getFlowTypeOfReference(node, classType);
45735                         }
45736                     }
45737                 }
45738                 else if (isInJS &&
45739                     (container.kind === 201 || container.kind === 244) &&
45740                     ts.getJSDocClassTag(container)) {
45741                     var classType = getDeclaredTypeOfSymbol(getMergedSymbol(container.symbol)).thisType;
45742                     return getFlowTypeOfReference(node, classType);
45743                 }
45744                 var thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container);
45745                 if (thisType) {
45746                     return getFlowTypeOfReference(node, thisType);
45747                 }
45748             }
45749             if (ts.isClassLike(container.parent)) {
45750                 var symbol = getSymbolOfNode(container.parent);
45751                 var type = ts.hasModifier(container, 32) ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType;
45752                 return getFlowTypeOfReference(node, type);
45753             }
45754             if (isInJS) {
45755                 var type = getTypeForThisExpressionFromJSDoc(container);
45756                 if (type && type !== errorType) {
45757                     return getFlowTypeOfReference(node, type);
45758                 }
45759             }
45760             if (ts.isSourceFile(container)) {
45761                 if (container.commonJsModuleIndicator) {
45762                     var fileSymbol = getSymbolOfNode(container);
45763                     return fileSymbol && getTypeOfSymbol(fileSymbol);
45764                 }
45765                 else if (includeGlobalThis) {
45766                     return getTypeOfSymbol(globalThisSymbol);
45767                 }
45768             }
45769         }
45770         function getExplicitThisType(node) {
45771             var container = ts.getThisContainer(node, false);
45772             if (ts.isFunctionLike(container)) {
45773                 var signature = getSignatureFromDeclaration(container);
45774                 if (signature.thisParameter) {
45775                     return getExplicitTypeOfSymbol(signature.thisParameter);
45776                 }
45777             }
45778             if (ts.isClassLike(container.parent)) {
45779                 var symbol = getSymbolOfNode(container.parent);
45780                 return ts.hasModifier(container, 32) ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType;
45781             }
45782         }
45783         function getClassNameFromPrototypeMethod(container) {
45784             if (container.kind === 201 &&
45785                 ts.isBinaryExpression(container.parent) &&
45786                 ts.getAssignmentDeclarationKind(container.parent) === 3) {
45787                 return container.parent
45788                     .left
45789                     .expression
45790                     .expression;
45791             }
45792             else if (container.kind === 161 &&
45793                 container.parent.kind === 193 &&
45794                 ts.isBinaryExpression(container.parent.parent) &&
45795                 ts.getAssignmentDeclarationKind(container.parent.parent) === 6) {
45796                 return container.parent.parent.left.expression;
45797             }
45798             else if (container.kind === 201 &&
45799                 container.parent.kind === 281 &&
45800                 container.parent.parent.kind === 193 &&
45801                 ts.isBinaryExpression(container.parent.parent.parent) &&
45802                 ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6) {
45803                 return container.parent.parent.parent.left.expression;
45804             }
45805             else if (container.kind === 201 &&
45806                 ts.isPropertyAssignment(container.parent) &&
45807                 ts.isIdentifier(container.parent.name) &&
45808                 (container.parent.name.escapedText === "value" || container.parent.name.escapedText === "get" || container.parent.name.escapedText === "set") &&
45809                 ts.isObjectLiteralExpression(container.parent.parent) &&
45810                 ts.isCallExpression(container.parent.parent.parent) &&
45811                 container.parent.parent.parent.arguments[2] === container.parent.parent &&
45812                 ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 9) {
45813                 return container.parent.parent.parent.arguments[0].expression;
45814             }
45815             else if (ts.isMethodDeclaration(container) &&
45816                 ts.isIdentifier(container.name) &&
45817                 (container.name.escapedText === "value" || container.name.escapedText === "get" || container.name.escapedText === "set") &&
45818                 ts.isObjectLiteralExpression(container.parent) &&
45819                 ts.isCallExpression(container.parent.parent) &&
45820                 container.parent.parent.arguments[2] === container.parent &&
45821                 ts.getAssignmentDeclarationKind(container.parent.parent) === 9) {
45822                 return container.parent.parent.arguments[0].expression;
45823             }
45824         }
45825         function getTypeForThisExpressionFromJSDoc(node) {
45826             var jsdocType = ts.getJSDocType(node);
45827             if (jsdocType && jsdocType.kind === 300) {
45828                 var jsDocFunctionType = jsdocType;
45829                 if (jsDocFunctionType.parameters.length > 0 &&
45830                     jsDocFunctionType.parameters[0].name &&
45831                     jsDocFunctionType.parameters[0].name.escapedText === "this") {
45832                     return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type);
45833                 }
45834             }
45835             var thisTag = ts.getJSDocThisTag(node);
45836             if (thisTag && thisTag.typeExpression) {
45837                 return getTypeFromTypeNode(thisTag.typeExpression);
45838             }
45839         }
45840         function isInConstructorArgumentInitializer(node, constructorDecl) {
45841             return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 156 && n.parent === constructorDecl; });
45842         }
45843         function checkSuperExpression(node) {
45844             var isCallExpression = node.parent.kind === 196 && node.parent.expression === node;
45845             var container = ts.getSuperContainer(node, true);
45846             var needToCaptureLexicalThis = false;
45847             if (!isCallExpression) {
45848                 while (container && container.kind === 202) {
45849                     container = ts.getSuperContainer(container, true);
45850                     needToCaptureLexicalThis = languageVersion < 2;
45851                 }
45852             }
45853             var canUseSuperExpression = isLegalUsageOfSuperExpression(container);
45854             var nodeCheckFlag = 0;
45855             if (!canUseSuperExpression) {
45856                 var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 154; });
45857                 if (current && current.kind === 154) {
45858                     error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name);
45859                 }
45860                 else if (isCallExpression) {
45861                     error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors);
45862                 }
45863                 else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 193)) {
45864                     error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions);
45865                 }
45866                 else {
45867                     error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class);
45868                 }
45869                 return errorType;
45870             }
45871             if (!isCallExpression && container.kind === 162) {
45872                 checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class);
45873             }
45874             if (ts.hasModifier(container, 32) || isCallExpression) {
45875                 nodeCheckFlag = 512;
45876             }
45877             else {
45878                 nodeCheckFlag = 256;
45879             }
45880             getNodeLinks(node).flags |= nodeCheckFlag;
45881             if (container.kind === 161 && ts.hasModifier(container, 256)) {
45882                 if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) {
45883                     getNodeLinks(container).flags |= 4096;
45884                 }
45885                 else {
45886                     getNodeLinks(container).flags |= 2048;
45887                 }
45888             }
45889             if (needToCaptureLexicalThis) {
45890                 captureLexicalThis(node.parent, container);
45891             }
45892             if (container.parent.kind === 193) {
45893                 if (languageVersion < 2) {
45894                     error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher);
45895                     return errorType;
45896                 }
45897                 else {
45898                     return anyType;
45899                 }
45900             }
45901             var classLikeDeclaration = container.parent;
45902             if (!ts.getClassExtendsHeritageElement(classLikeDeclaration)) {
45903                 error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class);
45904                 return errorType;
45905             }
45906             var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(classLikeDeclaration));
45907             var baseClassType = classType && getBaseTypes(classType)[0];
45908             if (!baseClassType) {
45909                 return errorType;
45910             }
45911             if (container.kind === 162 && isInConstructorArgumentInitializer(node, container)) {
45912                 error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments);
45913                 return errorType;
45914             }
45915             return nodeCheckFlag === 512
45916                 ? getBaseConstructorTypeOfClass(classType)
45917                 : getTypeWithThisArgument(baseClassType, classType.thisType);
45918             function isLegalUsageOfSuperExpression(container) {
45919                 if (!container) {
45920                     return false;
45921                 }
45922                 if (isCallExpression) {
45923                     return container.kind === 162;
45924                 }
45925                 else {
45926                     if (ts.isClassLike(container.parent) || container.parent.kind === 193) {
45927                         if (ts.hasModifier(container, 32)) {
45928                             return container.kind === 161 ||
45929                                 container.kind === 160 ||
45930                                 container.kind === 163 ||
45931                                 container.kind === 164;
45932                         }
45933                         else {
45934                             return container.kind === 161 ||
45935                                 container.kind === 160 ||
45936                                 container.kind === 163 ||
45937                                 container.kind === 164 ||
45938                                 container.kind === 159 ||
45939                                 container.kind === 158 ||
45940                                 container.kind === 162;
45941                         }
45942                     }
45943                 }
45944                 return false;
45945             }
45946         }
45947         function getContainingObjectLiteral(func) {
45948             return (func.kind === 161 ||
45949                 func.kind === 163 ||
45950                 func.kind === 164) && func.parent.kind === 193 ? func.parent :
45951                 func.kind === 201 && func.parent.kind === 281 ? func.parent.parent :
45952                     undefined;
45953         }
45954         function getThisTypeArgument(type) {
45955             return ts.getObjectFlags(type) & 4 && type.target === globalThisType ? getTypeArguments(type)[0] : undefined;
45956         }
45957         function getThisTypeFromContextualType(type) {
45958             return mapType(type, function (t) {
45959                 return t.flags & 2097152 ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t);
45960             });
45961         }
45962         function getContextualThisParameterType(func) {
45963             if (func.kind === 202) {
45964                 return undefined;
45965             }
45966             if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) {
45967                 var contextualSignature = getContextualSignature(func);
45968                 if (contextualSignature) {
45969                     var thisParameter = contextualSignature.thisParameter;
45970                     if (thisParameter) {
45971                         return getTypeOfSymbol(thisParameter);
45972                     }
45973                 }
45974             }
45975             var inJs = ts.isInJSFile(func);
45976             if (noImplicitThis || inJs) {
45977                 var containingLiteral = getContainingObjectLiteral(func);
45978                 if (containingLiteral) {
45979                     var contextualType = getApparentTypeOfContextualType(containingLiteral);
45980                     var literal = containingLiteral;
45981                     var type = contextualType;
45982                     while (type) {
45983                         var thisType = getThisTypeFromContextualType(type);
45984                         if (thisType) {
45985                             return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral)));
45986                         }
45987                         if (literal.parent.kind !== 281) {
45988                             break;
45989                         }
45990                         literal = literal.parent.parent;
45991                         type = getApparentTypeOfContextualType(literal);
45992                     }
45993                     return getWidenedType(contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral));
45994                 }
45995                 var parent = ts.walkUpParenthesizedExpressions(func.parent);
45996                 if (parent.kind === 209 && parent.operatorToken.kind === 62) {
45997                     var target = parent.left;
45998                     if (ts.isAccessExpression(target)) {
45999                         var expression = target.expression;
46000                         if (inJs && ts.isIdentifier(expression)) {
46001                             var sourceFile = ts.getSourceFileOfNode(parent);
46002                             if (sourceFile.commonJsModuleIndicator && getResolvedSymbol(expression) === sourceFile.symbol) {
46003                                 return undefined;
46004                             }
46005                         }
46006                         return getWidenedType(checkExpressionCached(expression));
46007                     }
46008                 }
46009             }
46010             return undefined;
46011         }
46012         function getContextuallyTypedParameterType(parameter) {
46013             var func = parameter.parent;
46014             if (!isContextSensitiveFunctionOrObjectLiteralMethod(func)) {
46015                 return undefined;
46016             }
46017             var iife = ts.getImmediatelyInvokedFunctionExpression(func);
46018             if (iife && iife.arguments) {
46019                 var args = getEffectiveCallArguments(iife);
46020                 var indexOfParameter = func.parameters.indexOf(parameter);
46021                 if (parameter.dotDotDotToken) {
46022                     return getSpreadArgumentType(args, indexOfParameter, args.length, anyType, undefined);
46023                 }
46024                 var links = getNodeLinks(iife);
46025                 var cached = links.resolvedSignature;
46026                 links.resolvedSignature = anySignature;
46027                 var type = indexOfParameter < args.length ?
46028                     getWidenedLiteralType(checkExpression(args[indexOfParameter])) :
46029                     parameter.initializer ? undefined : undefinedWideningType;
46030                 links.resolvedSignature = cached;
46031                 return type;
46032             }
46033             var contextualSignature = getContextualSignature(func);
46034             if (contextualSignature) {
46035                 var index = func.parameters.indexOf(parameter) - (ts.getThisParameter(func) ? 1 : 0);
46036                 return parameter.dotDotDotToken && ts.lastOrUndefined(func.parameters) === parameter ?
46037                     getRestTypeAtPosition(contextualSignature, index) :
46038                     tryGetTypeAtPosition(contextualSignature, index);
46039             }
46040         }
46041         function getContextualTypeForVariableLikeDeclaration(declaration) {
46042             var typeNode = ts.getEffectiveTypeAnnotationNode(declaration);
46043             if (typeNode) {
46044                 return getTypeFromTypeNode(typeNode);
46045             }
46046             switch (declaration.kind) {
46047                 case 156:
46048                     return getContextuallyTypedParameterType(declaration);
46049                 case 191:
46050                     return getContextualTypeForBindingElement(declaration);
46051             }
46052         }
46053         function getContextualTypeForBindingElement(declaration) {
46054             var parent = declaration.parent.parent;
46055             var name = declaration.propertyName || declaration.name;
46056             var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
46057                 parent.kind !== 191 && parent.initializer && checkDeclarationInitializer(parent);
46058             if (parentType && !ts.isBindingPattern(name) && !ts.isComputedNonLiteralName(name)) {
46059                 var nameType = getLiteralTypeFromPropertyName(name);
46060                 if (isTypeUsableAsPropertyName(nameType)) {
46061                     var text = getPropertyNameFromType(nameType);
46062                     return getTypeOfPropertyOfType(parentType, text);
46063                 }
46064             }
46065         }
46066         function getContextualTypeForInitializerExpression(node) {
46067             var declaration = node.parent;
46068             if (ts.hasInitializer(declaration) && node === declaration.initializer) {
46069                 var result = getContextualTypeForVariableLikeDeclaration(declaration);
46070                 if (result) {
46071                     return result;
46072                 }
46073                 if (ts.isBindingPattern(declaration.name)) {
46074                     return getTypeFromBindingPattern(declaration.name, true, false);
46075                 }
46076             }
46077             return undefined;
46078         }
46079         function getContextualTypeForReturnExpression(node) {
46080             var func = ts.getContainingFunction(node);
46081             if (func) {
46082                 var functionFlags = ts.getFunctionFlags(func);
46083                 if (functionFlags & 1) {
46084                     return undefined;
46085                 }
46086                 var contextualReturnType = getContextualReturnType(func);
46087                 if (contextualReturnType) {
46088                     if (functionFlags & 2) {
46089                         var contextualAwaitedType = mapType(contextualReturnType, getAwaitedTypeOfPromise);
46090                         return contextualAwaitedType && getUnionType([contextualAwaitedType, createPromiseLikeType(contextualAwaitedType)]);
46091                     }
46092                     return contextualReturnType;
46093                 }
46094             }
46095             return undefined;
46096         }
46097         function getContextualTypeForAwaitOperand(node) {
46098             var contextualType = getContextualType(node);
46099             if (contextualType) {
46100                 var contextualAwaitedType = getAwaitedType(contextualType);
46101                 return contextualAwaitedType && getUnionType([contextualAwaitedType, createPromiseLikeType(contextualAwaitedType)]);
46102             }
46103             return undefined;
46104         }
46105         function getContextualTypeForYieldOperand(node) {
46106             var func = ts.getContainingFunction(node);
46107             if (func) {
46108                 var functionFlags = ts.getFunctionFlags(func);
46109                 var contextualReturnType = getContextualReturnType(func);
46110                 if (contextualReturnType) {
46111                     return node.asteriskToken
46112                         ? contextualReturnType
46113                         : getIterationTypeOfGeneratorFunctionReturnType(0, contextualReturnType, (functionFlags & 2) !== 0);
46114                 }
46115             }
46116             return undefined;
46117         }
46118         function isInParameterInitializerBeforeContainingFunction(node) {
46119             var inBindingInitializer = false;
46120             while (node.parent && !ts.isFunctionLike(node.parent)) {
46121                 if (ts.isParameter(node.parent) && (inBindingInitializer || node.parent.initializer === node)) {
46122                     return true;
46123                 }
46124                 if (ts.isBindingElement(node.parent) && node.parent.initializer === node) {
46125                     inBindingInitializer = true;
46126                 }
46127                 node = node.parent;
46128             }
46129             return false;
46130         }
46131         function getContextualIterationType(kind, functionDecl) {
46132             var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2);
46133             var contextualReturnType = getContextualReturnType(functionDecl);
46134             if (contextualReturnType) {
46135                 return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync)
46136                     || undefined;
46137             }
46138             return undefined;
46139         }
46140         function getContextualReturnType(functionDecl) {
46141             var returnType = getReturnTypeFromAnnotation(functionDecl);
46142             if (returnType) {
46143                 return returnType;
46144             }
46145             var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl);
46146             if (signature && !isResolvingReturnTypeOfSignature(signature)) {
46147                 return getReturnTypeOfSignature(signature);
46148             }
46149             return undefined;
46150         }
46151         function getContextualTypeForArgument(callTarget, arg) {
46152             var args = getEffectiveCallArguments(callTarget);
46153             var argIndex = args.indexOf(arg);
46154             return argIndex === -1 ? undefined : getContextualTypeForArgumentAtIndex(callTarget, argIndex);
46155         }
46156         function getContextualTypeForArgumentAtIndex(callTarget, argIndex) {
46157             var signature = getNodeLinks(callTarget).resolvedSignature === resolvingSignature ? resolvingSignature : getResolvedSignature(callTarget);
46158             if (ts.isJsxOpeningLikeElement(callTarget) && argIndex === 0) {
46159                 return getEffectiveFirstArgumentForJsxSignature(signature, callTarget);
46160             }
46161             return getTypeAtPosition(signature, argIndex);
46162         }
46163         function getContextualTypeForSubstitutionExpression(template, substitutionExpression) {
46164             if (template.parent.kind === 198) {
46165                 return getContextualTypeForArgument(template.parent, substitutionExpression);
46166             }
46167             return undefined;
46168         }
46169         function getContextualTypeForBinaryOperand(node, contextFlags) {
46170             var binaryExpression = node.parent;
46171             var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right;
46172             switch (operatorToken.kind) {
46173                 case 62:
46174                     if (node !== right) {
46175                         return undefined;
46176                     }
46177                     var contextSensitive = getIsContextSensitiveAssignmentOrContextType(binaryExpression);
46178                     if (!contextSensitive) {
46179                         return undefined;
46180                     }
46181                     return contextSensitive === true ? getTypeOfExpression(left) : contextSensitive;
46182                 case 56:
46183                 case 60:
46184                     var type = getContextualType(binaryExpression, contextFlags);
46185                     return node === right && (type && type.pattern || !type && !ts.isDefaultedExpandoInitializer(binaryExpression)) ?
46186                         getTypeOfExpression(left) : type;
46187                 case 55:
46188                 case 27:
46189                     return node === right ? getContextualType(binaryExpression, contextFlags) : undefined;
46190                 default:
46191                     return undefined;
46192             }
46193         }
46194         function getIsContextSensitiveAssignmentOrContextType(binaryExpression) {
46195             var kind = ts.getAssignmentDeclarationKind(binaryExpression);
46196             switch (kind) {
46197                 case 0:
46198                     return true;
46199                 case 5:
46200                 case 1:
46201                 case 6:
46202                 case 3:
46203                     if (!binaryExpression.left.symbol) {
46204                         return true;
46205                     }
46206                     else {
46207                         var decl = binaryExpression.left.symbol.valueDeclaration;
46208                         if (!decl) {
46209                             return false;
46210                         }
46211                         var lhs = ts.cast(binaryExpression.left, ts.isAccessExpression);
46212                         var overallAnnotation = ts.getEffectiveTypeAnnotationNode(decl);
46213                         if (overallAnnotation) {
46214                             return getTypeFromTypeNode(overallAnnotation);
46215                         }
46216                         else if (ts.isIdentifier(lhs.expression)) {
46217                             var id = lhs.expression;
46218                             var parentSymbol = resolveName(id, id.escapedText, 111551, undefined, id.escapedText, true);
46219                             if (parentSymbol) {
46220                                 var annotated = ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration);
46221                                 if (annotated) {
46222                                     var nameStr_1 = ts.getElementOrPropertyAccessName(lhs);
46223                                     if (nameStr_1 !== undefined) {
46224                                         var type = getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), nameStr_1);
46225                                         return type || false;
46226                                     }
46227                                 }
46228                                 return false;
46229                             }
46230                         }
46231                         return !ts.isInJSFile(decl);
46232                     }
46233                 case 2:
46234                 case 4:
46235                     if (!binaryExpression.symbol)
46236                         return true;
46237                     if (binaryExpression.symbol.valueDeclaration) {
46238                         var annotated = ts.getEffectiveTypeAnnotationNode(binaryExpression.symbol.valueDeclaration);
46239                         if (annotated) {
46240                             var type = getTypeFromTypeNode(annotated);
46241                             if (type) {
46242                                 return type;
46243                             }
46244                         }
46245                     }
46246                     if (kind === 2)
46247                         return false;
46248                     var thisAccess = ts.cast(binaryExpression.left, ts.isAccessExpression);
46249                     if (!ts.isObjectLiteralMethod(ts.getThisContainer(thisAccess.expression, false))) {
46250                         return false;
46251                     }
46252                     var thisType = checkThisExpression(thisAccess.expression);
46253                     var nameStr = ts.getElementOrPropertyAccessName(thisAccess);
46254                     return nameStr !== undefined && thisType && getTypeOfPropertyOfContextualType(thisType, nameStr) || false;
46255                 case 7:
46256                 case 8:
46257                 case 9:
46258                     return ts.Debug.fail("Does not apply");
46259                 default:
46260                     return ts.Debug.assertNever(kind);
46261             }
46262         }
46263         function isCircularMappedProperty(symbol) {
46264             return !!(ts.getCheckFlags(symbol) & 262144 && !symbol.type && findResolutionCycleStartIndex(symbol, 0) >= 0);
46265         }
46266         function getTypeOfPropertyOfContextualType(type, name) {
46267             return mapType(type, function (t) {
46268                 if (isGenericMappedType(t)) {
46269                     var constraint = getConstraintTypeFromMappedType(t);
46270                     var constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
46271                     var propertyNameType = getLiteralType(ts.unescapeLeadingUnderscores(name));
46272                     if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
46273                         return substituteIndexedMappedType(t, propertyNameType);
46274                     }
46275                 }
46276                 else if (t.flags & 3670016) {
46277                     var prop = getPropertyOfType(t, name);
46278                     if (prop) {
46279                         return isCircularMappedProperty(prop) ? undefined : getTypeOfSymbol(prop);
46280                     }
46281                     if (isTupleType(t)) {
46282                         var restType = getRestTypeOfTupleType(t);
46283                         if (restType && isNumericLiteralName(name) && +name >= 0) {
46284                             return restType;
46285                         }
46286                     }
46287                     return isNumericLiteralName(name) && getIndexTypeOfContextualType(t, 1) ||
46288                         getIndexTypeOfContextualType(t, 0);
46289                 }
46290                 return undefined;
46291             }, true);
46292         }
46293         function getIndexTypeOfContextualType(type, kind) {
46294             return mapType(type, function (t) { return getIndexTypeOfStructuredType(t, kind); }, true);
46295         }
46296         function getContextualTypeForObjectLiteralMethod(node, contextFlags) {
46297             ts.Debug.assert(ts.isObjectLiteralMethod(node));
46298             if (node.flags & 16777216) {
46299                 return undefined;
46300             }
46301             return getContextualTypeForObjectLiteralElement(node, contextFlags);
46302         }
46303         function getContextualTypeForObjectLiteralElement(element, contextFlags) {
46304             var objectLiteral = element.parent;
46305             var type = getApparentTypeOfContextualType(objectLiteral, contextFlags);
46306             if (type) {
46307                 if (!hasNonBindableDynamicName(element)) {
46308                     var symbolName_3 = getSymbolOfNode(element).escapedName;
46309                     var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_3);
46310                     if (propertyType) {
46311                         return propertyType;
46312                     }
46313                 }
46314                 return isNumericName(element.name) && getIndexTypeOfContextualType(type, 1) ||
46315                     getIndexTypeOfContextualType(type, 0);
46316             }
46317             return undefined;
46318         }
46319         function getContextualTypeForElementExpression(arrayContextualType, index) {
46320             return arrayContextualType && (getTypeOfPropertyOfContextualType(arrayContextualType, "" + index)
46321                 || getIteratedTypeOrElementType(1, arrayContextualType, undefinedType, undefined, false));
46322         }
46323         function getContextualTypeForConditionalOperand(node, contextFlags) {
46324             var conditional = node.parent;
46325             return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional, contextFlags) : undefined;
46326         }
46327         function getContextualTypeForChildJsxExpression(node, child) {
46328             var attributesType = getApparentTypeOfContextualType(node.openingElement.tagName);
46329             var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node));
46330             if (!(attributesType && !isTypeAny(attributesType) && jsxChildrenPropertyName && jsxChildrenPropertyName !== "")) {
46331                 return undefined;
46332             }
46333             var realChildren = getSemanticJsxChildren(node.children);
46334             var childIndex = realChildren.indexOf(child);
46335             var childFieldType = getTypeOfPropertyOfContextualType(attributesType, jsxChildrenPropertyName);
46336             return childFieldType && (realChildren.length === 1 ? childFieldType : mapType(childFieldType, function (t) {
46337                 if (isArrayLikeType(t)) {
46338                     return getIndexedAccessType(t, getLiteralType(childIndex));
46339                 }
46340                 else {
46341                     return t;
46342                 }
46343             }, true));
46344         }
46345         function getContextualTypeForJsxExpression(node) {
46346             var exprParent = node.parent;
46347             return ts.isJsxAttributeLike(exprParent)
46348                 ? getContextualType(node)
46349                 : ts.isJsxElement(exprParent)
46350                     ? getContextualTypeForChildJsxExpression(exprParent, node)
46351                     : undefined;
46352         }
46353         function getContextualTypeForJsxAttribute(attribute) {
46354             if (ts.isJsxAttribute(attribute)) {
46355                 var attributesType = getApparentTypeOfContextualType(attribute.parent);
46356                 if (!attributesType || isTypeAny(attributesType)) {
46357                     return undefined;
46358                 }
46359                 return getTypeOfPropertyOfContextualType(attributesType, attribute.name.escapedText);
46360             }
46361             else {
46362                 return getContextualType(attribute.parent);
46363             }
46364         }
46365         function isPossiblyDiscriminantValue(node) {
46366             switch (node.kind) {
46367                 case 10:
46368                 case 8:
46369                 case 9:
46370                 case 14:
46371                 case 106:
46372                 case 91:
46373                 case 100:
46374                 case 75:
46375                 case 146:
46376                     return true;
46377                 case 194:
46378                 case 200:
46379                     return isPossiblyDiscriminantValue(node.expression);
46380                 case 276:
46381                     return !node.expression || isPossiblyDiscriminantValue(node.expression);
46382             }
46383             return false;
46384         }
46385         function discriminateContextualTypeByObjectMembers(node, contextualType) {
46386             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);
46387         }
46388         function discriminateContextualTypeByJSXAttributes(node, contextualType) {
46389             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);
46390         }
46391         function getApparentTypeOfContextualType(node, contextFlags) {
46392             var contextualType = ts.isObjectLiteralMethod(node) ?
46393                 getContextualTypeForObjectLiteralMethod(node, contextFlags) :
46394                 getContextualType(node, contextFlags);
46395             var instantiatedType = instantiateContextualType(contextualType, node, contextFlags);
46396             if (instantiatedType && !(contextFlags && contextFlags & 2 && instantiatedType.flags & 8650752)) {
46397                 var apparentType = mapType(instantiatedType, getApparentType, true);
46398                 if (apparentType.flags & 1048576) {
46399                     if (ts.isObjectLiteralExpression(node)) {
46400                         return discriminateContextualTypeByObjectMembers(node, apparentType);
46401                     }
46402                     else if (ts.isJsxAttributes(node)) {
46403                         return discriminateContextualTypeByJSXAttributes(node, apparentType);
46404                     }
46405                 }
46406                 return apparentType;
46407             }
46408         }
46409         function instantiateContextualType(contextualType, node, contextFlags) {
46410             if (contextualType && maybeTypeOfKind(contextualType, 63176704)) {
46411                 var inferenceContext = getInferenceContext(node);
46412                 if (inferenceContext && ts.some(inferenceContext.inferences, hasInferenceCandidates)) {
46413                     if (contextFlags && contextFlags & 1) {
46414                         return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
46415                     }
46416                     if (inferenceContext.returnMapper) {
46417                         return instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper);
46418                     }
46419                 }
46420             }
46421             return contextualType;
46422         }
46423         function instantiateInstantiableTypes(type, mapper) {
46424             if (type.flags & 63176704) {
46425                 return instantiateType(type, mapper);
46426             }
46427             if (type.flags & 1048576) {
46428                 return getUnionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }), 0);
46429             }
46430             if (type.flags & 2097152) {
46431                 return getIntersectionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }));
46432             }
46433             return type;
46434         }
46435         function getContextualType(node, contextFlags) {
46436             if (node.flags & 16777216) {
46437                 return undefined;
46438             }
46439             if (node.contextualType) {
46440                 return node.contextualType;
46441             }
46442             var parent = node.parent;
46443             switch (parent.kind) {
46444                 case 242:
46445                 case 156:
46446                 case 159:
46447                 case 158:
46448                 case 191:
46449                     return getContextualTypeForInitializerExpression(node);
46450                 case 202:
46451                 case 235:
46452                     return getContextualTypeForReturnExpression(node);
46453                 case 212:
46454                     return getContextualTypeForYieldOperand(parent);
46455                 case 206:
46456                     return getContextualTypeForAwaitOperand(parent);
46457                 case 196:
46458                     if (parent.expression.kind === 96) {
46459                         return stringType;
46460                     }
46461                 case 197:
46462                     return getContextualTypeForArgument(parent, node);
46463                 case 199:
46464                 case 217:
46465                     return ts.isConstTypeReference(parent.type) ? undefined : getTypeFromTypeNode(parent.type);
46466                 case 209:
46467                     return getContextualTypeForBinaryOperand(node, contextFlags);
46468                 case 281:
46469                 case 282:
46470                     return getContextualTypeForObjectLiteralElement(parent, contextFlags);
46471                 case 283:
46472                     return getApparentTypeOfContextualType(parent.parent, contextFlags);
46473                 case 192: {
46474                     var arrayLiteral = parent;
46475                     var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags);
46476                     return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node));
46477                 }
46478                 case 210:
46479                     return getContextualTypeForConditionalOperand(node, contextFlags);
46480                 case 221:
46481                     ts.Debug.assert(parent.parent.kind === 211);
46482                     return getContextualTypeForSubstitutionExpression(parent.parent, node);
46483                 case 200: {
46484                     var tag = ts.isInJSFile(parent) ? ts.getJSDocTypeTag(parent) : undefined;
46485                     return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent, contextFlags);
46486                 }
46487                 case 276:
46488                     return getContextualTypeForJsxExpression(parent);
46489                 case 273:
46490                 case 275:
46491                     return getContextualTypeForJsxAttribute(parent);
46492                 case 268:
46493                 case 267:
46494                     return getContextualJsxElementAttributesType(parent, contextFlags);
46495             }
46496             return undefined;
46497         }
46498         function getInferenceContext(node) {
46499             var ancestor = ts.findAncestor(node, function (n) { return !!n.inferenceContext; });
46500             return ancestor && ancestor.inferenceContext;
46501         }
46502         function getContextualJsxElementAttributesType(node, contextFlags) {
46503             if (ts.isJsxOpeningElement(node) && node.parent.contextualType && contextFlags !== 4) {
46504                 return node.parent.contextualType;
46505             }
46506             return getContextualTypeForArgumentAtIndex(node, 0);
46507         }
46508         function getEffectiveFirstArgumentForJsxSignature(signature, node) {
46509             return getJsxReferenceKind(node) !== 0
46510                 ? getJsxPropsTypeFromCallSignature(signature, node)
46511                 : getJsxPropsTypeFromClassType(signature, node);
46512         }
46513         function getJsxPropsTypeFromCallSignature(sig, context) {
46514             var propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, unknownType);
46515             propsType = getJsxManagedAttributesFromLocatedAttributes(context, getJsxNamespaceAt(context), propsType);
46516             var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context);
46517             if (intrinsicAttribs !== errorType) {
46518                 propsType = intersectTypes(intrinsicAttribs, propsType);
46519             }
46520             return propsType;
46521         }
46522         function getJsxPropsTypeForSignatureFromMember(sig, forcedLookupLocation) {
46523             if (sig.unionSignatures) {
46524                 var results = [];
46525                 for (var _i = 0, _a = sig.unionSignatures; _i < _a.length; _i++) {
46526                     var signature = _a[_i];
46527                     var instance = getReturnTypeOfSignature(signature);
46528                     if (isTypeAny(instance)) {
46529                         return instance;
46530                     }
46531                     var propType = getTypeOfPropertyOfType(instance, forcedLookupLocation);
46532                     if (!propType) {
46533                         return;
46534                     }
46535                     results.push(propType);
46536                 }
46537                 return getIntersectionType(results);
46538             }
46539             var instanceType = getReturnTypeOfSignature(sig);
46540             return isTypeAny(instanceType) ? instanceType : getTypeOfPropertyOfType(instanceType, forcedLookupLocation);
46541         }
46542         function getStaticTypeOfReferencedJsxConstructor(context) {
46543             if (isJsxIntrinsicIdentifier(context.tagName)) {
46544                 var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(context);
46545                 var fakeSignature = createSignatureForJSXIntrinsic(context, result);
46546                 return getOrCreateTypeFromSignature(fakeSignature);
46547             }
46548             var tagType = checkExpressionCached(context.tagName);
46549             if (tagType.flags & 128) {
46550                 var result = getIntrinsicAttributesTypeFromStringLiteralType(tagType, context);
46551                 if (!result) {
46552                     return errorType;
46553                 }
46554                 var fakeSignature = createSignatureForJSXIntrinsic(context, result);
46555                 return getOrCreateTypeFromSignature(fakeSignature);
46556             }
46557             return tagType;
46558         }
46559         function getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType) {
46560             var managedSym = getJsxLibraryManagedAttributes(ns);
46561             if (managedSym) {
46562                 var declaredManagedType = getDeclaredTypeOfSymbol(managedSym);
46563                 var ctorType = getStaticTypeOfReferencedJsxConstructor(context);
46564                 if (ts.length(declaredManagedType.typeParameters) >= 2) {
46565                     var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.typeParameters, 2, ts.isInJSFile(context));
46566                     return createTypeReference(declaredManagedType, args);
46567                 }
46568                 else if (ts.length(declaredManagedType.aliasTypeArguments) >= 2) {
46569                     var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.aliasTypeArguments, 2, ts.isInJSFile(context));
46570                     return getTypeAliasInstantiation(declaredManagedType.aliasSymbol, args);
46571                 }
46572             }
46573             return attributesType;
46574         }
46575         function getJsxPropsTypeFromClassType(sig, context) {
46576             var ns = getJsxNamespaceAt(context);
46577             var forcedLookupLocation = getJsxElementPropertiesName(ns);
46578             var attributesType = forcedLookupLocation === undefined
46579                 ? getTypeOfFirstParameterOfSignatureWithFallback(sig, unknownType)
46580                 : forcedLookupLocation === ""
46581                     ? getReturnTypeOfSignature(sig)
46582                     : getJsxPropsTypeForSignatureFromMember(sig, forcedLookupLocation);
46583             if (!attributesType) {
46584                 if (!!forcedLookupLocation && !!ts.length(context.attributes.properties)) {
46585                     error(context, ts.Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, ts.unescapeLeadingUnderscores(forcedLookupLocation));
46586                 }
46587                 return unknownType;
46588             }
46589             attributesType = getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType);
46590             if (isTypeAny(attributesType)) {
46591                 return attributesType;
46592             }
46593             else {
46594                 var apparentAttributesType = attributesType;
46595                 var intrinsicClassAttribs = getJsxType(JsxNames.IntrinsicClassAttributes, context);
46596                 if (intrinsicClassAttribs !== errorType) {
46597                     var typeParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol);
46598                     var hostClassType = getReturnTypeOfSignature(sig);
46599                     apparentAttributesType = intersectTypes(typeParams
46600                         ? createTypeReference(intrinsicClassAttribs, fillMissingTypeArguments([hostClassType], typeParams, getMinTypeArgumentCount(typeParams), ts.isInJSFile(context)))
46601                         : intrinsicClassAttribs, apparentAttributesType);
46602                 }
46603                 var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context);
46604                 if (intrinsicAttribs !== errorType) {
46605                     apparentAttributesType = intersectTypes(intrinsicAttribs, apparentAttributesType);
46606                 }
46607                 return apparentAttributesType;
46608             }
46609         }
46610         function getContextualCallSignature(type, node) {
46611             var signatures = getSignaturesOfType(type, 0);
46612             if (signatures.length === 1) {
46613                 var signature = signatures[0];
46614                 if (!isAritySmaller(signature, node)) {
46615                     return signature;
46616                 }
46617             }
46618         }
46619         function isAritySmaller(signature, target) {
46620             var targetParameterCount = 0;
46621             for (; targetParameterCount < target.parameters.length; targetParameterCount++) {
46622                 var param = target.parameters[targetParameterCount];
46623                 if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) {
46624                     break;
46625                 }
46626             }
46627             if (target.parameters.length && ts.parameterIsThisKeyword(target.parameters[0])) {
46628                 targetParameterCount--;
46629             }
46630             return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount;
46631         }
46632         function isFunctionExpressionOrArrowFunction(node) {
46633             return node.kind === 201 || node.kind === 202;
46634         }
46635         function getContextualSignatureForFunctionLikeDeclaration(node) {
46636             return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node)
46637                 ? getContextualSignature(node)
46638                 : undefined;
46639         }
46640         function getContextualSignature(node) {
46641             ts.Debug.assert(node.kind !== 161 || ts.isObjectLiteralMethod(node));
46642             var typeTagSignature = getSignatureOfTypeTag(node);
46643             if (typeTagSignature) {
46644                 return typeTagSignature;
46645             }
46646             var type = getApparentTypeOfContextualType(node, 1);
46647             if (!type) {
46648                 return undefined;
46649             }
46650             if (!(type.flags & 1048576)) {
46651                 return getContextualCallSignature(type, node);
46652             }
46653             var signatureList;
46654             var types = type.types;
46655             for (var _i = 0, types_17 = types; _i < types_17.length; _i++) {
46656                 var current = types_17[_i];
46657                 var signature = getContextualCallSignature(current, node);
46658                 if (signature) {
46659                     if (!signatureList) {
46660                         signatureList = [signature];
46661                     }
46662                     else if (!compareSignaturesIdentical(signatureList[0], signature, false, true, true, compareTypesIdentical)) {
46663                         return undefined;
46664                     }
46665                     else {
46666                         signatureList.push(signature);
46667                     }
46668                 }
46669             }
46670             if (signatureList) {
46671                 return signatureList.length === 1 ? signatureList[0] : createUnionSignature(signatureList[0], signatureList);
46672             }
46673         }
46674         function checkSpreadExpression(node, checkMode) {
46675             if (languageVersion < 2) {
46676                 checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 : 2048);
46677             }
46678             var arrayOrIterableType = checkExpression(node.expression, checkMode);
46679             return checkIteratedTypeOrElementType(33, arrayOrIterableType, undefinedType, node.expression);
46680         }
46681         function hasDefaultValue(node) {
46682             return (node.kind === 191 && !!node.initializer) ||
46683                 (node.kind === 209 && node.operatorToken.kind === 62);
46684         }
46685         function checkArrayLiteral(node, checkMode, forceTuple) {
46686             var elements = node.elements;
46687             var elementCount = elements.length;
46688             var elementTypes = [];
46689             var hasEndingSpreadElement = false;
46690             var hasNonEndingSpreadElement = false;
46691             var contextualType = getApparentTypeOfContextualType(node);
46692             var inDestructuringPattern = ts.isAssignmentTarget(node);
46693             var inConstContext = isConstContext(node);
46694             for (var i = 0; i < elementCount; i++) {
46695                 var e = elements[i];
46696                 var spread = e.kind === 213 && e.expression;
46697                 var spreadType = spread && checkExpression(spread, checkMode, forceTuple);
46698                 if (spreadType && isTupleType(spreadType)) {
46699                     elementTypes.push.apply(elementTypes, getTypeArguments(spreadType));
46700                     if (spreadType.target.hasRestElement) {
46701                         if (i === elementCount - 1)
46702                             hasEndingSpreadElement = true;
46703                         else
46704                             hasNonEndingSpreadElement = true;
46705                     }
46706                 }
46707                 else {
46708                     if (inDestructuringPattern && spreadType) {
46709                         var restElementType = getIndexTypeOfType(spreadType, 1) ||
46710                             getIteratedTypeOrElementType(65, spreadType, undefinedType, undefined, false);
46711                         if (restElementType) {
46712                             elementTypes.push(restElementType);
46713                         }
46714                     }
46715                     else {
46716                         var elementContextualType = getContextualTypeForElementExpression(contextualType, elementTypes.length);
46717                         var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple);
46718                         elementTypes.push(type);
46719                     }
46720                     if (spread) {
46721                         if (i === elementCount - 1)
46722                             hasEndingSpreadElement = true;
46723                         else
46724                             hasNonEndingSpreadElement = true;
46725                     }
46726                 }
46727             }
46728             if (!hasNonEndingSpreadElement) {
46729                 var minLength = elementTypes.length - (hasEndingSpreadElement ? 1 : 0);
46730                 var tupleResult = void 0;
46731                 if (inDestructuringPattern && minLength > 0) {
46732                     var type = cloneTypeReference(createTupleType(elementTypes, minLength, hasEndingSpreadElement));
46733                     type.pattern = node;
46734                     return type;
46735                 }
46736                 else if (tupleResult = getArrayLiteralTupleTypeIfApplicable(elementTypes, contextualType, hasEndingSpreadElement, elementTypes.length, inConstContext)) {
46737                     return createArrayLiteralType(tupleResult);
46738                 }
46739                 else if (forceTuple) {
46740                     return createArrayLiteralType(createTupleType(elementTypes, minLength, hasEndingSpreadElement));
46741                 }
46742             }
46743             return createArrayLiteralType(createArrayType(elementTypes.length ?
46744                 getUnionType(elementTypes, 2) :
46745                 strictNullChecks ? implicitNeverType : undefinedWideningType, inConstContext));
46746         }
46747         function createArrayLiteralType(type) {
46748             if (!(ts.getObjectFlags(type) & 4)) {
46749                 return type;
46750             }
46751             var literalType = type.literalType;
46752             if (!literalType) {
46753                 literalType = type.literalType = cloneTypeReference(type);
46754                 literalType.objectFlags |= 65536 | 1048576;
46755             }
46756             return literalType;
46757         }
46758         function getArrayLiteralTupleTypeIfApplicable(elementTypes, contextualType, hasRestElement, elementCount, readonly) {
46759             if (elementCount === void 0) { elementCount = elementTypes.length; }
46760             if (readonly === void 0) { readonly = false; }
46761             if (readonly || (contextualType && forEachType(contextualType, isTupleLikeType))) {
46762                 return createTupleType(elementTypes, elementCount - (hasRestElement ? 1 : 0), hasRestElement, readonly);
46763             }
46764         }
46765         function isNumericName(name) {
46766             switch (name.kind) {
46767                 case 154:
46768                     return isNumericComputedName(name);
46769                 case 75:
46770                     return isNumericLiteralName(name.escapedText);
46771                 case 8:
46772                 case 10:
46773                     return isNumericLiteralName(name.text);
46774                 default:
46775                     return false;
46776             }
46777         }
46778         function isNumericComputedName(name) {
46779             return isTypeAssignableToKind(checkComputedPropertyName(name), 296);
46780         }
46781         function isInfinityOrNaNString(name) {
46782             return name === "Infinity" || name === "-Infinity" || name === "NaN";
46783         }
46784         function isNumericLiteralName(name) {
46785             return (+name).toString() === name;
46786         }
46787         function checkComputedPropertyName(node) {
46788             var links = getNodeLinks(node.expression);
46789             if (!links.resolvedType) {
46790                 links.resolvedType = checkExpression(node.expression);
46791                 if (links.resolvedType.flags & 98304 ||
46792                     !isTypeAssignableToKind(links.resolvedType, 132 | 296 | 12288) &&
46793                         !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) {
46794                     error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any);
46795                 }
46796                 else {
46797                     checkThatExpressionIsProperSymbolReference(node.expression, links.resolvedType, true);
46798                 }
46799             }
46800             return links.resolvedType;
46801         }
46802         function getObjectLiteralIndexInfo(node, offset, properties, kind) {
46803             var propTypes = [];
46804             for (var i = 0; i < properties.length; i++) {
46805                 if (kind === 0 || isNumericName(node.properties[i + offset].name)) {
46806                     propTypes.push(getTypeOfSymbol(properties[i]));
46807                 }
46808             }
46809             var unionType = propTypes.length ? getUnionType(propTypes, 2) : undefinedType;
46810             return createIndexInfo(unionType, isConstContext(node));
46811         }
46812         function getImmediateAliasedSymbol(symbol) {
46813             ts.Debug.assert((symbol.flags & 2097152) !== 0, "Should only get Alias here.");
46814             var links = getSymbolLinks(symbol);
46815             if (!links.immediateTarget) {
46816                 var node = getDeclarationOfAliasSymbol(symbol);
46817                 if (!node)
46818                     return ts.Debug.fail();
46819                 links.immediateTarget = getTargetOfAliasDeclaration(node, true);
46820             }
46821             return links.immediateTarget;
46822         }
46823         function checkObjectLiteral(node, checkMode) {
46824             var inDestructuringPattern = ts.isAssignmentTarget(node);
46825             checkGrammarObjectLiteralExpression(node, inDestructuringPattern);
46826             var allPropertiesTable = strictNullChecks ? ts.createSymbolTable() : undefined;
46827             var propertiesTable = ts.createSymbolTable();
46828             var propertiesArray = [];
46829             var spread = emptyObjectType;
46830             var contextualType = getApparentTypeOfContextualType(node);
46831             var contextualTypeHasPattern = contextualType && contextualType.pattern &&
46832                 (contextualType.pattern.kind === 189 || contextualType.pattern.kind === 193);
46833             var inConstContext = isConstContext(node);
46834             var checkFlags = inConstContext ? 8 : 0;
46835             var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node);
46836             var enumTag = ts.getJSDocEnumTag(node);
46837             var isJSObjectLiteral = !contextualType && isInJavascript && !enumTag;
46838             var objectFlags = freshObjectLiteralFlag;
46839             var patternWithComputedProperties = false;
46840             var hasComputedStringProperty = false;
46841             var hasComputedNumberProperty = false;
46842             for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
46843                 var elem = _a[_i];
46844                 if (elem.name && ts.isComputedPropertyName(elem.name) && !ts.isWellKnownSymbolSyntactically(elem.name)) {
46845                     checkComputedPropertyName(elem.name);
46846                 }
46847             }
46848             var offset = 0;
46849             for (var i = 0; i < node.properties.length; i++) {
46850                 var memberDecl = node.properties[i];
46851                 var member = getSymbolOfNode(memberDecl);
46852                 var computedNameType = memberDecl.name && memberDecl.name.kind === 154 && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ?
46853                     checkComputedPropertyName(memberDecl.name) : undefined;
46854                 if (memberDecl.kind === 281 ||
46855                     memberDecl.kind === 282 ||
46856                     ts.isObjectLiteralMethod(memberDecl)) {
46857                     var type = memberDecl.kind === 281 ? checkPropertyAssignment(memberDecl, checkMode) :
46858                         memberDecl.kind === 282 ? checkExpressionForMutableLocation(memberDecl.name, checkMode) :
46859                             checkObjectLiteralMethod(memberDecl, checkMode);
46860                     if (isInJavascript) {
46861                         var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl);
46862                         if (jsDocType) {
46863                             checkTypeAssignableTo(type, jsDocType, memberDecl);
46864                             type = jsDocType;
46865                         }
46866                         else if (enumTag && enumTag.typeExpression) {
46867                             checkTypeAssignableTo(type, getTypeFromTypeNode(enumTag.typeExpression), memberDecl);
46868                         }
46869                     }
46870                     objectFlags |= ts.getObjectFlags(type) & 3670016;
46871                     var nameType = computedNameType && isTypeUsableAsPropertyName(computedNameType) ? computedNameType : undefined;
46872                     var prop = nameType ?
46873                         createSymbol(4 | member.flags, getPropertyNameFromType(nameType), checkFlags | 4096) :
46874                         createSymbol(4 | member.flags, member.escapedName, checkFlags);
46875                     if (nameType) {
46876                         prop.nameType = nameType;
46877                     }
46878                     if (inDestructuringPattern) {
46879                         var isOptional = (memberDecl.kind === 281 && hasDefaultValue(memberDecl.initializer)) ||
46880                             (memberDecl.kind === 282 && memberDecl.objectAssignmentInitializer);
46881                         if (isOptional) {
46882                             prop.flags |= 16777216;
46883                         }
46884                     }
46885                     else if (contextualTypeHasPattern && !(ts.getObjectFlags(contextualType) & 512)) {
46886                         var impliedProp = getPropertyOfType(contextualType, member.escapedName);
46887                         if (impliedProp) {
46888                             prop.flags |= impliedProp.flags & 16777216;
46889                         }
46890                         else if (!compilerOptions.suppressExcessPropertyErrors && !getIndexInfoOfType(contextualType, 0)) {
46891                             error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType));
46892                         }
46893                     }
46894                     prop.declarations = member.declarations;
46895                     prop.parent = member.parent;
46896                     if (member.valueDeclaration) {
46897                         prop.valueDeclaration = member.valueDeclaration;
46898                     }
46899                     prop.type = type;
46900                     prop.target = member;
46901                     member = prop;
46902                     allPropertiesTable === null || allPropertiesTable === void 0 ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
46903                 }
46904                 else if (memberDecl.kind === 283) {
46905                     if (languageVersion < 2) {
46906                         checkExternalEmitHelpers(memberDecl, 2);
46907                     }
46908                     if (propertiesArray.length > 0) {
46909                         spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, objectFlags, inConstContext);
46910                         propertiesArray = [];
46911                         propertiesTable = ts.createSymbolTable();
46912                         hasComputedStringProperty = false;
46913                         hasComputedNumberProperty = false;
46914                     }
46915                     var type = getReducedType(checkExpression(memberDecl.expression));
46916                     if (!isValidSpreadType(type)) {
46917                         error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types);
46918                         return errorType;
46919                     }
46920                     if (allPropertiesTable) {
46921                         checkSpreadPropOverrides(type, allPropertiesTable, memberDecl);
46922                     }
46923                     spread = getSpreadType(spread, type, node.symbol, objectFlags, inConstContext);
46924                     offset = i + 1;
46925                     continue;
46926                 }
46927                 else {
46928                     ts.Debug.assert(memberDecl.kind === 163 || memberDecl.kind === 164);
46929                     checkNodeDeferred(memberDecl);
46930                 }
46931                 if (computedNameType && !(computedNameType.flags & 8576)) {
46932                     if (isTypeAssignableTo(computedNameType, stringNumberSymbolType)) {
46933                         if (isTypeAssignableTo(computedNameType, numberType)) {
46934                             hasComputedNumberProperty = true;
46935                         }
46936                         else {
46937                             hasComputedStringProperty = true;
46938                         }
46939                         if (inDestructuringPattern) {
46940                             patternWithComputedProperties = true;
46941                         }
46942                     }
46943                 }
46944                 else {
46945                     propertiesTable.set(member.escapedName, member);
46946                 }
46947                 propertiesArray.push(member);
46948             }
46949             if (contextualTypeHasPattern && node.parent.kind !== 283) {
46950                 for (var _b = 0, _c = getPropertiesOfType(contextualType); _b < _c.length; _b++) {
46951                     var prop = _c[_b];
46952                     if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) {
46953                         if (!(prop.flags & 16777216)) {
46954                             error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
46955                         }
46956                         propertiesTable.set(prop.escapedName, prop);
46957                         propertiesArray.push(prop);
46958                     }
46959                 }
46960             }
46961             if (spread !== emptyObjectType) {
46962                 if (propertiesArray.length > 0) {
46963                     spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, objectFlags, inConstContext);
46964                     propertiesArray = [];
46965                     propertiesTable = ts.createSymbolTable();
46966                     hasComputedStringProperty = false;
46967                     hasComputedNumberProperty = false;
46968                 }
46969                 return mapType(spread, function (t) { return t === emptyObjectType ? createObjectLiteralType() : t; });
46970             }
46971             return createObjectLiteralType();
46972             function createObjectLiteralType() {
46973                 var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node, offset, propertiesArray, 0) : undefined;
46974                 var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, offset, propertiesArray, 1) : undefined;
46975                 var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo);
46976                 result.objectFlags |= objectFlags | 128 | 1048576;
46977                 if (isJSObjectLiteral) {
46978                     result.objectFlags |= 16384;
46979                 }
46980                 if (patternWithComputedProperties) {
46981                     result.objectFlags |= 512;
46982                 }
46983                 if (inDestructuringPattern) {
46984                     result.pattern = node;
46985                 }
46986                 return result;
46987             }
46988         }
46989         function isValidSpreadType(type) {
46990             if (type.flags & 63176704) {
46991                 var constraint = getBaseConstraintOfType(type);
46992                 if (constraint !== undefined) {
46993                     return isValidSpreadType(constraint);
46994                 }
46995             }
46996             return !!(type.flags & (1 | 67108864 | 524288 | 58982400) ||
46997                 getFalsyFlags(type) & 117632 && isValidSpreadType(removeDefinitelyFalsyTypes(type)) ||
46998                 type.flags & 3145728 && ts.every(type.types, isValidSpreadType));
46999         }
47000         function checkJsxSelfClosingElementDeferred(node) {
47001             checkJsxOpeningLikeElementOrOpeningFragment(node);
47002             resolveUntypedCall(node);
47003         }
47004         function checkJsxSelfClosingElement(node, _checkMode) {
47005             checkNodeDeferred(node);
47006             return getJsxElementTypeAt(node) || anyType;
47007         }
47008         function checkJsxElementDeferred(node) {
47009             checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement);
47010             if (isJsxIntrinsicIdentifier(node.closingElement.tagName)) {
47011                 getIntrinsicTagSymbol(node.closingElement);
47012             }
47013             else {
47014                 checkExpression(node.closingElement.tagName);
47015             }
47016             checkJsxChildren(node);
47017         }
47018         function checkJsxElement(node, _checkMode) {
47019             checkNodeDeferred(node);
47020             return getJsxElementTypeAt(node) || anyType;
47021         }
47022         function checkJsxFragment(node) {
47023             checkJsxOpeningLikeElementOrOpeningFragment(node.openingFragment);
47024             if (compilerOptions.jsx === 2 && (compilerOptions.jsxFactory || ts.getSourceFileOfNode(node).pragmas.has("jsx"))) {
47025                 error(node, compilerOptions.jsxFactory
47026                     ? ts.Diagnostics.JSX_fragment_is_not_supported_when_using_jsxFactory
47027                     : ts.Diagnostics.JSX_fragment_is_not_supported_when_using_an_inline_JSX_factory_pragma);
47028             }
47029             checkJsxChildren(node);
47030             return getJsxElementTypeAt(node) || anyType;
47031         }
47032         function isUnhyphenatedJsxName(name) {
47033             return !ts.stringContains(name, "-");
47034         }
47035         function isJsxIntrinsicIdentifier(tagName) {
47036             return tagName.kind === 75 && ts.isIntrinsicJsxName(tagName.escapedText);
47037         }
47038         function checkJsxAttribute(node, checkMode) {
47039             return node.initializer
47040                 ? checkExpressionForMutableLocation(node.initializer, checkMode)
47041                 : trueType;
47042         }
47043         function createJsxAttributesTypeFromAttributesProperty(openingLikeElement, checkMode) {
47044             var attributes = openingLikeElement.attributes;
47045             var allAttributesTable = strictNullChecks ? ts.createSymbolTable() : undefined;
47046             var attributesTable = ts.createSymbolTable();
47047             var spread = emptyJsxObjectType;
47048             var hasSpreadAnyType = false;
47049             var typeToIntersect;
47050             var explicitlySpecifyChildrenAttribute = false;
47051             var objectFlags = 4096;
47052             var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(openingLikeElement));
47053             for (var _i = 0, _a = attributes.properties; _i < _a.length; _i++) {
47054                 var attributeDecl = _a[_i];
47055                 var member = attributeDecl.symbol;
47056                 if (ts.isJsxAttribute(attributeDecl)) {
47057                     var exprType = checkJsxAttribute(attributeDecl, checkMode);
47058                     objectFlags |= ts.getObjectFlags(exprType) & 3670016;
47059                     var attributeSymbol = createSymbol(4 | 33554432 | member.flags, member.escapedName);
47060                     attributeSymbol.declarations = member.declarations;
47061                     attributeSymbol.parent = member.parent;
47062                     if (member.valueDeclaration) {
47063                         attributeSymbol.valueDeclaration = member.valueDeclaration;
47064                     }
47065                     attributeSymbol.type = exprType;
47066                     attributeSymbol.target = member;
47067                     attributesTable.set(attributeSymbol.escapedName, attributeSymbol);
47068                     allAttributesTable === null || allAttributesTable === void 0 ? void 0 : allAttributesTable.set(attributeSymbol.escapedName, attributeSymbol);
47069                     if (attributeDecl.name.escapedText === jsxChildrenPropertyName) {
47070                         explicitlySpecifyChildrenAttribute = true;
47071                     }
47072                 }
47073                 else {
47074                     ts.Debug.assert(attributeDecl.kind === 275);
47075                     if (attributesTable.size > 0) {
47076                         spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, false);
47077                         attributesTable = ts.createSymbolTable();
47078                     }
47079                     var exprType = getReducedType(checkExpressionCached(attributeDecl.expression, checkMode));
47080                     if (isTypeAny(exprType)) {
47081                         hasSpreadAnyType = true;
47082                     }
47083                     if (isValidSpreadType(exprType)) {
47084                         spread = getSpreadType(spread, exprType, attributes.symbol, objectFlags, false);
47085                         if (allAttributesTable) {
47086                             checkSpreadPropOverrides(exprType, allAttributesTable, attributeDecl);
47087                         }
47088                     }
47089                     else {
47090                         typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType;
47091                     }
47092                 }
47093             }
47094             if (!hasSpreadAnyType) {
47095                 if (attributesTable.size > 0) {
47096                     spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, false);
47097                 }
47098             }
47099             var parent = openingLikeElement.parent.kind === 266 ? openingLikeElement.parent : undefined;
47100             if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) {
47101                 var childrenTypes = checkJsxChildren(parent, checkMode);
47102                 if (!hasSpreadAnyType && jsxChildrenPropertyName && jsxChildrenPropertyName !== "") {
47103                     if (explicitlySpecifyChildrenAttribute) {
47104                         error(attributes, ts.Diagnostics._0_are_specified_twice_The_attribute_named_0_will_be_overwritten, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName));
47105                     }
47106                     var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes);
47107                     var childrenContextualType = contextualType && getTypeOfPropertyOfContextualType(contextualType, jsxChildrenPropertyName);
47108                     var childrenPropSymbol = createSymbol(4 | 33554432, jsxChildrenPropertyName);
47109                     childrenPropSymbol.type = childrenTypes.length === 1 ?
47110                         childrenTypes[0] :
47111                         (getArrayLiteralTupleTypeIfApplicable(childrenTypes, childrenContextualType, false) || createArrayType(getUnionType(childrenTypes)));
47112                     childrenPropSymbol.valueDeclaration = ts.createPropertySignature(undefined, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName), undefined, undefined, undefined);
47113                     childrenPropSymbol.valueDeclaration.parent = attributes;
47114                     childrenPropSymbol.valueDeclaration.symbol = childrenPropSymbol;
47115                     var childPropMap = ts.createSymbolTable();
47116                     childPropMap.set(jsxChildrenPropertyName, childrenPropSymbol);
47117                     spread = getSpreadType(spread, createAnonymousType(attributes.symbol, childPropMap, ts.emptyArray, ts.emptyArray, undefined, undefined), attributes.symbol, objectFlags, false);
47118                 }
47119             }
47120             if (hasSpreadAnyType) {
47121                 return anyType;
47122             }
47123             if (typeToIntersect && spread !== emptyJsxObjectType) {
47124                 return getIntersectionType([typeToIntersect, spread]);
47125             }
47126             return typeToIntersect || (spread === emptyJsxObjectType ? createJsxAttributesType() : spread);
47127             function createJsxAttributesType() {
47128                 objectFlags |= freshObjectLiteralFlag;
47129                 var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, undefined, undefined);
47130                 result.objectFlags |= objectFlags | 128 | 1048576;
47131                 return result;
47132             }
47133         }
47134         function checkJsxChildren(node, checkMode) {
47135             var childrenTypes = [];
47136             for (var _i = 0, _a = node.children; _i < _a.length; _i++) {
47137                 var child = _a[_i];
47138                 if (child.kind === 11) {
47139                     if (!child.containsOnlyTriviaWhiteSpaces) {
47140                         childrenTypes.push(stringType);
47141                     }
47142                 }
47143                 else {
47144                     childrenTypes.push(checkExpressionForMutableLocation(child, checkMode));
47145                 }
47146             }
47147             return childrenTypes;
47148         }
47149         function checkSpreadPropOverrides(type, props, spread) {
47150             for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) {
47151                 var right = _a[_i];
47152                 var left = props.get(right.escapedName);
47153                 var rightType = getTypeOfSymbol(right);
47154                 if (left && !maybeTypeOfKind(rightType, 98304) && !(maybeTypeOfKind(rightType, 3) && right.flags & 16777216)) {
47155                     var diagnostic = error(left.valueDeclaration, ts.Diagnostics._0_is_specified_more_than_once_so_this_usage_will_be_overwritten, ts.unescapeLeadingUnderscores(left.escapedName));
47156                     ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(spread, ts.Diagnostics.This_spread_always_overwrites_this_property));
47157                 }
47158             }
47159         }
47160         function checkJsxAttributes(node, checkMode) {
47161             return createJsxAttributesTypeFromAttributesProperty(node.parent, checkMode);
47162         }
47163         function getJsxType(name, location) {
47164             var namespace = getJsxNamespaceAt(location);
47165             var exports = namespace && getExportsOfSymbol(namespace);
47166             var typeSymbol = exports && getSymbol(exports, name, 788968);
47167             return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType;
47168         }
47169         function getIntrinsicTagSymbol(node) {
47170             var links = getNodeLinks(node);
47171             if (!links.resolvedSymbol) {
47172                 var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, node);
47173                 if (intrinsicElementsType !== errorType) {
47174                     if (!ts.isIdentifier(node.tagName))
47175                         return ts.Debug.fail();
47176                     var intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.escapedText);
47177                     if (intrinsicProp) {
47178                         links.jsxFlags |= 1;
47179                         return links.resolvedSymbol = intrinsicProp;
47180                     }
47181                     var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0);
47182                     if (indexSignatureType) {
47183                         links.jsxFlags |= 2;
47184                         return links.resolvedSymbol = intrinsicElementsType.symbol;
47185                     }
47186                     error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.idText(node.tagName), "JSX." + JsxNames.IntrinsicElements);
47187                     return links.resolvedSymbol = unknownSymbol;
47188                 }
47189                 else {
47190                     if (noImplicitAny) {
47191                         error(node, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, ts.unescapeLeadingUnderscores(JsxNames.IntrinsicElements));
47192                     }
47193                     return links.resolvedSymbol = unknownSymbol;
47194                 }
47195             }
47196             return links.resolvedSymbol;
47197         }
47198         function getJsxNamespaceAt(location) {
47199             var links = location && getNodeLinks(location);
47200             if (links && links.jsxNamespace) {
47201                 return links.jsxNamespace;
47202             }
47203             if (!links || links.jsxNamespace !== false) {
47204                 var namespaceName = getJsxNamespace(location);
47205                 var resolvedNamespace = resolveName(location, namespaceName, 1920, undefined, namespaceName, false);
47206                 if (resolvedNamespace) {
47207                     var candidate = resolveSymbol(getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920));
47208                     if (candidate) {
47209                         if (links) {
47210                             links.jsxNamespace = candidate;
47211                         }
47212                         return candidate;
47213                     }
47214                     if (links) {
47215                         links.jsxNamespace = false;
47216                     }
47217                 }
47218             }
47219             return getGlobalSymbol(JsxNames.JSX, 1920, undefined);
47220         }
47221         function getNameFromJsxElementAttributesContainer(nameOfAttribPropContainer, jsxNamespace) {
47222             var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968);
47223             var jsxElementAttribPropInterfaceType = jsxElementAttribPropInterfaceSym && getDeclaredTypeOfSymbol(jsxElementAttribPropInterfaceSym);
47224             var propertiesOfJsxElementAttribPropInterface = jsxElementAttribPropInterfaceType && getPropertiesOfType(jsxElementAttribPropInterfaceType);
47225             if (propertiesOfJsxElementAttribPropInterface) {
47226                 if (propertiesOfJsxElementAttribPropInterface.length === 0) {
47227                     return "";
47228                 }
47229                 else if (propertiesOfJsxElementAttribPropInterface.length === 1) {
47230                     return propertiesOfJsxElementAttribPropInterface[0].escapedName;
47231                 }
47232                 else if (propertiesOfJsxElementAttribPropInterface.length > 1) {
47233                     error(jsxElementAttribPropInterfaceSym.declarations[0], ts.Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, ts.unescapeLeadingUnderscores(nameOfAttribPropContainer));
47234                 }
47235             }
47236             return undefined;
47237         }
47238         function getJsxLibraryManagedAttributes(jsxNamespace) {
47239             return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968);
47240         }
47241         function getJsxElementPropertiesName(jsxNamespace) {
47242             return getNameFromJsxElementAttributesContainer(JsxNames.ElementAttributesPropertyNameContainer, jsxNamespace);
47243         }
47244         function getJsxElementChildrenPropertyName(jsxNamespace) {
47245             return getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer, jsxNamespace);
47246         }
47247         function getUninstantiatedJsxSignaturesOfType(elementType, caller) {
47248             if (elementType.flags & 4) {
47249                 return [anySignature];
47250             }
47251             else if (elementType.flags & 128) {
47252                 var intrinsicType = getIntrinsicAttributesTypeFromStringLiteralType(elementType, caller);
47253                 if (!intrinsicType) {
47254                     error(caller, ts.Diagnostics.Property_0_does_not_exist_on_type_1, elementType.value, "JSX." + JsxNames.IntrinsicElements);
47255                     return ts.emptyArray;
47256                 }
47257                 else {
47258                     var fakeSignature = createSignatureForJSXIntrinsic(caller, intrinsicType);
47259                     return [fakeSignature];
47260                 }
47261             }
47262             var apparentElemType = getApparentType(elementType);
47263             var signatures = getSignaturesOfType(apparentElemType, 1);
47264             if (signatures.length === 0) {
47265                 signatures = getSignaturesOfType(apparentElemType, 0);
47266             }
47267             if (signatures.length === 0 && apparentElemType.flags & 1048576) {
47268                 signatures = getUnionSignatures(ts.map(apparentElemType.types, function (t) { return getUninstantiatedJsxSignaturesOfType(t, caller); }));
47269             }
47270             return signatures;
47271         }
47272         function getIntrinsicAttributesTypeFromStringLiteralType(type, location) {
47273             var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, location);
47274             if (intrinsicElementsType !== errorType) {
47275                 var stringLiteralTypeName = type.value;
47276                 var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName));
47277                 if (intrinsicProp) {
47278                     return getTypeOfSymbol(intrinsicProp);
47279                 }
47280                 var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0);
47281                 if (indexSignatureType) {
47282                     return indexSignatureType;
47283                 }
47284                 return undefined;
47285             }
47286             return anyType;
47287         }
47288         function checkJsxReturnAssignableToAppropriateBound(refKind, elemInstanceType, openingLikeElement) {
47289             if (refKind === 1) {
47290                 var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement);
47291                 if (sfcReturnConstraint) {
47292                     checkTypeRelatedTo(elemInstanceType, sfcReturnConstraint, assignableRelation, openingLikeElement.tagName, ts.Diagnostics.Its_return_type_0_is_not_a_valid_JSX_element, generateInitialErrorChain);
47293                 }
47294             }
47295             else if (refKind === 0) {
47296                 var classConstraint = getJsxElementClassTypeAt(openingLikeElement);
47297                 if (classConstraint) {
47298                     checkTypeRelatedTo(elemInstanceType, classConstraint, assignableRelation, openingLikeElement.tagName, ts.Diagnostics.Its_instance_type_0_is_not_a_valid_JSX_element, generateInitialErrorChain);
47299                 }
47300             }
47301             else {
47302                 var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement);
47303                 var classConstraint = getJsxElementClassTypeAt(openingLikeElement);
47304                 if (!sfcReturnConstraint || !classConstraint) {
47305                     return;
47306                 }
47307                 var combined = getUnionType([sfcReturnConstraint, classConstraint]);
47308                 checkTypeRelatedTo(elemInstanceType, combined, assignableRelation, openingLikeElement.tagName, ts.Diagnostics.Its_element_type_0_is_not_a_valid_JSX_element, generateInitialErrorChain);
47309             }
47310             function generateInitialErrorChain() {
47311                 var componentName = ts.getTextOfNode(openingLikeElement.tagName);
47312                 return ts.chainDiagnosticMessages(undefined, ts.Diagnostics._0_cannot_be_used_as_a_JSX_component, componentName);
47313             }
47314         }
47315         function getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node) {
47316             ts.Debug.assert(isJsxIntrinsicIdentifier(node.tagName));
47317             var links = getNodeLinks(node);
47318             if (!links.resolvedJsxElementAttributesType) {
47319                 var symbol = getIntrinsicTagSymbol(node);
47320                 if (links.jsxFlags & 1) {
47321                     return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol);
47322                 }
47323                 else if (links.jsxFlags & 2) {
47324                     return links.resolvedJsxElementAttributesType =
47325                         getIndexTypeOfType(getDeclaredTypeOfSymbol(symbol), 0);
47326                 }
47327                 else {
47328                     return links.resolvedJsxElementAttributesType = errorType;
47329                 }
47330             }
47331             return links.resolvedJsxElementAttributesType;
47332         }
47333         function getJsxElementClassTypeAt(location) {
47334             var type = getJsxType(JsxNames.ElementClass, location);
47335             if (type === errorType)
47336                 return undefined;
47337             return type;
47338         }
47339         function getJsxElementTypeAt(location) {
47340             return getJsxType(JsxNames.Element, location);
47341         }
47342         function getJsxStatelessElementTypeAt(location) {
47343             var jsxElementType = getJsxElementTypeAt(location);
47344             if (jsxElementType) {
47345                 return getUnionType([jsxElementType, nullType]);
47346             }
47347         }
47348         function getJsxIntrinsicTagNamesAt(location) {
47349             var intrinsics = getJsxType(JsxNames.IntrinsicElements, location);
47350             return intrinsics ? getPropertiesOfType(intrinsics) : ts.emptyArray;
47351         }
47352         function checkJsxPreconditions(errorNode) {
47353             if ((compilerOptions.jsx || 0) === 0) {
47354                 error(errorNode, ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided);
47355             }
47356             if (getJsxElementTypeAt(errorNode) === undefined) {
47357                 if (noImplicitAny) {
47358                     error(errorNode, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist);
47359                 }
47360             }
47361         }
47362         function checkJsxOpeningLikeElementOrOpeningFragment(node) {
47363             var isNodeOpeningLikeElement = ts.isJsxOpeningLikeElement(node);
47364             if (isNodeOpeningLikeElement) {
47365                 checkGrammarJsxElement(node);
47366             }
47367             checkJsxPreconditions(node);
47368             var reactRefErr = diagnostics && compilerOptions.jsx === 2 ? ts.Diagnostics.Cannot_find_name_0 : undefined;
47369             var reactNamespace = getJsxNamespace(node);
47370             var reactLocation = isNodeOpeningLikeElement ? node.tagName : node;
47371             var reactSym = resolveName(reactLocation, reactNamespace, 111551, reactRefErr, reactNamespace, true);
47372             if (reactSym) {
47373                 reactSym.isReferenced = 67108863;
47374                 if (reactSym.flags & 2097152 && !getTypeOnlyAliasDeclaration(reactSym)) {
47375                     markAliasSymbolAsReferenced(reactSym);
47376                 }
47377             }
47378             if (isNodeOpeningLikeElement) {
47379                 var jsxOpeningLikeNode = node;
47380                 var sig = getResolvedSignature(jsxOpeningLikeNode);
47381                 checkJsxReturnAssignableToAppropriateBound(getJsxReferenceKind(jsxOpeningLikeNode), getReturnTypeOfSignature(sig), jsxOpeningLikeNode);
47382             }
47383         }
47384         function isKnownProperty(targetType, name, isComparingJsxAttributes) {
47385             if (targetType.flags & 524288) {
47386                 var resolved = resolveStructuredTypeMembers(targetType);
47387                 if (resolved.stringIndexInfo ||
47388                     resolved.numberIndexInfo && isNumericLiteralName(name) ||
47389                     getPropertyOfObjectType(targetType, name) ||
47390                     isComparingJsxAttributes && !isUnhyphenatedJsxName(name)) {
47391                     return true;
47392                 }
47393             }
47394             else if (targetType.flags & 3145728 && isExcessPropertyCheckTarget(targetType)) {
47395                 for (var _i = 0, _a = targetType.types; _i < _a.length; _i++) {
47396                     var t = _a[_i];
47397                     if (isKnownProperty(t, name, isComparingJsxAttributes)) {
47398                         return true;
47399                     }
47400                 }
47401             }
47402             return false;
47403         }
47404         function isExcessPropertyCheckTarget(type) {
47405             return !!(type.flags & 524288 && !(ts.getObjectFlags(type) & 512) ||
47406                 type.flags & 67108864 ||
47407                 type.flags & 1048576 && ts.some(type.types, isExcessPropertyCheckTarget) ||
47408                 type.flags & 2097152 && ts.every(type.types, isExcessPropertyCheckTarget));
47409         }
47410         function checkJsxExpression(node, checkMode) {
47411             checkGrammarJsxExpression(node);
47412             if (node.expression) {
47413                 var type = checkExpression(node.expression, checkMode);
47414                 if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) {
47415                     error(node, ts.Diagnostics.JSX_spread_child_must_be_an_array_type);
47416                 }
47417                 return type;
47418             }
47419             else {
47420                 return errorType;
47421             }
47422         }
47423         function getDeclarationNodeFlagsFromSymbol(s) {
47424             return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : 0;
47425         }
47426         function isPrototypeProperty(symbol) {
47427             if (symbol.flags & 8192 || ts.getCheckFlags(symbol) & 4) {
47428                 return true;
47429             }
47430             if (ts.isInJSFile(symbol.valueDeclaration)) {
47431                 var parent = symbol.valueDeclaration.parent;
47432                 return parent && ts.isBinaryExpression(parent) &&
47433                     ts.getAssignmentDeclarationKind(parent) === 3;
47434             }
47435         }
47436         function checkPropertyAccessibility(node, isSuper, type, prop) {
47437             var flags = ts.getDeclarationModifierFlagsFromSymbol(prop);
47438             var errorNode = node.kind === 153 ? node.right : node.kind === 188 ? node : node.name;
47439             if (isSuper) {
47440                 if (languageVersion < 2) {
47441                     if (symbolHasNonMethodDeclaration(prop)) {
47442                         error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword);
47443                         return false;
47444                     }
47445                 }
47446                 if (flags & 128) {
47447                     error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(getDeclaringClass(prop)));
47448                     return false;
47449                 }
47450             }
47451             if ((flags & 128) && ts.isThisProperty(node) && symbolHasNonMethodDeclaration(prop)) {
47452                 var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop));
47453                 if (declaringClassDeclaration && isNodeUsedDuringClassInitialization(node)) {
47454                     error(errorNode, ts.Diagnostics.Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor, symbolToString(prop), ts.getTextOfIdentifierOrLiteral(declaringClassDeclaration.name));
47455                     return false;
47456                 }
47457             }
47458             if (ts.isPropertyAccessExpression(node) && ts.isPrivateIdentifier(node.name)) {
47459                 if (!ts.getContainingClass(node)) {
47460                     error(errorNode, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
47461                     return false;
47462                 }
47463                 return true;
47464             }
47465             if (!(flags & 24)) {
47466                 return true;
47467             }
47468             if (flags & 8) {
47469                 var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop));
47470                 if (!isNodeWithinClass(node, declaringClassDeclaration)) {
47471                     error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(getDeclaringClass(prop)));
47472                     return false;
47473                 }
47474                 return true;
47475             }
47476             if (isSuper) {
47477                 return true;
47478             }
47479             var enclosingClass = forEachEnclosingClass(node, function (enclosingDeclaration) {
47480                 var enclosingClass = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingDeclaration));
47481                 return isClassDerivedFromDeclaringClasses(enclosingClass, prop) ? enclosingClass : undefined;
47482             });
47483             if (!enclosingClass) {
47484                 var thisParameter = void 0;
47485                 if (flags & 32 || !(thisParameter = getThisParameterFromNodeContext(node)) || !thisParameter.type) {
47486                     error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || type));
47487                     return false;
47488                 }
47489                 var thisType = getTypeFromTypeNode(thisParameter.type);
47490                 enclosingClass = ((thisType.flags & 262144) ? getConstraintOfTypeParameter(thisType) : thisType).target;
47491             }
47492             if (flags & 32) {
47493                 return true;
47494             }
47495             if (type.flags & 262144) {
47496                 type = type.isThisType ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type);
47497             }
47498             if (!type || !hasBaseType(type, enclosingClass)) {
47499                 error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass));
47500                 return false;
47501             }
47502             return true;
47503         }
47504         function getThisParameterFromNodeContext(node) {
47505             var thisContainer = ts.getThisContainer(node, false);
47506             return thisContainer && ts.isFunctionLike(thisContainer) ? ts.getThisParameter(thisContainer) : undefined;
47507         }
47508         function symbolHasNonMethodDeclaration(symbol) {
47509             return !!forEachProperty(symbol, function (prop) { return !(prop.flags & 8192); });
47510         }
47511         function checkNonNullExpression(node) {
47512             return checkNonNullType(checkExpression(node), node);
47513         }
47514         function isNullableType(type) {
47515             return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304);
47516         }
47517         function getNonNullableTypeIfNeeded(type) {
47518             return isNullableType(type) ? getNonNullableType(type) : type;
47519         }
47520         function reportObjectPossiblyNullOrUndefinedError(node, flags) {
47521             error(node, flags & 32768 ? flags & 65536 ?
47522                 ts.Diagnostics.Object_is_possibly_null_or_undefined :
47523                 ts.Diagnostics.Object_is_possibly_undefined :
47524                 ts.Diagnostics.Object_is_possibly_null);
47525         }
47526         function reportCannotInvokePossiblyNullOrUndefinedError(node, flags) {
47527             error(node, flags & 32768 ? flags & 65536 ?
47528                 ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined :
47529                 ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined :
47530                 ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null);
47531         }
47532         function checkNonNullTypeWithReporter(type, node, reportError) {
47533             if (strictNullChecks && type.flags & 2) {
47534                 error(node, ts.Diagnostics.Object_is_of_type_unknown);
47535                 return errorType;
47536             }
47537             var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304;
47538             if (kind) {
47539                 reportError(node, kind);
47540                 var t = getNonNullableType(type);
47541                 return t.flags & (98304 | 131072) ? errorType : t;
47542             }
47543             return type;
47544         }
47545         function checkNonNullType(type, node) {
47546             return checkNonNullTypeWithReporter(type, node, reportObjectPossiblyNullOrUndefinedError);
47547         }
47548         function checkNonNullNonVoidType(type, node) {
47549             var nonNullType = checkNonNullType(type, node);
47550             if (nonNullType !== errorType && nonNullType.flags & 16384) {
47551                 error(node, ts.Diagnostics.Object_is_possibly_undefined);
47552             }
47553             return nonNullType;
47554         }
47555         function checkPropertyAccessExpression(node) {
47556             return node.flags & 32 ? checkPropertyAccessChain(node) :
47557                 checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name);
47558         }
47559         function checkPropertyAccessChain(node) {
47560             var leftType = checkExpression(node.expression);
47561             var nonOptionalType = getOptionalExpressionType(leftType, node.expression);
47562             return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name), node, nonOptionalType !== leftType);
47563         }
47564         function checkQualifiedName(node) {
47565             return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right);
47566         }
47567         function isMethodAccessForCall(node) {
47568             while (node.parent.kind === 200) {
47569                 node = node.parent;
47570             }
47571             return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node;
47572         }
47573         function lookupSymbolForPrivateIdentifierDeclaration(propName, location) {
47574             for (var containingClass = ts.getContainingClass(location); !!containingClass; containingClass = ts.getContainingClass(containingClass)) {
47575                 var symbol = containingClass.symbol;
47576                 var name = ts.getSymbolNameForPrivateIdentifier(symbol, propName);
47577                 var prop = (symbol.members && symbol.members.get(name)) || (symbol.exports && symbol.exports.get(name));
47578                 if (prop) {
47579                     return prop;
47580                 }
47581             }
47582         }
47583         function getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedIdentifier) {
47584             return getPropertyOfType(leftType, lexicallyScopedIdentifier.escapedName);
47585         }
47586         function checkPrivateIdentifierPropertyAccess(leftType, right, lexicallyScopedIdentifier) {
47587             var propertyOnType;
47588             var properties = getPropertiesOfType(leftType);
47589             if (properties) {
47590                 ts.forEach(properties, function (symbol) {
47591                     var decl = symbol.valueDeclaration;
47592                     if (decl && ts.isNamedDeclaration(decl) && ts.isPrivateIdentifier(decl.name) && decl.name.escapedText === right.escapedText) {
47593                         propertyOnType = symbol;
47594                         return true;
47595                     }
47596                 });
47597             }
47598             var diagName = diagnosticName(right);
47599             if (propertyOnType) {
47600                 var typeValueDecl = propertyOnType.valueDeclaration;
47601                 var typeClass_1 = ts.getContainingClass(typeValueDecl);
47602                 ts.Debug.assert(!!typeClass_1);
47603                 if (lexicallyScopedIdentifier) {
47604                     var lexicalValueDecl = lexicallyScopedIdentifier.valueDeclaration;
47605                     var lexicalClass = ts.getContainingClass(lexicalValueDecl);
47606                     ts.Debug.assert(!!lexicalClass);
47607                     if (ts.findAncestor(lexicalClass, function (n) { return typeClass_1 === n; })) {
47608                         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));
47609                         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));
47610                         return true;
47611                     }
47612                 }
47613                 error(right, ts.Diagnostics.Property_0_is_not_accessible_outside_class_1_because_it_has_a_private_identifier, diagName, diagnosticName(typeClass_1.name || anon));
47614                 return true;
47615             }
47616             return false;
47617         }
47618         function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right) {
47619             var parentSymbol = getNodeLinks(left).resolvedSymbol;
47620             var assignmentKind = ts.getAssignmentTargetKind(node);
47621             var apparentType = getApparentType(assignmentKind !== 0 || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType);
47622             if (ts.isPrivateIdentifier(right)) {
47623                 checkExternalEmitHelpers(node, 262144);
47624             }
47625             var isAnyLike = isTypeAny(apparentType) || apparentType === silentNeverType;
47626             var prop;
47627             if (ts.isPrivateIdentifier(right)) {
47628                 var lexicallyScopedSymbol = lookupSymbolForPrivateIdentifierDeclaration(right.escapedText, right);
47629                 if (isAnyLike) {
47630                     if (lexicallyScopedSymbol) {
47631                         return apparentType;
47632                     }
47633                     if (!ts.getContainingClass(right)) {
47634                         grammarErrorOnNode(right, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
47635                         return anyType;
47636                     }
47637                 }
47638                 prop = lexicallyScopedSymbol ? getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedSymbol) : undefined;
47639                 if (!prop && checkPrivateIdentifierPropertyAccess(leftType, right, lexicallyScopedSymbol)) {
47640                     return errorType;
47641                 }
47642             }
47643             else {
47644                 if (isAnyLike) {
47645                     if (ts.isIdentifier(left) && parentSymbol) {
47646                         markAliasReferenced(parentSymbol, node);
47647                     }
47648                     return apparentType;
47649                 }
47650                 prop = getPropertyOfType(apparentType, right.escapedText);
47651             }
47652             if (ts.isIdentifier(left) && parentSymbol && !(prop && isConstEnumOrConstEnumOnlyModule(prop))) {
47653                 markAliasReferenced(parentSymbol, node);
47654             }
47655             var propType;
47656             if (!prop) {
47657                 var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 || !isGenericObjectType(leftType) || isThisTypeParameter(leftType)) ? getIndexInfoOfType(apparentType, 0) : undefined;
47658                 if (!(indexInfo && indexInfo.type)) {
47659                     if (isJSLiteralType(leftType)) {
47660                         return anyType;
47661                     }
47662                     if (leftType.symbol === globalThisSymbol) {
47663                         if (globalThisSymbol.exports.has(right.escapedText) && (globalThisSymbol.exports.get(right.escapedText).flags & 418)) {
47664                             error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(right.escapedText), typeToString(leftType));
47665                         }
47666                         else if (noImplicitAny) {
47667                             error(right, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(leftType));
47668                         }
47669                         return anyType;
47670                     }
47671                     if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) {
47672                         reportNonexistentProperty(right, isThisTypeParameter(leftType) ? apparentType : leftType);
47673                     }
47674                     return errorType;
47675                 }
47676                 if (indexInfo.isReadonly && (ts.isAssignmentTarget(node) || ts.isDeleteTarget(node))) {
47677                     error(node, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(apparentType));
47678                 }
47679                 propType = indexInfo.type;
47680             }
47681             else {
47682                 checkPropertyNotUsedBeforeDeclaration(prop, node, right);
47683                 markPropertyAsReferenced(prop, node, left.kind === 104);
47684                 getNodeLinks(node).resolvedSymbol = prop;
47685                 checkPropertyAccessibility(node, left.kind === 102, apparentType, prop);
47686                 if (isAssignmentToReadonlyEntity(node, prop, assignmentKind)) {
47687                     error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right));
47688                     return errorType;
47689                 }
47690                 propType = getConstraintForLocation(getTypeOfSymbol(prop), node);
47691             }
47692             return getFlowTypeOfAccessExpression(node, prop, propType, right);
47693         }
47694         function getFlowTypeOfAccessExpression(node, prop, propType, errorNode) {
47695             var assignmentKind = ts.getAssignmentTargetKind(node);
47696             if (!ts.isAccessExpression(node) ||
47697                 assignmentKind === 1 ||
47698                 prop && !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 1048576)) {
47699                 return propType;
47700             }
47701             var assumeUninitialized = false;
47702             if (strictNullChecks && strictPropertyInitialization && node.expression.kind === 104) {
47703                 var declaration = prop && prop.valueDeclaration;
47704                 if (declaration && isInstancePropertyWithoutInitializer(declaration)) {
47705                     var flowContainer = getControlFlowContainer(node);
47706                     if (flowContainer.kind === 162 && flowContainer.parent === declaration.parent && !(declaration.flags & 8388608)) {
47707                         assumeUninitialized = true;
47708                     }
47709                 }
47710             }
47711             else if (strictNullChecks && prop && prop.valueDeclaration &&
47712                 ts.isPropertyAccessExpression(prop.valueDeclaration) &&
47713                 ts.getAssignmentDeclarationPropertyAccessKind(prop.valueDeclaration) &&
47714                 getControlFlowContainer(node) === getControlFlowContainer(prop.valueDeclaration)) {
47715                 assumeUninitialized = true;
47716             }
47717             var flowType = getFlowTypeOfReference(node, propType, assumeUninitialized ? getOptionalType(propType) : propType);
47718             if (assumeUninitialized && !(getFalsyFlags(propType) & 32768) && getFalsyFlags(flowType) & 32768) {
47719                 error(errorNode, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(prop));
47720                 return propType;
47721             }
47722             return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
47723         }
47724         function checkPropertyNotUsedBeforeDeclaration(prop, node, right) {
47725             var valueDeclaration = prop.valueDeclaration;
47726             if (!valueDeclaration || ts.getSourceFileOfNode(node).isDeclarationFile) {
47727                 return;
47728             }
47729             var diagnosticMessage;
47730             var declarationName = ts.idText(right);
47731             if (isInPropertyInitializer(node)
47732                 && !(ts.isAccessExpression(node) && ts.isAccessExpression(node.expression))
47733                 && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)
47734                 && !isPropertyDeclaredInAncestorClass(prop)) {
47735                 diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName);
47736             }
47737             else if (valueDeclaration.kind === 245 &&
47738                 node.parent.kind !== 169 &&
47739                 !(valueDeclaration.flags & 8388608) &&
47740                 !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) {
47741                 diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName);
47742             }
47743             if (diagnosticMessage) {
47744                 ts.addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(valueDeclaration, ts.Diagnostics._0_is_declared_here, declarationName));
47745             }
47746         }
47747         function isInPropertyInitializer(node) {
47748             return !!ts.findAncestor(node, function (node) {
47749                 switch (node.kind) {
47750                     case 159:
47751                         return true;
47752                     case 281:
47753                     case 161:
47754                     case 163:
47755                     case 164:
47756                     case 283:
47757                     case 154:
47758                     case 221:
47759                     case 276:
47760                     case 273:
47761                     case 274:
47762                     case 275:
47763                     case 268:
47764                     case 216:
47765                     case 279:
47766                         return false;
47767                     default:
47768                         return ts.isExpressionNode(node) ? false : "quit";
47769                 }
47770             });
47771         }
47772         function isPropertyDeclaredInAncestorClass(prop) {
47773             if (!(prop.parent.flags & 32)) {
47774                 return false;
47775             }
47776             var classType = getTypeOfSymbol(prop.parent);
47777             while (true) {
47778                 classType = classType.symbol && getSuperClass(classType);
47779                 if (!classType) {
47780                     return false;
47781                 }
47782                 var superProperty = getPropertyOfType(classType, prop.escapedName);
47783                 if (superProperty && superProperty.valueDeclaration) {
47784                     return true;
47785                 }
47786             }
47787         }
47788         function getSuperClass(classType) {
47789             var x = getBaseTypes(classType);
47790             if (x.length === 0) {
47791                 return undefined;
47792             }
47793             return getIntersectionType(x);
47794         }
47795         function reportNonexistentProperty(propNode, containingType) {
47796             var errorInfo;
47797             var relatedInfo;
47798             if (!ts.isPrivateIdentifier(propNode) && containingType.flags & 1048576 && !(containingType.flags & 131068)) {
47799                 for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) {
47800                     var subtype = _a[_i];
47801                     if (!getPropertyOfType(subtype, propNode.escapedText) && !getIndexInfoOfType(subtype, 0)) {
47802                         errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(subtype));
47803                         break;
47804                     }
47805                 }
47806             }
47807             if (typeHasStaticProperty(propNode.escapedText, containingType)) {
47808                 errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_is_a_static_member_of_type_1, ts.declarationNameToString(propNode), typeToString(containingType));
47809             }
47810             else {
47811                 var promisedType = getPromisedTypeOfPromise(containingType);
47812                 if (promisedType && getPropertyOfType(promisedType, propNode.escapedText)) {
47813                     errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType));
47814                     relatedInfo = ts.createDiagnosticForNode(propNode, ts.Diagnostics.Did_you_forget_to_use_await);
47815                 }
47816                 else {
47817                     var suggestion = getSuggestedSymbolForNonexistentProperty(propNode, containingType);
47818                     if (suggestion !== undefined) {
47819                         var suggestedName = ts.symbolName(suggestion);
47820                         errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, ts.declarationNameToString(propNode), typeToString(containingType), suggestedName);
47821                         relatedInfo = suggestion.valueDeclaration && ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestedName);
47822                     }
47823                     else {
47824                         errorInfo = ts.chainDiagnosticMessages(elaborateNeverIntersection(errorInfo, containingType), ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType));
47825                     }
47826                 }
47827             }
47828             var resultDiagnostic = ts.createDiagnosticForNodeFromMessageChain(propNode, errorInfo);
47829             if (relatedInfo) {
47830                 ts.addRelatedInfo(resultDiagnostic, relatedInfo);
47831             }
47832             diagnostics.add(resultDiagnostic);
47833         }
47834         function typeHasStaticProperty(propName, containingType) {
47835             var prop = containingType.symbol && getPropertyOfType(getTypeOfSymbol(containingType.symbol), propName);
47836             return prop !== undefined && prop.valueDeclaration && ts.hasModifier(prop.valueDeclaration, 32);
47837         }
47838         function getSuggestedSymbolForNonexistentProperty(name, containingType) {
47839             return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 111551);
47840         }
47841         function getSuggestionForNonexistentProperty(name, containingType) {
47842             var suggestion = getSuggestedSymbolForNonexistentProperty(name, containingType);
47843             return suggestion && ts.symbolName(suggestion);
47844         }
47845         function getSuggestedSymbolForNonexistentSymbol(location, outerName, meaning) {
47846             ts.Debug.assert(outerName !== undefined, "outername should always be defined");
47847             var result = resolveNameHelper(location, outerName, meaning, undefined, outerName, false, false, function (symbols, name, meaning) {
47848                 ts.Debug.assertEqual(outerName, name, "name should equal outerName");
47849                 var symbol = getSymbol(symbols, name, meaning);
47850                 return symbol || getSpellingSuggestionForName(ts.unescapeLeadingUnderscores(name), ts.arrayFrom(symbols.values()), meaning);
47851             });
47852             return result;
47853         }
47854         function getSuggestionForNonexistentSymbol(location, outerName, meaning) {
47855             var symbolResult = getSuggestedSymbolForNonexistentSymbol(location, outerName, meaning);
47856             return symbolResult && ts.symbolName(symbolResult);
47857         }
47858         function getSuggestedSymbolForNonexistentModule(name, targetModule) {
47859             return targetModule.exports && getSpellingSuggestionForName(ts.idText(name), getExportsOfModuleAsArray(targetModule), 2623475);
47860         }
47861         function getSuggestionForNonexistentExport(name, targetModule) {
47862             var suggestion = getSuggestedSymbolForNonexistentModule(name, targetModule);
47863             return suggestion && ts.symbolName(suggestion);
47864         }
47865         function getSuggestionForNonexistentIndexSignature(objectType, expr, keyedType) {
47866             function hasProp(name) {
47867                 var prop = getPropertyOfObjectType(objectType, name);
47868                 if (prop) {
47869                     var s = getSingleCallSignature(getTypeOfSymbol(prop));
47870                     return !!s && getMinArgumentCount(s) >= 1 && isTypeAssignableTo(keyedType, getTypeAtPosition(s, 0));
47871                 }
47872                 return false;
47873             }
47874             ;
47875             var suggestedMethod = ts.isAssignmentTarget(expr) ? "set" : "get";
47876             if (!hasProp(suggestedMethod)) {
47877                 return undefined;
47878             }
47879             var suggestion = ts.tryGetPropertyAccessOrIdentifierToString(expr.expression);
47880             if (suggestion === undefined) {
47881                 suggestion = suggestedMethod;
47882             }
47883             else {
47884                 suggestion += "." + suggestedMethod;
47885             }
47886             return suggestion;
47887         }
47888         function getSpellingSuggestionForName(name, symbols, meaning) {
47889             return ts.getSpellingSuggestion(name, symbols, getCandidateName);
47890             function getCandidateName(candidate) {
47891                 var candidateName = ts.symbolName(candidate);
47892                 if (ts.startsWith(candidateName, "\"")) {
47893                     return undefined;
47894                 }
47895                 if (candidate.flags & meaning) {
47896                     return candidateName;
47897                 }
47898                 if (candidate.flags & 2097152) {
47899                     var alias = tryResolveAlias(candidate);
47900                     if (alias && alias.flags & meaning) {
47901                         return candidateName;
47902                     }
47903                 }
47904                 return undefined;
47905             }
47906         }
47907         function markPropertyAsReferenced(prop, nodeForCheckWriteOnly, isThisAccess) {
47908             var valueDeclaration = prop && (prop.flags & 106500) && prop.valueDeclaration;
47909             if (!valueDeclaration) {
47910                 return;
47911             }
47912             var hasPrivateModifier = ts.hasModifier(valueDeclaration, 8);
47913             var hasPrivateIdentifier = ts.isNamedDeclaration(prop.valueDeclaration) && ts.isPrivateIdentifier(prop.valueDeclaration.name);
47914             if (!hasPrivateModifier && !hasPrivateIdentifier) {
47915                 return;
47916             }
47917             if (nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly) && !(prop.flags & 65536)) {
47918                 return;
47919             }
47920             if (isThisAccess) {
47921                 var containingMethod = ts.findAncestor(nodeForCheckWriteOnly, ts.isFunctionLikeDeclaration);
47922                 if (containingMethod && containingMethod.symbol === prop) {
47923                     return;
47924                 }
47925             }
47926             (ts.getCheckFlags(prop) & 1 ? getSymbolLinks(prop).target : prop).isReferenced = 67108863;
47927         }
47928         function isValidPropertyAccess(node, propertyName) {
47929             switch (node.kind) {
47930                 case 194:
47931                     return isValidPropertyAccessWithType(node, node.expression.kind === 102, propertyName, getWidenedType(checkExpression(node.expression)));
47932                 case 153:
47933                     return isValidPropertyAccessWithType(node, false, propertyName, getWidenedType(checkExpression(node.left)));
47934                 case 188:
47935                     return isValidPropertyAccessWithType(node, false, propertyName, getTypeFromTypeNode(node));
47936             }
47937         }
47938         function isValidPropertyAccessForCompletions(node, type, property) {
47939             return isValidPropertyAccessWithType(node, node.kind === 194 && node.expression.kind === 102, property.escapedName, type);
47940         }
47941         function isValidPropertyAccessWithType(node, isSuper, propertyName, type) {
47942             if (type === errorType || isTypeAny(type)) {
47943                 return true;
47944             }
47945             var prop = getPropertyOfType(type, propertyName);
47946             if (prop) {
47947                 if (ts.isPropertyAccessExpression(node) && prop.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(prop.valueDeclaration)) {
47948                     var declClass_1 = ts.getContainingClass(prop.valueDeclaration);
47949                     return !ts.isOptionalChain(node) && !!ts.findAncestor(node, function (parent) { return parent === declClass_1; });
47950                 }
47951                 return checkPropertyAccessibility(node, isSuper, type, prop);
47952             }
47953             return ts.isInJSFile(node) && (type.flags & 1048576) !== 0 && type.types.some(function (elementType) { return isValidPropertyAccessWithType(node, isSuper, propertyName, elementType); });
47954         }
47955         function getForInVariableSymbol(node) {
47956             var initializer = node.initializer;
47957             if (initializer.kind === 243) {
47958                 var variable = initializer.declarations[0];
47959                 if (variable && !ts.isBindingPattern(variable.name)) {
47960                     return getSymbolOfNode(variable);
47961                 }
47962             }
47963             else if (initializer.kind === 75) {
47964                 return getResolvedSymbol(initializer);
47965             }
47966             return undefined;
47967         }
47968         function hasNumericPropertyNames(type) {
47969             return getIndexTypeOfType(type, 1) && !getIndexTypeOfType(type, 0);
47970         }
47971         function isForInVariableForNumericPropertyNames(expr) {
47972             var e = ts.skipParentheses(expr);
47973             if (e.kind === 75) {
47974                 var symbol = getResolvedSymbol(e);
47975                 if (symbol.flags & 3) {
47976                     var child = expr;
47977                     var node = expr.parent;
47978                     while (node) {
47979                         if (node.kind === 231 &&
47980                             child === node.statement &&
47981                             getForInVariableSymbol(node) === symbol &&
47982                             hasNumericPropertyNames(getTypeOfExpression(node.expression))) {
47983                             return true;
47984                         }
47985                         child = node;
47986                         node = node.parent;
47987                     }
47988                 }
47989             }
47990             return false;
47991         }
47992         function checkIndexedAccess(node) {
47993             return node.flags & 32 ? checkElementAccessChain(node) :
47994                 checkElementAccessExpression(node, checkNonNullExpression(node.expression));
47995         }
47996         function checkElementAccessChain(node) {
47997             var exprType = checkExpression(node.expression);
47998             var nonOptionalType = getOptionalExpressionType(exprType, node.expression);
47999             return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression)), node, nonOptionalType !== exprType);
48000         }
48001         function checkElementAccessExpression(node, exprType) {
48002             var objectType = ts.getAssignmentTargetKind(node) !== 0 || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType;
48003             var indexExpression = node.argumentExpression;
48004             var indexType = checkExpression(indexExpression);
48005             if (objectType === errorType || objectType === silentNeverType) {
48006                 return objectType;
48007             }
48008             if (isConstEnumObjectType(objectType) && !ts.isStringLiteralLike(indexExpression)) {
48009                 error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal);
48010                 return errorType;
48011             }
48012             var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType;
48013             var accessFlags = ts.isAssignmentTarget(node) ?
48014                 2 | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 : 0) :
48015                 0;
48016             var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, node, accessFlags) || errorType;
48017             return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, indexedAccessType.symbol, indexedAccessType, indexExpression), node);
48018         }
48019         function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) {
48020             if (expressionType === errorType) {
48021                 return false;
48022             }
48023             if (!ts.isWellKnownSymbolSyntactically(expression)) {
48024                 return false;
48025             }
48026             if ((expressionType.flags & 12288) === 0) {
48027                 if (reportError) {
48028                     error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression));
48029                 }
48030                 return false;
48031             }
48032             var leftHandSide = expression.expression;
48033             var leftHandSideSymbol = getResolvedSymbol(leftHandSide);
48034             if (!leftHandSideSymbol) {
48035                 return false;
48036             }
48037             var globalESSymbol = getGlobalESSymbolConstructorSymbol(true);
48038             if (!globalESSymbol) {
48039                 return false;
48040             }
48041             if (leftHandSideSymbol !== globalESSymbol) {
48042                 if (reportError) {
48043                     error(leftHandSide, ts.Diagnostics.Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object);
48044                 }
48045                 return false;
48046             }
48047             return true;
48048         }
48049         function callLikeExpressionMayHaveTypeArguments(node) {
48050             return ts.isCallOrNewExpression(node) || ts.isTaggedTemplateExpression(node) || ts.isJsxOpeningLikeElement(node);
48051         }
48052         function resolveUntypedCall(node) {
48053             if (callLikeExpressionMayHaveTypeArguments(node)) {
48054                 ts.forEach(node.typeArguments, checkSourceElement);
48055             }
48056             if (node.kind === 198) {
48057                 checkExpression(node.template);
48058             }
48059             else if (ts.isJsxOpeningLikeElement(node)) {
48060                 checkExpression(node.attributes);
48061             }
48062             else if (node.kind !== 157) {
48063                 ts.forEach(node.arguments, function (argument) {
48064                     checkExpression(argument);
48065                 });
48066             }
48067             return anySignature;
48068         }
48069         function resolveErrorCall(node) {
48070             resolveUntypedCall(node);
48071             return unknownSignature;
48072         }
48073         function reorderCandidates(signatures, result, callChainFlags) {
48074             var lastParent;
48075             var lastSymbol;
48076             var cutoffIndex = 0;
48077             var index;
48078             var specializedIndex = -1;
48079             var spliceIndex;
48080             ts.Debug.assert(!result.length);
48081             for (var _i = 0, signatures_7 = signatures; _i < signatures_7.length; _i++) {
48082                 var signature = signatures_7[_i];
48083                 var symbol = signature.declaration && getSymbolOfNode(signature.declaration);
48084                 var parent = signature.declaration && signature.declaration.parent;
48085                 if (!lastSymbol || symbol === lastSymbol) {
48086                     if (lastParent && parent === lastParent) {
48087                         index = index + 1;
48088                     }
48089                     else {
48090                         lastParent = parent;
48091                         index = cutoffIndex;
48092                     }
48093                 }
48094                 else {
48095                     index = cutoffIndex = result.length;
48096                     lastParent = parent;
48097                 }
48098                 lastSymbol = symbol;
48099                 if (signatureHasLiteralTypes(signature)) {
48100                     specializedIndex++;
48101                     spliceIndex = specializedIndex;
48102                     cutoffIndex++;
48103                 }
48104                 else {
48105                     spliceIndex = index;
48106                 }
48107                 result.splice(spliceIndex, 0, callChainFlags ? getOptionalCallSignature(signature, callChainFlags) : signature);
48108             }
48109         }
48110         function isSpreadArgument(arg) {
48111             return !!arg && (arg.kind === 213 || arg.kind === 220 && arg.isSpread);
48112         }
48113         function getSpreadArgumentIndex(args) {
48114             return ts.findIndex(args, isSpreadArgument);
48115         }
48116         function acceptsVoid(t) {
48117             return !!(t.flags & 16384);
48118         }
48119         function hasCorrectArity(node, args, signature, signatureHelpTrailingComma) {
48120             if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; }
48121             var argCount;
48122             var callIsIncomplete = false;
48123             var effectiveParameterCount = getParameterCount(signature);
48124             var effectiveMinimumArguments = getMinArgumentCount(signature);
48125             if (node.kind === 198) {
48126                 argCount = args.length;
48127                 if (node.template.kind === 211) {
48128                     var lastSpan = ts.last(node.template.templateSpans);
48129                     callIsIncomplete = ts.nodeIsMissing(lastSpan.literal) || !!lastSpan.literal.isUnterminated;
48130                 }
48131                 else {
48132                     var templateLiteral = node.template;
48133                     ts.Debug.assert(templateLiteral.kind === 14);
48134                     callIsIncomplete = !!templateLiteral.isUnterminated;
48135                 }
48136             }
48137             else if (node.kind === 157) {
48138                 argCount = getDecoratorArgumentCount(node, signature);
48139             }
48140             else if (ts.isJsxOpeningLikeElement(node)) {
48141                 callIsIncomplete = node.attributes.end === node.end;
48142                 if (callIsIncomplete) {
48143                     return true;
48144                 }
48145                 argCount = effectiveMinimumArguments === 0 ? args.length : 1;
48146                 effectiveParameterCount = args.length === 0 ? effectiveParameterCount : 1;
48147                 effectiveMinimumArguments = Math.min(effectiveMinimumArguments, 1);
48148             }
48149             else {
48150                 if (!node.arguments) {
48151                     ts.Debug.assert(node.kind === 197);
48152                     return getMinArgumentCount(signature) === 0;
48153                 }
48154                 argCount = signatureHelpTrailingComma ? args.length + 1 : args.length;
48155                 callIsIncomplete = node.arguments.end === node.end;
48156                 var spreadArgIndex = getSpreadArgumentIndex(args);
48157                 if (spreadArgIndex >= 0) {
48158                     return spreadArgIndex >= getMinArgumentCount(signature) && (hasEffectiveRestParameter(signature) || spreadArgIndex < getParameterCount(signature));
48159                 }
48160             }
48161             if (!hasEffectiveRestParameter(signature) && argCount > effectiveParameterCount) {
48162                 return false;
48163             }
48164             if (callIsIncomplete || argCount >= effectiveMinimumArguments) {
48165                 return true;
48166             }
48167             for (var i = argCount; i < effectiveMinimumArguments; i++) {
48168                 var type = getTypeAtPosition(signature, i);
48169                 if (filterType(type, acceptsVoid).flags & 131072) {
48170                     return false;
48171                 }
48172             }
48173             return true;
48174         }
48175         function hasCorrectTypeArgumentArity(signature, typeArguments) {
48176             var numTypeParameters = ts.length(signature.typeParameters);
48177             var minTypeArgumentCount = getMinTypeArgumentCount(signature.typeParameters);
48178             return !ts.some(typeArguments) ||
48179                 (typeArguments.length >= minTypeArgumentCount && typeArguments.length <= numTypeParameters);
48180         }
48181         function getSingleCallSignature(type) {
48182             return getSingleSignature(type, 0, false);
48183         }
48184         function getSingleCallOrConstructSignature(type) {
48185             return getSingleSignature(type, 0, false) ||
48186                 getSingleSignature(type, 1, false);
48187         }
48188         function getSingleSignature(type, kind, allowMembers) {
48189             if (type.flags & 524288) {
48190                 var resolved = resolveStructuredTypeMembers(type);
48191                 if (allowMembers || resolved.properties.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo) {
48192                     if (kind === 0 && resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0) {
48193                         return resolved.callSignatures[0];
48194                     }
48195                     if (kind === 1 && resolved.constructSignatures.length === 1 && resolved.callSignatures.length === 0) {
48196                         return resolved.constructSignatures[0];
48197                     }
48198                 }
48199             }
48200             return undefined;
48201         }
48202         function instantiateSignatureInContextOf(signature, contextualSignature, inferenceContext, compareTypes) {
48203             var context = createInferenceContext(signature.typeParameters, signature, 0, compareTypes);
48204             var restType = getEffectiveRestType(contextualSignature);
48205             var mapper = inferenceContext && (restType && restType.flags & 262144 ? inferenceContext.nonFixingMapper : inferenceContext.mapper);
48206             var sourceSignature = mapper ? instantiateSignature(contextualSignature, mapper) : contextualSignature;
48207             applyToParameterTypes(sourceSignature, signature, function (source, target) {
48208                 inferTypes(context.inferences, source, target);
48209             });
48210             if (!inferenceContext) {
48211                 applyToReturnTypes(contextualSignature, signature, function (source, target) {
48212                     inferTypes(context.inferences, source, target, 32);
48213                 });
48214             }
48215             return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJSFile(contextualSignature.declaration));
48216         }
48217         function inferJsxTypeArguments(node, signature, checkMode, context) {
48218             var paramType = getEffectiveFirstArgumentForJsxSignature(signature, node);
48219             var checkAttrType = checkExpressionWithContextualType(node.attributes, paramType, context, checkMode);
48220             inferTypes(context.inferences, checkAttrType, paramType);
48221             return getInferredTypes(context);
48222         }
48223         function inferTypeArguments(node, signature, args, checkMode, context) {
48224             if (ts.isJsxOpeningLikeElement(node)) {
48225                 return inferJsxTypeArguments(node, signature, checkMode, context);
48226             }
48227             if (node.kind !== 157) {
48228                 var contextualType = getContextualType(node);
48229                 if (contextualType) {
48230                     var outerContext = getInferenceContext(node);
48231                     var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1));
48232                     var instantiatedType = instantiateType(contextualType, outerMapper);
48233                     var contextualSignature = getSingleCallSignature(instantiatedType);
48234                     var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
48235                         getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
48236                         instantiatedType;
48237                     var inferenceTargetType = getReturnTypeOfSignature(signature);
48238                     inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 32);
48239                     var returnContext = createInferenceContext(signature.typeParameters, signature, context.flags);
48240                     var returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper);
48241                     inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType);
48242                     context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : undefined;
48243                 }
48244             }
48245             var thisType = getThisTypeOfSignature(signature);
48246             if (thisType) {
48247                 var thisArgumentNode = getThisArgumentOfCall(node);
48248                 var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType;
48249                 inferTypes(context.inferences, thisArgumentType, thisType);
48250             }
48251             var restType = getNonArrayRestType(signature);
48252             var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length;
48253             for (var i = 0; i < argCount; i++) {
48254                 var arg = args[i];
48255                 if (arg.kind !== 215) {
48256                     var paramType = getTypeAtPosition(signature, i);
48257                     var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
48258                     inferTypes(context.inferences, argType, paramType);
48259                 }
48260             }
48261             if (restType) {
48262                 var spreadType = getSpreadArgumentType(args, argCount, args.length, restType, context);
48263                 inferTypes(context.inferences, spreadType, restType);
48264             }
48265             return getInferredTypes(context);
48266         }
48267         function getArrayifiedType(type) {
48268             return type.flags & 1048576 ? mapType(type, getArrayifiedType) :
48269                 type.flags & (1 | 63176704) || isMutableArrayOrTuple(type) ? type :
48270                     isTupleType(type) ? createTupleType(getTypeArguments(type), type.target.minLength, type.target.hasRestElement, false, type.target.associatedNames) :
48271                         createArrayType(getIndexedAccessType(type, numberType));
48272         }
48273         function getSpreadArgumentType(args, index, argCount, restType, context) {
48274             if (index >= argCount - 1) {
48275                 var arg = args[argCount - 1];
48276                 if (isSpreadArgument(arg)) {
48277                     return arg.kind === 220 ?
48278                         createArrayType(arg.type) :
48279                         getArrayifiedType(checkExpressionWithContextualType(arg.expression, restType, context, 0));
48280                 }
48281             }
48282             var types = [];
48283             var spreadIndex = -1;
48284             for (var i = index; i < argCount; i++) {
48285                 var contextualType = getIndexedAccessType(restType, getLiteralType(i - index));
48286                 var argType = checkExpressionWithContextualType(args[i], contextualType, context, 0);
48287                 if (spreadIndex < 0 && isSpreadArgument(args[i])) {
48288                     spreadIndex = i - index;
48289                 }
48290                 var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 | 4194304);
48291                 types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType));
48292             }
48293             return spreadIndex < 0 ?
48294                 createTupleType(types) :
48295                 createTupleType(ts.append(types.slice(0, spreadIndex), getUnionType(types.slice(spreadIndex))), spreadIndex, true);
48296         }
48297         function checkTypeArguments(signature, typeArgumentNodes, reportErrors, headMessage) {
48298             var isJavascript = ts.isInJSFile(signature.declaration);
48299             var typeParameters = signature.typeParameters;
48300             var typeArgumentTypes = fillMissingTypeArguments(ts.map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, getMinTypeArgumentCount(typeParameters), isJavascript);
48301             var mapper;
48302             for (var i = 0; i < typeArgumentNodes.length; i++) {
48303                 ts.Debug.assert(typeParameters[i] !== undefined, "Should not call checkTypeArguments with too many type arguments");
48304                 var constraint = getConstraintOfTypeParameter(typeParameters[i]);
48305                 if (constraint) {
48306                     var errorInfo = reportErrors && headMessage ? (function () { return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); }) : undefined;
48307                     var typeArgumentHeadMessage = headMessage || ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1;
48308                     if (!mapper) {
48309                         mapper = createTypeMapper(typeParameters, typeArgumentTypes);
48310                     }
48311                     var typeArgument = typeArgumentTypes[i];
48312                     if (!checkTypeAssignableTo(typeArgument, getTypeWithThisArgument(instantiateType(constraint, mapper), typeArgument), reportErrors ? typeArgumentNodes[i] : undefined, typeArgumentHeadMessage, errorInfo)) {
48313                         return undefined;
48314                     }
48315                 }
48316             }
48317             return typeArgumentTypes;
48318         }
48319         function getJsxReferenceKind(node) {
48320             if (isJsxIntrinsicIdentifier(node.tagName)) {
48321                 return 2;
48322             }
48323             var tagType = getApparentType(checkExpression(node.tagName));
48324             if (ts.length(getSignaturesOfType(tagType, 1))) {
48325                 return 0;
48326             }
48327             if (ts.length(getSignaturesOfType(tagType, 0))) {
48328                 return 1;
48329             }
48330             return 2;
48331         }
48332         function checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors, containingMessageChain, errorOutputContainer) {
48333             var paramType = getEffectiveFirstArgumentForJsxSignature(signature, node);
48334             var attributesType = checkExpressionWithContextualType(node.attributes, paramType, undefined, checkMode);
48335             return checkTagNameDoesNotExpectTooManyArguments() && checkTypeRelatedToAndOptionallyElaborate(attributesType, paramType, relation, reportErrors ? node.tagName : undefined, node.attributes, undefined, containingMessageChain, errorOutputContainer);
48336             function checkTagNameDoesNotExpectTooManyArguments() {
48337                 var _a;
48338                 var tagType = ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node) && !isJsxIntrinsicIdentifier(node.tagName) ? checkExpression(node.tagName) : undefined;
48339                 if (!tagType) {
48340                     return true;
48341                 }
48342                 var tagCallSignatures = getSignaturesOfType(tagType, 0);
48343                 if (!ts.length(tagCallSignatures)) {
48344                     return true;
48345                 }
48346                 var factory = getJsxFactoryEntity(node);
48347                 if (!factory) {
48348                     return true;
48349                 }
48350                 var factorySymbol = resolveEntityName(factory, 111551, true, false, node);
48351                 if (!factorySymbol) {
48352                     return true;
48353                 }
48354                 var factoryType = getTypeOfSymbol(factorySymbol);
48355                 var callSignatures = getSignaturesOfType(factoryType, 0);
48356                 if (!ts.length(callSignatures)) {
48357                     return true;
48358                 }
48359                 var hasFirstParamSignatures = false;
48360                 var maxParamCount = 0;
48361                 for (var _i = 0, callSignatures_1 = callSignatures; _i < callSignatures_1.length; _i++) {
48362                     var sig = callSignatures_1[_i];
48363                     var firstparam = getTypeAtPosition(sig, 0);
48364                     var signaturesOfParam = getSignaturesOfType(firstparam, 0);
48365                     if (!ts.length(signaturesOfParam))
48366                         continue;
48367                     for (var _b = 0, signaturesOfParam_1 = signaturesOfParam; _b < signaturesOfParam_1.length; _b++) {
48368                         var paramSig = signaturesOfParam_1[_b];
48369                         hasFirstParamSignatures = true;
48370                         if (hasEffectiveRestParameter(paramSig)) {
48371                             return true;
48372                         }
48373                         var paramCount = getParameterCount(paramSig);
48374                         if (paramCount > maxParamCount) {
48375                             maxParamCount = paramCount;
48376                         }
48377                     }
48378                 }
48379                 if (!hasFirstParamSignatures) {
48380                     return true;
48381                 }
48382                 var absoluteMinArgCount = Infinity;
48383                 for (var _c = 0, tagCallSignatures_1 = tagCallSignatures; _c < tagCallSignatures_1.length; _c++) {
48384                     var tagSig = tagCallSignatures_1[_c];
48385                     var tagRequiredArgCount = getMinArgumentCount(tagSig);
48386                     if (tagRequiredArgCount < absoluteMinArgCount) {
48387                         absoluteMinArgCount = tagRequiredArgCount;
48388                     }
48389                 }
48390                 if (absoluteMinArgCount <= maxParamCount) {
48391                     return true;
48392                 }
48393                 if (reportErrors) {
48394                     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);
48395                     var tagNameDeclaration = (_a = getSymbolAtLocation(node.tagName)) === null || _a === void 0 ? void 0 : _a.valueDeclaration;
48396                     if (tagNameDeclaration) {
48397                         ts.addRelatedInfo(diag, ts.createDiagnosticForNode(tagNameDeclaration, ts.Diagnostics._0_is_declared_here, ts.entityNameToString(node.tagName)));
48398                     }
48399                     if (errorOutputContainer && errorOutputContainer.skipLogging) {
48400                         (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
48401                     }
48402                     if (!errorOutputContainer.skipLogging) {
48403                         diagnostics.add(diag);
48404                     }
48405                 }
48406                 return false;
48407             }
48408         }
48409         function getSignatureApplicabilityError(node, args, signature, relation, checkMode, reportErrors, containingMessageChain) {
48410             var errorOutputContainer = { errors: undefined, skipLogging: true };
48411             if (ts.isJsxOpeningLikeElement(node)) {
48412                 if (!checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors, containingMessageChain, errorOutputContainer)) {
48413                     ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "jsx should have errors when reporting errors");
48414                     return errorOutputContainer.errors || ts.emptyArray;
48415                 }
48416                 return undefined;
48417             }
48418             var thisType = getThisTypeOfSignature(signature);
48419             if (thisType && thisType !== voidType && node.kind !== 197) {
48420                 var thisArgumentNode = getThisArgumentOfCall(node);
48421                 var thisArgumentType = void 0;
48422                 if (thisArgumentNode) {
48423                     thisArgumentType = checkExpression(thisArgumentNode);
48424                     if (ts.isOptionalChainRoot(thisArgumentNode.parent)) {
48425                         thisArgumentType = getNonNullableType(thisArgumentType);
48426                     }
48427                     else if (ts.isOptionalChain(thisArgumentNode.parent)) {
48428                         thisArgumentType = removeOptionalTypeMarker(thisArgumentType);
48429                     }
48430                 }
48431                 else {
48432                     thisArgumentType = voidType;
48433                 }
48434                 var errorNode = reportErrors ? (thisArgumentNode || node) : undefined;
48435                 var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1;
48436                 if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1, containingMessageChain, errorOutputContainer)) {
48437                     ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "this parameter should have errors when reporting errors");
48438                     return errorOutputContainer.errors || ts.emptyArray;
48439                 }
48440             }
48441             var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1;
48442             var restType = getNonArrayRestType(signature);
48443             var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length;
48444             for (var i = 0; i < argCount; i++) {
48445                 var arg = args[i];
48446                 if (arg.kind !== 215) {
48447                     var paramType = getTypeAtPosition(signature, i);
48448                     var argType = checkExpressionWithContextualType(arg, paramType, undefined, checkMode);
48449                     var checkArgType = checkMode & 4 ? getRegularTypeOfObjectLiteral(argType) : argType;
48450                     if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage, containingMessageChain, errorOutputContainer)) {
48451                         ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "parameter should have errors when reporting errors");
48452                         maybeAddMissingAwaitInfo(arg, checkArgType, paramType);
48453                         return errorOutputContainer.errors || ts.emptyArray;
48454                     }
48455                 }
48456             }
48457             if (restType) {
48458                 var spreadType = getSpreadArgumentType(args, argCount, args.length, restType, undefined);
48459                 var errorNode = reportErrors ? argCount < args.length ? args[argCount] : node : undefined;
48460                 if (!checkTypeRelatedTo(spreadType, restType, relation, errorNode, headMessage, undefined, errorOutputContainer)) {
48461                     ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "rest parameter should have errors when reporting errors");
48462                     maybeAddMissingAwaitInfo(errorNode, spreadType, restType);
48463                     return errorOutputContainer.errors || ts.emptyArray;
48464                 }
48465             }
48466             return undefined;
48467             function maybeAddMissingAwaitInfo(errorNode, source, target) {
48468                 if (errorNode && reportErrors && errorOutputContainer.errors && errorOutputContainer.errors.length) {
48469                     if (getAwaitedTypeOfPromise(target)) {
48470                         return;
48471                     }
48472                     var awaitedTypeOfSource = getAwaitedTypeOfPromise(source);
48473                     if (awaitedTypeOfSource && isTypeRelatedTo(awaitedTypeOfSource, target, relation)) {
48474                         ts.addRelatedInfo(errorOutputContainer.errors[0], ts.createDiagnosticForNode(errorNode, ts.Diagnostics.Did_you_forget_to_use_await));
48475                     }
48476                 }
48477             }
48478         }
48479         function getThisArgumentOfCall(node) {
48480             if (node.kind === 196) {
48481                 var callee = ts.skipOuterExpressions(node.expression);
48482                 if (ts.isAccessExpression(callee)) {
48483                     return callee.expression;
48484                 }
48485             }
48486         }
48487         function createSyntheticExpression(parent, type, isSpread) {
48488             var result = ts.createNode(220, parent.pos, parent.end);
48489             result.parent = parent;
48490             result.type = type;
48491             result.isSpread = isSpread || false;
48492             return result;
48493         }
48494         function getEffectiveCallArguments(node) {
48495             if (node.kind === 198) {
48496                 var template = node.template;
48497                 var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())];
48498                 if (template.kind === 211) {
48499                     ts.forEach(template.templateSpans, function (span) {
48500                         args_3.push(span.expression);
48501                     });
48502                 }
48503                 return args_3;
48504             }
48505             if (node.kind === 157) {
48506                 return getEffectiveDecoratorArguments(node);
48507             }
48508             if (ts.isJsxOpeningLikeElement(node)) {
48509                 return node.attributes.properties.length > 0 || (ts.isJsxOpeningElement(node) && node.parent.children.length > 0) ? [node.attributes] : ts.emptyArray;
48510             }
48511             var args = node.arguments || ts.emptyArray;
48512             var length = args.length;
48513             if (length && isSpreadArgument(args[length - 1]) && getSpreadArgumentIndex(args) === length - 1) {
48514                 var spreadArgument_1 = args[length - 1];
48515                 var type = flowLoopCount ? checkExpression(spreadArgument_1.expression) : checkExpressionCached(spreadArgument_1.expression);
48516                 if (isTupleType(type)) {
48517                     var typeArguments = getTypeArguments(type);
48518                     var restIndex_2 = type.target.hasRestElement ? typeArguments.length - 1 : -1;
48519                     var syntheticArgs = ts.map(typeArguments, function (t, i) { return createSyntheticExpression(spreadArgument_1, t, i === restIndex_2); });
48520                     return ts.concatenate(args.slice(0, length - 1), syntheticArgs);
48521                 }
48522             }
48523             return args;
48524         }
48525         function getEffectiveDecoratorArguments(node) {
48526             var parent = node.parent;
48527             var expr = node.expression;
48528             switch (parent.kind) {
48529                 case 245:
48530                 case 214:
48531                     return [
48532                         createSyntheticExpression(expr, getTypeOfSymbol(getSymbolOfNode(parent)))
48533                     ];
48534                 case 156:
48535                     var func = parent.parent;
48536                     return [
48537                         createSyntheticExpression(expr, parent.parent.kind === 162 ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType),
48538                         createSyntheticExpression(expr, anyType),
48539                         createSyntheticExpression(expr, numberType)
48540                     ];
48541                 case 159:
48542                 case 161:
48543                 case 163:
48544                 case 164:
48545                     var hasPropDesc = parent.kind !== 159 && languageVersion !== 0;
48546                     return [
48547                         createSyntheticExpression(expr, getParentTypeOfClassElement(parent)),
48548                         createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)),
48549                         createSyntheticExpression(expr, hasPropDesc ? createTypedPropertyDescriptorType(getTypeOfNode(parent)) : anyType)
48550                     ];
48551             }
48552             return ts.Debug.fail();
48553         }
48554         function getDecoratorArgumentCount(node, signature) {
48555             switch (node.parent.kind) {
48556                 case 245:
48557                 case 214:
48558                     return 1;
48559                 case 159:
48560                     return 2;
48561                 case 161:
48562                 case 163:
48563                 case 164:
48564                     return languageVersion === 0 || signature.parameters.length <= 2 ? 2 : 3;
48565                 case 156:
48566                     return 3;
48567                 default:
48568                     return ts.Debug.fail();
48569             }
48570         }
48571         function getDiagnosticSpanForCallNode(node, doNotIncludeArguments) {
48572             var start;
48573             var length;
48574             var sourceFile = ts.getSourceFileOfNode(node);
48575             if (ts.isPropertyAccessExpression(node.expression)) {
48576                 var nameSpan = ts.getErrorSpanForNode(sourceFile, node.expression.name);
48577                 start = nameSpan.start;
48578                 length = doNotIncludeArguments ? nameSpan.length : node.end - start;
48579             }
48580             else {
48581                 var expressionSpan = ts.getErrorSpanForNode(sourceFile, node.expression);
48582                 start = expressionSpan.start;
48583                 length = doNotIncludeArguments ? expressionSpan.length : node.end - start;
48584             }
48585             return { start: start, length: length, sourceFile: sourceFile };
48586         }
48587         function getDiagnosticForCallNode(node, message, arg0, arg1, arg2, arg3) {
48588             if (ts.isCallExpression(node)) {
48589                 var _a = getDiagnosticSpanForCallNode(node), sourceFile = _a.sourceFile, start = _a.start, length_5 = _a.length;
48590                 return ts.createFileDiagnostic(sourceFile, start, length_5, message, arg0, arg1, arg2, arg3);
48591             }
48592             else {
48593                 return ts.createDiagnosticForNode(node, message, arg0, arg1, arg2, arg3);
48594             }
48595         }
48596         function getArgumentArityError(node, signatures, args) {
48597             var min = Number.POSITIVE_INFINITY;
48598             var max = Number.NEGATIVE_INFINITY;
48599             var belowArgCount = Number.NEGATIVE_INFINITY;
48600             var aboveArgCount = Number.POSITIVE_INFINITY;
48601             var argCount = args.length;
48602             var closestSignature;
48603             for (var _i = 0, signatures_8 = signatures; _i < signatures_8.length; _i++) {
48604                 var sig = signatures_8[_i];
48605                 var minCount = getMinArgumentCount(sig);
48606                 var maxCount = getParameterCount(sig);
48607                 if (minCount < argCount && minCount > belowArgCount)
48608                     belowArgCount = minCount;
48609                 if (argCount < maxCount && maxCount < aboveArgCount)
48610                     aboveArgCount = maxCount;
48611                 if (minCount < min) {
48612                     min = minCount;
48613                     closestSignature = sig;
48614                 }
48615                 max = Math.max(max, maxCount);
48616             }
48617             var hasRestParameter = ts.some(signatures, hasEffectiveRestParameter);
48618             var paramRange = hasRestParameter ? min :
48619                 min < max ? min + "-" + max :
48620                     min;
48621             var hasSpreadArgument = getSpreadArgumentIndex(args) > -1;
48622             if (argCount <= max && hasSpreadArgument) {
48623                 argCount--;
48624             }
48625             var spanArray;
48626             var related;
48627             var error = hasRestParameter || hasSpreadArgument ? hasRestParameter && hasSpreadArgument ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1_or_more :
48628                 hasRestParameter ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1 :
48629                     ts.Diagnostics.Expected_0_arguments_but_got_1_or_more : ts.Diagnostics.Expected_0_arguments_but_got_1;
48630             if (closestSignature && getMinArgumentCount(closestSignature) > argCount && closestSignature.declaration) {
48631                 var paramDecl = closestSignature.declaration.parameters[closestSignature.thisParameter ? argCount + 1 : argCount];
48632                 if (paramDecl) {
48633                     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);
48634                 }
48635             }
48636             if (min < argCount && argCount < max) {
48637                 return getDiagnosticForCallNode(node, ts.Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, argCount, belowArgCount, aboveArgCount);
48638             }
48639             if (!hasSpreadArgument && argCount < min) {
48640                 var diagnostic_1 = getDiagnosticForCallNode(node, error, paramRange, argCount);
48641                 return related ? ts.addRelatedInfo(diagnostic_1, related) : diagnostic_1;
48642             }
48643             if (hasRestParameter || hasSpreadArgument) {
48644                 spanArray = ts.createNodeArray(args);
48645                 if (hasSpreadArgument && argCount) {
48646                     var nextArg = ts.elementAt(args, getSpreadArgumentIndex(args) + 1) || undefined;
48647                     spanArray = ts.createNodeArray(args.slice(max > argCount && nextArg ? args.indexOf(nextArg) : Math.min(max, args.length - 1)));
48648                 }
48649             }
48650             else {
48651                 spanArray = ts.createNodeArray(args.slice(max));
48652             }
48653             spanArray.pos = ts.first(spanArray).pos;
48654             spanArray.end = ts.last(spanArray).end;
48655             if (spanArray.end === spanArray.pos) {
48656                 spanArray.end++;
48657             }
48658             var diagnostic = ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), spanArray, error, paramRange, argCount);
48659             return related ? ts.addRelatedInfo(diagnostic, related) : diagnostic;
48660         }
48661         function getTypeArgumentArityError(node, signatures, typeArguments) {
48662             var argCount = typeArguments.length;
48663             if (signatures.length === 1) {
48664                 var sig = signatures[0];
48665                 var min_1 = getMinTypeArgumentCount(sig.typeParameters);
48666                 var max = ts.length(sig.typeParameters);
48667                 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);
48668             }
48669             var belowArgCount = -Infinity;
48670             var aboveArgCount = Infinity;
48671             for (var _i = 0, signatures_9 = signatures; _i < signatures_9.length; _i++) {
48672                 var sig = signatures_9[_i];
48673                 var min_2 = getMinTypeArgumentCount(sig.typeParameters);
48674                 var max = ts.length(sig.typeParameters);
48675                 if (min_2 > argCount) {
48676                     aboveArgCount = Math.min(aboveArgCount, min_2);
48677                 }
48678                 else if (max < argCount) {
48679                     belowArgCount = Math.max(belowArgCount, max);
48680                 }
48681             }
48682             if (belowArgCount !== -Infinity && aboveArgCount !== Infinity) {
48683                 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);
48684             }
48685             return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount);
48686         }
48687         function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, fallbackError) {
48688             var isTaggedTemplate = node.kind === 198;
48689             var isDecorator = node.kind === 157;
48690             var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node);
48691             var reportErrors = !candidatesOutArray;
48692             var typeArguments;
48693             if (!isDecorator) {
48694                 typeArguments = node.typeArguments;
48695                 if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 102) {
48696                     ts.forEach(typeArguments, checkSourceElement);
48697                 }
48698             }
48699             var candidates = candidatesOutArray || [];
48700             reorderCandidates(signatures, candidates, callChainFlags);
48701             if (!candidates.length) {
48702                 if (reportErrors) {
48703                     diagnostics.add(getDiagnosticForCallNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures));
48704                 }
48705                 return resolveErrorCall(node);
48706             }
48707             var args = getEffectiveCallArguments(node);
48708             var isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
48709             var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 : 0;
48710             var candidatesForArgumentError;
48711             var candidateForArgumentArityError;
48712             var candidateForTypeArgumentError;
48713             var result;
48714             var signatureHelpTrailingComma = !!(checkMode & 16) && node.kind === 196 && node.arguments.hasTrailingComma;
48715             if (candidates.length > 1) {
48716                 result = chooseOverload(candidates, subtypeRelation, signatureHelpTrailingComma);
48717             }
48718             if (!result) {
48719                 result = chooseOverload(candidates, assignableRelation, signatureHelpTrailingComma);
48720             }
48721             if (result) {
48722                 return result;
48723             }
48724             if (reportErrors) {
48725                 if (candidatesForArgumentError) {
48726                     if (candidatesForArgumentError.length === 1 || candidatesForArgumentError.length > 3) {
48727                         var last_2 = candidatesForArgumentError[candidatesForArgumentError.length - 1];
48728                         var chain_1;
48729                         if (candidatesForArgumentError.length > 3) {
48730                             chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.The_last_overload_gave_the_following_error);
48731                             chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.No_overload_matches_this_call);
48732                         }
48733                         var diags = getSignatureApplicabilityError(node, args, last_2, assignableRelation, 0, true, function () { return chain_1; });
48734                         if (diags) {
48735                             for (var _i = 0, diags_1 = diags; _i < diags_1.length; _i++) {
48736                                 var d = diags_1[_i];
48737                                 if (last_2.declaration && candidatesForArgumentError.length > 3) {
48738                                     ts.addRelatedInfo(d, ts.createDiagnosticForNode(last_2.declaration, ts.Diagnostics.The_last_overload_is_declared_here));
48739                                 }
48740                                 diagnostics.add(d);
48741                             }
48742                         }
48743                         else {
48744                             ts.Debug.fail("No error for last overload signature");
48745                         }
48746                     }
48747                     else {
48748                         var allDiagnostics = [];
48749                         var max = 0;
48750                         var min_3 = Number.MAX_VALUE;
48751                         var minIndex = 0;
48752                         var i_1 = 0;
48753                         var _loop_17 = function (c) {
48754                             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)); };
48755                             var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0, true, chain_2);
48756                             if (diags_2) {
48757                                 if (diags_2.length <= min_3) {
48758                                     min_3 = diags_2.length;
48759                                     minIndex = i_1;
48760                                 }
48761                                 max = Math.max(max, diags_2.length);
48762                                 allDiagnostics.push(diags_2);
48763                             }
48764                             else {
48765                                 ts.Debug.fail("No error for 3 or fewer overload signatures");
48766                             }
48767                             i_1++;
48768                         };
48769                         for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
48770                             var c = candidatesForArgumentError_1[_a];
48771                             _loop_17(c);
48772                         }
48773                         var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
48774                         ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
48775                         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);
48776                         var related = ts.flatMap(diags_3, function (d) { return d.relatedInformation; });
48777                         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; })) {
48778                             var _b = diags_3[0], file = _b.file, start = _b.start, length_6 = _b.length;
48779                             diagnostics.add({ file: file, start: start, length: length_6, code: chain.code, category: chain.category, messageText: chain, relatedInformation: related });
48780                         }
48781                         else {
48782                             diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, chain, related));
48783                         }
48784                     }
48785                 }
48786                 else if (candidateForArgumentArityError) {
48787                     diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args));
48788                 }
48789                 else if (candidateForTypeArgumentError) {
48790                     checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, true, fallbackError);
48791                 }
48792                 else {
48793                     var signaturesWithCorrectTypeArgumentArity = ts.filter(signatures, function (s) { return hasCorrectTypeArgumentArity(s, typeArguments); });
48794                     if (signaturesWithCorrectTypeArgumentArity.length === 0) {
48795                         diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments));
48796                     }
48797                     else if (!isDecorator) {
48798                         diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args));
48799                     }
48800                     else if (fallbackError) {
48801                         diagnostics.add(getDiagnosticForCallNode(node, fallbackError));
48802                     }
48803                 }
48804             }
48805             return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray);
48806             function chooseOverload(candidates, relation, signatureHelpTrailingComma) {
48807                 if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; }
48808                 candidatesForArgumentError = undefined;
48809                 candidateForArgumentArityError = undefined;
48810                 candidateForTypeArgumentError = undefined;
48811                 if (isSingleNonGenericCandidate) {
48812                     var candidate = candidates[0];
48813                     if (ts.some(typeArguments) || !hasCorrectArity(node, args, candidate, signatureHelpTrailingComma)) {
48814                         return undefined;
48815                     }
48816                     if (getSignatureApplicabilityError(node, args, candidate, relation, 0, false, undefined)) {
48817                         candidatesForArgumentError = [candidate];
48818                         return undefined;
48819                     }
48820                     return candidate;
48821                 }
48822                 for (var candidateIndex = 0; candidateIndex < candidates.length; candidateIndex++) {
48823                     var candidate = candidates[candidateIndex];
48824                     if (!hasCorrectTypeArgumentArity(candidate, typeArguments) || !hasCorrectArity(node, args, candidate, signatureHelpTrailingComma)) {
48825                         continue;
48826                     }
48827                     var checkCandidate = void 0;
48828                     var inferenceContext = void 0;
48829                     if (candidate.typeParameters) {
48830                         var typeArgumentTypes = void 0;
48831                         if (ts.some(typeArguments)) {
48832                             typeArgumentTypes = checkTypeArguments(candidate, typeArguments, false);
48833                             if (!typeArgumentTypes) {
48834                                 candidateForTypeArgumentError = candidate;
48835                                 continue;
48836                             }
48837                         }
48838                         else {
48839                             inferenceContext = createInferenceContext(candidate.typeParameters, candidate, ts.isInJSFile(node) ? 2 : 0);
48840                             typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode | 8, inferenceContext);
48841                             argCheckMode |= inferenceContext.flags & 4 ? 8 : 0;
48842                         }
48843                         checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters);
48844                         if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma)) {
48845                             candidateForArgumentArityError = checkCandidate;
48846                             continue;
48847                         }
48848                     }
48849                     else {
48850                         checkCandidate = candidate;
48851                     }
48852                     if (getSignatureApplicabilityError(node, args, checkCandidate, relation, argCheckMode, false, undefined)) {
48853                         (candidatesForArgumentError || (candidatesForArgumentError = [])).push(checkCandidate);
48854                         continue;
48855                     }
48856                     if (argCheckMode) {
48857                         argCheckMode = 0;
48858                         if (inferenceContext) {
48859                             var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
48860                             checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters);
48861                             if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma)) {
48862                                 candidateForArgumentArityError = checkCandidate;
48863                                 continue;
48864                             }
48865                         }
48866                         if (getSignatureApplicabilityError(node, args, checkCandidate, relation, argCheckMode, false, undefined)) {
48867                             (candidatesForArgumentError || (candidatesForArgumentError = [])).push(checkCandidate);
48868                             continue;
48869                         }
48870                     }
48871                     candidates[candidateIndex] = checkCandidate;
48872                     return checkCandidate;
48873                 }
48874                 return undefined;
48875             }
48876         }
48877         function getCandidateForOverloadFailure(node, candidates, args, hasCandidatesOutArray) {
48878             ts.Debug.assert(candidates.length > 0);
48879             checkNodeDeferred(node);
48880             return hasCandidatesOutArray || candidates.length === 1 || candidates.some(function (c) { return !!c.typeParameters; })
48881                 ? pickLongestCandidateSignature(node, candidates, args)
48882                 : createUnionOfSignaturesForOverloadFailure(candidates);
48883         }
48884         function createUnionOfSignaturesForOverloadFailure(candidates) {
48885             var thisParameters = ts.mapDefined(candidates, function (c) { return c.thisParameter; });
48886             var thisParameter;
48887             if (thisParameters.length) {
48888                 thisParameter = createCombinedSymbolFromTypes(thisParameters, thisParameters.map(getTypeOfParameter));
48889             }
48890             var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
48891             var parameters = [];
48892             var _loop_18 = function (i) {
48893                 var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
48894                     i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
48895                     i < s.parameters.length ? s.parameters[i] : undefined; });
48896                 ts.Debug.assert(symbols.length !== 0);
48897                 parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
48898             };
48899             for (var i = 0; i < maxNonRestParam; i++) {
48900                 _loop_18(i);
48901             }
48902             var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
48903             var flags = 0;
48904             if (restParameterSymbols.length !== 0) {
48905                 var type = createArrayType(getUnionType(ts.mapDefined(candidates, tryGetRestTypeOfSignature), 2));
48906                 parameters.push(createCombinedSymbolForOverloadFailure(restParameterSymbols, type));
48907                 flags |= 1;
48908             }
48909             if (candidates.some(signatureHasLiteralTypes)) {
48910                 flags |= 2;
48911             }
48912             return createSignature(candidates[0].declaration, undefined, thisParameter, parameters, getIntersectionType(candidates.map(getReturnTypeOfSignature)), undefined, minArgumentCount, flags);
48913         }
48914         function getNumNonRestParameters(signature) {
48915             var numParams = signature.parameters.length;
48916             return signatureHasRestParameter(signature) ? numParams - 1 : numParams;
48917         }
48918         function createCombinedSymbolFromTypes(sources, types) {
48919             return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, 2));
48920         }
48921         function createCombinedSymbolForOverloadFailure(sources, type) {
48922             return createSymbolWithType(ts.first(sources), type);
48923         }
48924         function pickLongestCandidateSignature(node, candidates, args) {
48925             var bestIndex = getLongestCandidateIndex(candidates, apparentArgumentCount === undefined ? args.length : apparentArgumentCount);
48926             var candidate = candidates[bestIndex];
48927             var typeParameters = candidate.typeParameters;
48928             if (!typeParameters) {
48929                 return candidate;
48930             }
48931             var typeArgumentNodes = callLikeExpressionMayHaveTypeArguments(node) ? node.typeArguments : undefined;
48932             var instantiated = typeArgumentNodes
48933                 ? createSignatureInstantiation(candidate, getTypeArgumentsFromNodes(typeArgumentNodes, typeParameters, ts.isInJSFile(node)))
48934                 : inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args);
48935             candidates[bestIndex] = instantiated;
48936             return instantiated;
48937         }
48938         function getTypeArgumentsFromNodes(typeArgumentNodes, typeParameters, isJs) {
48939             var typeArguments = typeArgumentNodes.map(getTypeOfNode);
48940             while (typeArguments.length > typeParameters.length) {
48941                 typeArguments.pop();
48942             }
48943             while (typeArguments.length < typeParameters.length) {
48944                 typeArguments.push(getConstraintOfTypeParameter(typeParameters[typeArguments.length]) || getDefaultTypeArgumentType(isJs));
48945             }
48946             return typeArguments;
48947         }
48948         function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args) {
48949             var inferenceContext = createInferenceContext(typeParameters, candidate, ts.isInJSFile(node) ? 2 : 0);
48950             var typeArgumentTypes = inferTypeArguments(node, candidate, args, 4 | 8, inferenceContext);
48951             return createSignatureInstantiation(candidate, typeArgumentTypes);
48952         }
48953         function getLongestCandidateIndex(candidates, argsCount) {
48954             var maxParamsIndex = -1;
48955             var maxParams = -1;
48956             for (var i = 0; i < candidates.length; i++) {
48957                 var candidate = candidates[i];
48958                 var paramCount = getParameterCount(candidate);
48959                 if (hasEffectiveRestParameter(candidate) || paramCount >= argsCount) {
48960                     return i;
48961                 }
48962                 if (paramCount > maxParams) {
48963                     maxParams = paramCount;
48964                     maxParamsIndex = i;
48965                 }
48966             }
48967             return maxParamsIndex;
48968         }
48969         function resolveCallExpression(node, candidatesOutArray, checkMode) {
48970             if (node.expression.kind === 102) {
48971                 var superType = checkSuperExpression(node.expression);
48972                 if (isTypeAny(superType)) {
48973                     for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) {
48974                         var arg = _a[_i];
48975                         checkExpression(arg);
48976                     }
48977                     return anySignature;
48978                 }
48979                 if (superType !== errorType) {
48980                     var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node));
48981                     if (baseTypeNode) {
48982                         var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode);
48983                         return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0);
48984                     }
48985                 }
48986                 return resolveUntypedCall(node);
48987             }
48988             var callChainFlags;
48989             var funcType = checkExpression(node.expression);
48990             if (ts.isCallChain(node)) {
48991                 var nonOptionalType = getOptionalExpressionType(funcType, node.expression);
48992                 callChainFlags = nonOptionalType === funcType ? 0 :
48993                     ts.isOutermostOptionalChain(node) ? 8 :
48994                         4;
48995                 funcType = nonOptionalType;
48996             }
48997             else {
48998                 callChainFlags = 0;
48999             }
49000             funcType = checkNonNullTypeWithReporter(funcType, node.expression, reportCannotInvokePossiblyNullOrUndefinedError);
49001             if (funcType === silentNeverType) {
49002                 return silentNeverSignature;
49003             }
49004             var apparentType = getApparentType(funcType);
49005             if (apparentType === errorType) {
49006                 return resolveErrorCall(node);
49007             }
49008             var callSignatures = getSignaturesOfType(apparentType, 0);
49009             var numConstructSignatures = getSignaturesOfType(apparentType, 1).length;
49010             if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, numConstructSignatures)) {
49011                 if (funcType !== errorType && node.typeArguments) {
49012                     error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments);
49013                 }
49014                 return resolveUntypedCall(node);
49015             }
49016             if (!callSignatures.length) {
49017                 if (numConstructSignatures) {
49018                     error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
49019                 }
49020                 else {
49021                     var relatedInformation = void 0;
49022                     if (node.arguments.length === 1) {
49023                         var text = ts.getSourceFileOfNode(node).text;
49024                         if (ts.isLineBreak(text.charCodeAt(ts.skipTrivia(text, node.expression.end, true) - 1))) {
49025                             relatedInformation = ts.createDiagnosticForNode(node.expression, ts.Diagnostics.Are_you_missing_a_semicolon);
49026                         }
49027                     }
49028                     invocationError(node.expression, apparentType, 0, relatedInformation);
49029                 }
49030                 return resolveErrorCall(node);
49031             }
49032             if (checkMode & 8 && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) {
49033                 skippedGenericFunction(node, checkMode);
49034                 return resolvingSignature;
49035             }
49036             if (callSignatures.some(function (sig) { return ts.isInJSFile(sig.declaration) && !!ts.getJSDocClassTag(sig.declaration); })) {
49037                 error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
49038                 return resolveErrorCall(node);
49039             }
49040             return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
49041         }
49042         function isGenericFunctionReturningFunction(signature) {
49043             return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature)));
49044         }
49045         function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) {
49046             return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144) ||
49047                 !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & (1048576 | 131072)) && isTypeAssignableTo(funcType, globalFunctionType);
49048         }
49049         function resolveNewExpression(node, candidatesOutArray, checkMode) {
49050             if (node.arguments && languageVersion < 1) {
49051                 var spreadIndex = getSpreadArgumentIndex(node.arguments);
49052                 if (spreadIndex >= 0) {
49053                     error(node.arguments[spreadIndex], ts.Diagnostics.Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher);
49054                 }
49055             }
49056             var expressionType = checkNonNullExpression(node.expression);
49057             if (expressionType === silentNeverType) {
49058                 return silentNeverSignature;
49059             }
49060             expressionType = getApparentType(expressionType);
49061             if (expressionType === errorType) {
49062                 return resolveErrorCall(node);
49063             }
49064             if (isTypeAny(expressionType)) {
49065                 if (node.typeArguments) {
49066                     error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments);
49067                 }
49068                 return resolveUntypedCall(node);
49069             }
49070             var constructSignatures = getSignaturesOfType(expressionType, 1);
49071             if (constructSignatures.length) {
49072                 if (!isConstructorAccessible(node, constructSignatures[0])) {
49073                     return resolveErrorCall(node);
49074                 }
49075                 var valueDecl = expressionType.symbol && ts.getClassLikeDeclarationOfSymbol(expressionType.symbol);
49076                 if (valueDecl && ts.hasModifier(valueDecl, 128)) {
49077                     error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class);
49078                     return resolveErrorCall(node);
49079                 }
49080                 return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0);
49081             }
49082             var callSignatures = getSignaturesOfType(expressionType, 0);
49083             if (callSignatures.length) {
49084                 var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0);
49085                 if (!noImplicitAny) {
49086                     if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) {
49087                         error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword);
49088                     }
49089                     if (getThisTypeOfSignature(signature) === voidType) {
49090                         error(node, ts.Diagnostics.A_function_that_is_called_with_the_new_keyword_cannot_have_a_this_type_that_is_void);
49091                     }
49092                 }
49093                 return signature;
49094             }
49095             invocationError(node.expression, expressionType, 1);
49096             return resolveErrorCall(node);
49097         }
49098         function typeHasProtectedAccessibleBase(target, type) {
49099             var baseTypes = getBaseTypes(type);
49100             if (!ts.length(baseTypes)) {
49101                 return false;
49102             }
49103             var firstBase = baseTypes[0];
49104             if (firstBase.flags & 2097152) {
49105                 var types = firstBase.types;
49106                 var mixinFlags = findMixins(types);
49107                 var i = 0;
49108                 for (var _i = 0, _a = firstBase.types; _i < _a.length; _i++) {
49109                     var intersectionMember = _a[_i];
49110                     if (!mixinFlags[i]) {
49111                         if (ts.getObjectFlags(intersectionMember) & (1 | 2)) {
49112                             if (intersectionMember.symbol === target) {
49113                                 return true;
49114                             }
49115                             if (typeHasProtectedAccessibleBase(target, intersectionMember)) {
49116                                 return true;
49117                             }
49118                         }
49119                     }
49120                     i++;
49121                 }
49122                 return false;
49123             }
49124             if (firstBase.symbol === target) {
49125                 return true;
49126             }
49127             return typeHasProtectedAccessibleBase(target, firstBase);
49128         }
49129         function isConstructorAccessible(node, signature) {
49130             if (!signature || !signature.declaration) {
49131                 return true;
49132             }
49133             var declaration = signature.declaration;
49134             var modifiers = ts.getSelectedModifierFlags(declaration, 24);
49135             if (!modifiers || declaration.kind !== 162) {
49136                 return true;
49137             }
49138             var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(declaration.parent.symbol);
49139             var declaringClass = getDeclaredTypeOfSymbol(declaration.parent.symbol);
49140             if (!isNodeWithinClass(node, declaringClassDeclaration)) {
49141                 var containingClass = ts.getContainingClass(node);
49142                 if (containingClass && modifiers & 16) {
49143                     var containingType = getTypeOfNode(containingClass);
49144                     if (typeHasProtectedAccessibleBase(declaration.parent.symbol, containingType)) {
49145                         return true;
49146                     }
49147                 }
49148                 if (modifiers & 8) {
49149                     error(node, ts.Diagnostics.Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration, typeToString(declaringClass));
49150                 }
49151                 if (modifiers & 16) {
49152                     error(node, ts.Diagnostics.Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration, typeToString(declaringClass));
49153                 }
49154                 return false;
49155             }
49156             return true;
49157         }
49158         function invocationErrorDetails(apparentType, kind) {
49159             var errorInfo;
49160             var isCall = kind === 0;
49161             var awaitedType = getAwaitedType(apparentType);
49162             var maybeMissingAwait = awaitedType && getSignaturesOfType(awaitedType, kind).length > 0;
49163             if (apparentType.flags & 1048576) {
49164                 var types = apparentType.types;
49165                 var hasSignatures = false;
49166                 for (var _i = 0, types_18 = types; _i < types_18.length; _i++) {
49167                     var constituent = types_18[_i];
49168                     var signatures = getSignaturesOfType(constituent, kind);
49169                     if (signatures.length !== 0) {
49170                         hasSignatures = true;
49171                         if (errorInfo) {
49172                             break;
49173                         }
49174                     }
49175                     else {
49176                         if (!errorInfo) {
49177                             errorInfo = ts.chainDiagnosticMessages(errorInfo, isCall ?
49178                                 ts.Diagnostics.Type_0_has_no_call_signatures :
49179                                 ts.Diagnostics.Type_0_has_no_construct_signatures, typeToString(constituent));
49180                             errorInfo = ts.chainDiagnosticMessages(errorInfo, isCall ?
49181                                 ts.Diagnostics.Not_all_constituents_of_type_0_are_callable :
49182                                 ts.Diagnostics.Not_all_constituents_of_type_0_are_constructable, typeToString(apparentType));
49183                         }
49184                         if (hasSignatures) {
49185                             break;
49186                         }
49187                     }
49188                 }
49189                 if (!hasSignatures) {
49190                     errorInfo = ts.chainDiagnosticMessages(undefined, isCall ?
49191                         ts.Diagnostics.No_constituent_of_type_0_is_callable :
49192                         ts.Diagnostics.No_constituent_of_type_0_is_constructable, typeToString(apparentType));
49193                 }
49194                 if (!errorInfo) {
49195                     errorInfo = ts.chainDiagnosticMessages(errorInfo, isCall ?
49196                         ts.Diagnostics.Each_member_of_the_union_type_0_has_signatures_but_none_of_those_signatures_are_compatible_with_each_other :
49197                         ts.Diagnostics.Each_member_of_the_union_type_0_has_construct_signatures_but_none_of_those_signatures_are_compatible_with_each_other, typeToString(apparentType));
49198                 }
49199             }
49200             else {
49201                 errorInfo = ts.chainDiagnosticMessages(errorInfo, isCall ?
49202                     ts.Diagnostics.Type_0_has_no_call_signatures :
49203                     ts.Diagnostics.Type_0_has_no_construct_signatures, typeToString(apparentType));
49204             }
49205             return {
49206                 messageChain: ts.chainDiagnosticMessages(errorInfo, isCall ? ts.Diagnostics.This_expression_is_not_callable : ts.Diagnostics.This_expression_is_not_constructable),
49207                 relatedMessage: maybeMissingAwait ? ts.Diagnostics.Did_you_forget_to_use_await : undefined,
49208             };
49209         }
49210         function invocationError(errorTarget, apparentType, kind, relatedInformation) {
49211             var _a = invocationErrorDetails(apparentType, kind), messageChain = _a.messageChain, relatedInfo = _a.relatedMessage;
49212             var diagnostic = ts.createDiagnosticForNodeFromMessageChain(errorTarget, messageChain);
49213             if (relatedInfo) {
49214                 ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(errorTarget, relatedInfo));
49215             }
49216             if (ts.isCallExpression(errorTarget.parent)) {
49217                 var _b = getDiagnosticSpanForCallNode(errorTarget.parent, true), start = _b.start, length_7 = _b.length;
49218                 diagnostic.start = start;
49219                 diagnostic.length = length_7;
49220             }
49221             diagnostics.add(diagnostic);
49222             invocationErrorRecovery(apparentType, kind, relatedInformation ? ts.addRelatedInfo(diagnostic, relatedInformation) : diagnostic);
49223         }
49224         function invocationErrorRecovery(apparentType, kind, diagnostic) {
49225             if (!apparentType.symbol) {
49226                 return;
49227             }
49228             var importNode = getSymbolLinks(apparentType.symbol).originatingImport;
49229             if (importNode && !ts.isImportCall(importNode)) {
49230                 var sigs = getSignaturesOfType(getTypeOfSymbol(getSymbolLinks(apparentType.symbol).target), kind);
49231                 if (!sigs || !sigs.length)
49232                     return;
49233                 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));
49234             }
49235         }
49236         function resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode) {
49237             var tagType = checkExpression(node.tag);
49238             var apparentType = getApparentType(tagType);
49239             if (apparentType === errorType) {
49240                 return resolveErrorCall(node);
49241             }
49242             var callSignatures = getSignaturesOfType(apparentType, 0);
49243             var numConstructSignatures = getSignaturesOfType(apparentType, 1).length;
49244             if (isUntypedFunctionCall(tagType, apparentType, callSignatures.length, numConstructSignatures)) {
49245                 return resolveUntypedCall(node);
49246             }
49247             if (!callSignatures.length) {
49248                 invocationError(node.tag, apparentType, 0);
49249                 return resolveErrorCall(node);
49250             }
49251             return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0);
49252         }
49253         function getDiagnosticHeadMessageForDecoratorResolution(node) {
49254             switch (node.parent.kind) {
49255                 case 245:
49256                 case 214:
49257                     return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression;
49258                 case 156:
49259                     return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression;
49260                 case 159:
49261                     return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression;
49262                 case 161:
49263                 case 163:
49264                 case 164:
49265                     return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression;
49266                 default:
49267                     return ts.Debug.fail();
49268             }
49269         }
49270         function resolveDecorator(node, candidatesOutArray, checkMode) {
49271             var funcType = checkExpression(node.expression);
49272             var apparentType = getApparentType(funcType);
49273             if (apparentType === errorType) {
49274                 return resolveErrorCall(node);
49275             }
49276             var callSignatures = getSignaturesOfType(apparentType, 0);
49277             var numConstructSignatures = getSignaturesOfType(apparentType, 1).length;
49278             if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, numConstructSignatures)) {
49279                 return resolveUntypedCall(node);
49280             }
49281             if (isPotentiallyUncalledDecorator(node, callSignatures)) {
49282                 var nodeStr = ts.getTextOfNode(node.expression, false);
49283                 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);
49284                 return resolveErrorCall(node);
49285             }
49286             var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node);
49287             if (!callSignatures.length) {
49288                 var errorDetails = invocationErrorDetails(apparentType, 0);
49289                 var messageChain = ts.chainDiagnosticMessages(errorDetails.messageChain, headMessage);
49290                 var diag = ts.createDiagnosticForNodeFromMessageChain(node.expression, messageChain);
49291                 if (errorDetails.relatedMessage) {
49292                     ts.addRelatedInfo(diag, ts.createDiagnosticForNode(node.expression, errorDetails.relatedMessage));
49293                 }
49294                 diagnostics.add(diag);
49295                 invocationErrorRecovery(apparentType, 0, diag);
49296                 return resolveErrorCall(node);
49297             }
49298             return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0, headMessage);
49299         }
49300         function createSignatureForJSXIntrinsic(node, result) {
49301             var namespace = getJsxNamespaceAt(node);
49302             var exports = namespace && getExportsOfSymbol(namespace);
49303             var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968);
49304             var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968, node);
49305             var declaration = ts.createFunctionTypeNode(undefined, [ts.createParameter(undefined, undefined, undefined, "props", undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.createTypeReferenceNode(returnNode, undefined) : ts.createKeywordTypeNode(125));
49306             var parameterSymbol = createSymbol(1, "props");
49307             parameterSymbol.type = result;
49308             return createSignature(declaration, undefined, undefined, [parameterSymbol], typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType, undefined, 1, 0);
49309         }
49310         function resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode) {
49311             if (isJsxIntrinsicIdentifier(node.tagName)) {
49312                 var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node);
49313                 var fakeSignature = createSignatureForJSXIntrinsic(node, result);
49314                 checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), undefined, 0), result, node.tagName, node.attributes);
49315                 return fakeSignature;
49316             }
49317             var exprTypes = checkExpression(node.tagName);
49318             var apparentType = getApparentType(exprTypes);
49319             if (apparentType === errorType) {
49320                 return resolveErrorCall(node);
49321             }
49322             var signatures = getUninstantiatedJsxSignaturesOfType(exprTypes, node);
49323             if (isUntypedFunctionCall(exprTypes, apparentType, signatures.length, 0)) {
49324                 return resolveUntypedCall(node);
49325             }
49326             if (signatures.length === 0) {
49327                 error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName));
49328                 return resolveErrorCall(node);
49329             }
49330             return resolveCall(node, signatures, candidatesOutArray, checkMode, 0);
49331         }
49332         function isPotentiallyUncalledDecorator(decorator, signatures) {
49333             return signatures.length && ts.every(signatures, function (signature) {
49334                 return signature.minArgumentCount === 0 &&
49335                     !signatureHasRestParameter(signature) &&
49336                     signature.parameters.length < getDecoratorArgumentCount(decorator, signature);
49337             });
49338         }
49339         function resolveSignature(node, candidatesOutArray, checkMode) {
49340             switch (node.kind) {
49341                 case 196:
49342                     return resolveCallExpression(node, candidatesOutArray, checkMode);
49343                 case 197:
49344                     return resolveNewExpression(node, candidatesOutArray, checkMode);
49345                 case 198:
49346                     return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode);
49347                 case 157:
49348                     return resolveDecorator(node, candidatesOutArray, checkMode);
49349                 case 268:
49350                 case 267:
49351                     return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode);
49352             }
49353             throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable.");
49354         }
49355         function getResolvedSignature(node, candidatesOutArray, checkMode) {
49356             var links = getNodeLinks(node);
49357             var cached = links.resolvedSignature;
49358             if (cached && cached !== resolvingSignature && !candidatesOutArray) {
49359                 return cached;
49360             }
49361             links.resolvedSignature = resolvingSignature;
49362             var result = resolveSignature(node, candidatesOutArray, checkMode || 0);
49363             if (result !== resolvingSignature) {
49364                 links.resolvedSignature = flowLoopStart === flowLoopCount ? result : cached;
49365             }
49366             return result;
49367         }
49368         function isJSConstructor(node) {
49369             if (!node || !ts.isInJSFile(node)) {
49370                 return false;
49371             }
49372             var func = ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) ? node :
49373                 ts.isVariableDeclaration(node) && node.initializer && ts.isFunctionExpression(node.initializer) ? node.initializer :
49374                     undefined;
49375             if (func) {
49376                 if (ts.getJSDocClassTag(node))
49377                     return true;
49378                 var symbol = getSymbolOfNode(func);
49379                 return !!symbol && ts.hasEntries(symbol.members);
49380             }
49381             return false;
49382         }
49383         function mergeJSSymbols(target, source) {
49384             if (source) {
49385                 var links = getSymbolLinks(source);
49386                 if (!links.inferredClassSymbol || !links.inferredClassSymbol.has("" + getSymbolId(target))) {
49387                     var inferred = ts.isTransientSymbol(target) ? target : cloneSymbol(target);
49388                     inferred.exports = inferred.exports || ts.createSymbolTable();
49389                     inferred.members = inferred.members || ts.createSymbolTable();
49390                     inferred.flags |= source.flags & 32;
49391                     if (ts.hasEntries(source.exports)) {
49392                         mergeSymbolTable(inferred.exports, source.exports);
49393                     }
49394                     if (ts.hasEntries(source.members)) {
49395                         mergeSymbolTable(inferred.members, source.members);
49396                     }
49397                     (links.inferredClassSymbol || (links.inferredClassSymbol = ts.createMap())).set("" + getSymbolId(inferred), inferred);
49398                     return inferred;
49399                 }
49400                 return links.inferredClassSymbol.get("" + getSymbolId(target));
49401             }
49402         }
49403         function getAssignedClassSymbol(decl) {
49404             var assignmentSymbol = decl && decl.parent &&
49405                 (ts.isFunctionDeclaration(decl) && getSymbolOfNode(decl) ||
49406                     ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) ||
49407                     ts.isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent));
49408             var prototype = assignmentSymbol && assignmentSymbol.exports && assignmentSymbol.exports.get("prototype");
49409             var init = prototype && prototype.valueDeclaration && getAssignedJSPrototype(prototype.valueDeclaration);
49410             return init ? getSymbolOfNode(init) : undefined;
49411         }
49412         function getAssignedJSPrototype(node) {
49413             if (!node.parent) {
49414                 return false;
49415             }
49416             var parent = node.parent;
49417             while (parent && parent.kind === 194) {
49418                 parent = parent.parent;
49419             }
49420             if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 62) {
49421                 var right = ts.getInitializerOfBinaryExpression(parent);
49422                 return ts.isObjectLiteralExpression(right) && right;
49423             }
49424         }
49425         function checkCallExpression(node, checkMode) {
49426             if (!checkGrammarTypeArguments(node, node.typeArguments))
49427                 checkGrammarArguments(node.arguments);
49428             var signature = getResolvedSignature(node, undefined, checkMode);
49429             if (signature === resolvingSignature) {
49430                 return nonInferrableType;
49431             }
49432             if (node.expression.kind === 102) {
49433                 return voidType;
49434             }
49435             if (node.kind === 197) {
49436                 var declaration = signature.declaration;
49437                 if (declaration &&
49438                     declaration.kind !== 162 &&
49439                     declaration.kind !== 166 &&
49440                     declaration.kind !== 171 &&
49441                     !ts.isJSDocConstructSignature(declaration) &&
49442                     !isJSConstructor(declaration)) {
49443                     if (noImplicitAny) {
49444                         error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type);
49445                     }
49446                     return anyType;
49447                 }
49448             }
49449             if (ts.isInJSFile(node) && isCommonJsRequire(node)) {
49450                 return resolveExternalModuleTypeByLiteral(node.arguments[0]);
49451             }
49452             var returnType = getReturnTypeOfSignature(signature);
49453             if (returnType.flags & 12288 && isSymbolOrSymbolForCall(node)) {
49454                 return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent));
49455             }
49456             if (node.kind === 196 && node.parent.kind === 226 &&
49457                 returnType.flags & 16384 && getTypePredicateOfSignature(signature)) {
49458                 if (!ts.isDottedName(node.expression)) {
49459                     error(node.expression, ts.Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name);
49460                 }
49461                 else if (!getEffectsSignature(node)) {
49462                     var diagnostic = error(node.expression, ts.Diagnostics.Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation);
49463                     getTypeOfDottedName(node.expression, diagnostic);
49464                 }
49465             }
49466             if (ts.isInJSFile(node)) {
49467                 var decl = ts.getDeclarationOfExpando(node);
49468                 if (decl) {
49469                     var jsSymbol = getSymbolOfNode(decl);
49470                     if (jsSymbol && ts.hasEntries(jsSymbol.exports)) {
49471                         var jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, undefined, undefined);
49472                         jsAssignmentType.objectFlags |= 16384;
49473                         return getIntersectionType([returnType, jsAssignmentType]);
49474                     }
49475                 }
49476             }
49477             return returnType;
49478         }
49479         function isSymbolOrSymbolForCall(node) {
49480             if (!ts.isCallExpression(node))
49481                 return false;
49482             var left = node.expression;
49483             if (ts.isPropertyAccessExpression(left) && left.name.escapedText === "for") {
49484                 left = left.expression;
49485             }
49486             if (!ts.isIdentifier(left) || left.escapedText !== "Symbol") {
49487                 return false;
49488             }
49489             var globalESSymbol = getGlobalESSymbolConstructorSymbol(false);
49490             if (!globalESSymbol) {
49491                 return false;
49492             }
49493             return globalESSymbol === resolveName(left, "Symbol", 111551, undefined, undefined, false);
49494         }
49495         function checkImportCallExpression(node) {
49496             if (!checkGrammarArguments(node.arguments))
49497                 checkGrammarImportCallExpression(node);
49498             if (node.arguments.length === 0) {
49499                 return createPromiseReturnType(node, anyType);
49500             }
49501             var specifier = node.arguments[0];
49502             var specifierType = checkExpressionCached(specifier);
49503             for (var i = 1; i < node.arguments.length; ++i) {
49504                 checkExpressionCached(node.arguments[i]);
49505             }
49506             if (specifierType.flags & 32768 || specifierType.flags & 65536 || !isTypeAssignableTo(specifierType, stringType)) {
49507                 error(specifier, ts.Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType));
49508             }
49509             var moduleSymbol = resolveExternalModuleName(node, specifier);
49510             if (moduleSymbol) {
49511                 var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, true, false);
49512                 if (esModuleSymbol) {
49513                     return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol));
49514                 }
49515             }
49516             return createPromiseReturnType(node, anyType);
49517         }
49518         function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol) {
49519             if (allowSyntheticDefaultImports && type && type !== errorType) {
49520                 var synthType = type;
49521                 if (!synthType.syntheticType) {
49522                     var file = ts.find(originalSymbol.declarations, ts.isSourceFile);
49523                     var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, false);
49524                     if (hasSyntheticDefault) {
49525                         var memberTable = ts.createSymbolTable();
49526                         var newSymbol = createSymbol(2097152, "default");
49527                         newSymbol.nameType = getLiteralType("default");
49528                         newSymbol.target = resolveSymbol(symbol);
49529                         memberTable.set("default", newSymbol);
49530                         var anonymousSymbol = createSymbol(2048, "__type");
49531                         var defaultContainingObject = createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, undefined, undefined);
49532                         anonymousSymbol.type = defaultContainingObject;
49533                         synthType.syntheticType = isValidSpreadType(type) ? getSpreadType(type, defaultContainingObject, anonymousSymbol, 0, false) : defaultContainingObject;
49534                     }
49535                     else {
49536                         synthType.syntheticType = type;
49537                     }
49538                 }
49539                 return synthType.syntheticType;
49540             }
49541             return type;
49542         }
49543         function isCommonJsRequire(node) {
49544             if (!ts.isRequireCall(node, true)) {
49545                 return false;
49546             }
49547             if (!ts.isIdentifier(node.expression))
49548                 return ts.Debug.fail();
49549             var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551, undefined, undefined, true);
49550             if (resolvedRequire === requireSymbol) {
49551                 return true;
49552             }
49553             if (resolvedRequire.flags & 2097152) {
49554                 return false;
49555             }
49556             var targetDeclarationKind = resolvedRequire.flags & 16
49557                 ? 244
49558                 : resolvedRequire.flags & 3
49559                     ? 242
49560                     : 0;
49561             if (targetDeclarationKind !== 0) {
49562                 var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind);
49563                 return !!decl && !!(decl.flags & 8388608);
49564             }
49565             return false;
49566         }
49567         function checkTaggedTemplateExpression(node) {
49568             if (!checkGrammarTaggedTemplateChain(node))
49569                 checkGrammarTypeArguments(node, node.typeArguments);
49570             if (languageVersion < 2) {
49571                 checkExternalEmitHelpers(node, 131072);
49572             }
49573             return getReturnTypeOfSignature(getResolvedSignature(node));
49574         }
49575         function checkAssertion(node) {
49576             return checkAssertionWorker(node, node.type, node.expression);
49577         }
49578         function isValidConstAssertionArgument(node) {
49579             switch (node.kind) {
49580                 case 10:
49581                 case 14:
49582                 case 8:
49583                 case 9:
49584                 case 106:
49585                 case 91:
49586                 case 192:
49587                 case 193:
49588                     return true;
49589                 case 200:
49590                     return isValidConstAssertionArgument(node.expression);
49591                 case 207:
49592                     var op = node.operator;
49593                     var arg = node.operand;
49594                     return op === 40 && (arg.kind === 8 || arg.kind === 9) ||
49595                         op === 39 && arg.kind === 8;
49596                 case 194:
49597                 case 195:
49598                     var expr = node.expression;
49599                     if (ts.isIdentifier(expr)) {
49600                         var symbol = getSymbolAtLocation(expr);
49601                         if (symbol && symbol.flags & 2097152) {
49602                             symbol = resolveAlias(symbol);
49603                         }
49604                         return !!(symbol && (symbol.flags & 384) && getEnumKind(symbol) === 1);
49605                     }
49606             }
49607             return false;
49608         }
49609         function checkAssertionWorker(errNode, type, expression, checkMode) {
49610             var exprType = checkExpression(expression, checkMode);
49611             if (ts.isConstTypeReference(type)) {
49612                 if (!isValidConstAssertionArgument(expression)) {
49613                     error(expression, ts.Diagnostics.A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals);
49614                 }
49615                 return getRegularTypeOfLiteralType(exprType);
49616             }
49617             checkSourceElement(type);
49618             exprType = getRegularTypeOfObjectLiteral(getBaseTypeOfLiteralType(exprType));
49619             var targetType = getTypeFromTypeNode(type);
49620             if (produceDiagnostics && targetType !== errorType) {
49621                 var widenedType = getWidenedType(exprType);
49622                 if (!isTypeComparableTo(targetType, widenedType)) {
49623                     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);
49624                 }
49625             }
49626             return targetType;
49627         }
49628         function checkNonNullChain(node) {
49629             var leftType = checkExpression(node.expression);
49630             var nonOptionalType = getOptionalExpressionType(leftType, node.expression);
49631             return propagateOptionalTypeMarker(getNonNullableType(nonOptionalType), node, nonOptionalType !== leftType);
49632         }
49633         function checkNonNullAssertion(node) {
49634             return node.flags & 32 ? checkNonNullChain(node) :
49635                 getNonNullableType(checkExpression(node.expression));
49636         }
49637         function checkMetaProperty(node) {
49638             checkGrammarMetaProperty(node);
49639             if (node.keywordToken === 99) {
49640                 return checkNewTargetMetaProperty(node);
49641             }
49642             if (node.keywordToken === 96) {
49643                 return checkImportMetaProperty(node);
49644             }
49645             return ts.Debug.assertNever(node.keywordToken);
49646         }
49647         function checkNewTargetMetaProperty(node) {
49648             var container = ts.getNewTargetContainer(node);
49649             if (!container) {
49650                 error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target");
49651                 return errorType;
49652             }
49653             else if (container.kind === 162) {
49654                 var symbol = getSymbolOfNode(container.parent);
49655                 return getTypeOfSymbol(symbol);
49656             }
49657             else {
49658                 var symbol = getSymbolOfNode(container);
49659                 return getTypeOfSymbol(symbol);
49660             }
49661         }
49662         function checkImportMetaProperty(node) {
49663             if (moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) {
49664                 error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system);
49665             }
49666             var file = ts.getSourceFileOfNode(node);
49667             ts.Debug.assert(!!(file.flags & 2097152), "Containing file is missing import meta node flag.");
49668             ts.Debug.assert(!!file.externalModuleIndicator, "Containing file should be a module.");
49669             return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType;
49670         }
49671         function getTypeOfParameter(symbol) {
49672             var type = getTypeOfSymbol(symbol);
49673             if (strictNullChecks) {
49674                 var declaration = symbol.valueDeclaration;
49675                 if (declaration && ts.hasInitializer(declaration)) {
49676                     return getOptionalType(type);
49677                 }
49678             }
49679             return type;
49680         }
49681         function getParameterNameAtPosition(signature, pos) {
49682             var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
49683             if (pos < paramCount) {
49684                 return signature.parameters[pos].escapedName;
49685             }
49686             var restParameter = signature.parameters[paramCount] || unknownSymbol;
49687             var restType = getTypeOfSymbol(restParameter);
49688             if (isTupleType(restType)) {
49689                 var associatedNames = restType.target.associatedNames;
49690                 var index = pos - paramCount;
49691                 return associatedNames && associatedNames[index] || restParameter.escapedName + "_" + index;
49692             }
49693             return restParameter.escapedName;
49694         }
49695         function getTypeAtPosition(signature, pos) {
49696             return tryGetTypeAtPosition(signature, pos) || anyType;
49697         }
49698         function tryGetTypeAtPosition(signature, pos) {
49699             var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
49700             if (pos < paramCount) {
49701                 return getTypeOfParameter(signature.parameters[pos]);
49702             }
49703             if (signatureHasRestParameter(signature)) {
49704                 var restType = getTypeOfSymbol(signature.parameters[paramCount]);
49705                 var index = pos - paramCount;
49706                 if (!isTupleType(restType) || restType.target.hasRestElement || index < getTypeArguments(restType).length) {
49707                     return getIndexedAccessType(restType, getLiteralType(index));
49708                 }
49709             }
49710             return undefined;
49711         }
49712         function getRestTypeAtPosition(source, pos) {
49713             var paramCount = getParameterCount(source);
49714             var restType = getEffectiveRestType(source);
49715             var nonRestCount = paramCount - (restType ? 1 : 0);
49716             if (restType && pos === nonRestCount) {
49717                 return restType;
49718             }
49719             var types = [];
49720             var names = [];
49721             for (var i = pos; i < nonRestCount; i++) {
49722                 types.push(getTypeAtPosition(source, i));
49723                 names.push(getParameterNameAtPosition(source, i));
49724             }
49725             if (restType) {
49726                 types.push(getIndexedAccessType(restType, numberType));
49727                 names.push(getParameterNameAtPosition(source, nonRestCount));
49728             }
49729             var minArgumentCount = getMinArgumentCount(source);
49730             var minLength = minArgumentCount < pos ? 0 : minArgumentCount - pos;
49731             return createTupleType(types, minLength, !!restType, false, names);
49732         }
49733         function getParameterCount(signature) {
49734             var length = signature.parameters.length;
49735             if (signatureHasRestParameter(signature)) {
49736                 var restType = getTypeOfSymbol(signature.parameters[length - 1]);
49737                 if (isTupleType(restType)) {
49738                     return length + getTypeArguments(restType).length - 1;
49739                 }
49740             }
49741             return length;
49742         }
49743         function getMinArgumentCount(signature, strongArityForUntypedJS) {
49744             if (signatureHasRestParameter(signature)) {
49745                 var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]);
49746                 if (isTupleType(restType)) {
49747                     var minLength = restType.target.minLength;
49748                     if (minLength > 0) {
49749                         return signature.parameters.length - 1 + minLength;
49750                     }
49751                 }
49752             }
49753             if (!strongArityForUntypedJS && signature.flags & 16) {
49754                 return 0;
49755             }
49756             return signature.minArgumentCount;
49757         }
49758         function hasEffectiveRestParameter(signature) {
49759             if (signatureHasRestParameter(signature)) {
49760                 var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]);
49761                 return !isTupleType(restType) || restType.target.hasRestElement;
49762             }
49763             return false;
49764         }
49765         function getEffectiveRestType(signature) {
49766             if (signatureHasRestParameter(signature)) {
49767                 var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]);
49768                 return isTupleType(restType) ? getRestArrayTypeOfTupleType(restType) : restType;
49769             }
49770             return undefined;
49771         }
49772         function getNonArrayRestType(signature) {
49773             var restType = getEffectiveRestType(signature);
49774             return restType && !isArrayType(restType) && !isTypeAny(restType) && (getReducedType(restType).flags & 131072) === 0 ? restType : undefined;
49775         }
49776         function getTypeOfFirstParameterOfSignature(signature) {
49777             return getTypeOfFirstParameterOfSignatureWithFallback(signature, neverType);
49778         }
49779         function getTypeOfFirstParameterOfSignatureWithFallback(signature, fallbackType) {
49780             return signature.parameters.length > 0 ? getTypeAtPosition(signature, 0) : fallbackType;
49781         }
49782         function inferFromAnnotatedParameters(signature, context, inferenceContext) {
49783             var len = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
49784             for (var i = 0; i < len; i++) {
49785                 var declaration = signature.parameters[i].valueDeclaration;
49786                 if (declaration.type) {
49787                     var typeNode = ts.getEffectiveTypeAnnotationNode(declaration);
49788                     if (typeNode) {
49789                         inferTypes(inferenceContext.inferences, getTypeFromTypeNode(typeNode), getTypeAtPosition(context, i));
49790                     }
49791                 }
49792             }
49793             var restType = getEffectiveRestType(context);
49794             if (restType && restType.flags & 262144) {
49795                 var instantiatedContext = instantiateSignature(context, inferenceContext.nonFixingMapper);
49796                 assignContextualParameterTypes(signature, instantiatedContext);
49797                 var restPos = getParameterCount(context) - 1;
49798                 inferTypes(inferenceContext.inferences, getRestTypeAtPosition(signature, restPos), restType);
49799             }
49800         }
49801         function assignContextualParameterTypes(signature, context) {
49802             signature.typeParameters = context.typeParameters;
49803             if (context.thisParameter) {
49804                 var parameter = signature.thisParameter;
49805                 if (!parameter || parameter.valueDeclaration && !parameter.valueDeclaration.type) {
49806                     if (!parameter) {
49807                         signature.thisParameter = createSymbolWithType(context.thisParameter, undefined);
49808                     }
49809                     assignParameterType(signature.thisParameter, getTypeOfSymbol(context.thisParameter));
49810                 }
49811             }
49812             var len = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
49813             for (var i = 0; i < len; i++) {
49814                 var parameter = signature.parameters[i];
49815                 if (!ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) {
49816                     var contextualParameterType = tryGetTypeAtPosition(context, i);
49817                     assignParameterType(parameter, contextualParameterType);
49818                 }
49819             }
49820             if (signatureHasRestParameter(signature)) {
49821                 var parameter = ts.last(signature.parameters);
49822                 if (ts.isTransientSymbol(parameter) || !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) {
49823                     var contextualParameterType = getRestTypeAtPosition(context, len);
49824                     assignParameterType(parameter, contextualParameterType);
49825                 }
49826             }
49827         }
49828         function assignNonContextualParameterTypes(signature) {
49829             if (signature.thisParameter) {
49830                 assignParameterType(signature.thisParameter);
49831             }
49832             for (var _i = 0, _a = signature.parameters; _i < _a.length; _i++) {
49833                 var parameter = _a[_i];
49834                 assignParameterType(parameter);
49835             }
49836         }
49837         function assignParameterType(parameter, type) {
49838             var links = getSymbolLinks(parameter);
49839             if (!links.type) {
49840                 var declaration = parameter.valueDeclaration;
49841                 links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, true);
49842                 if (declaration.name.kind !== 75) {
49843                     if (links.type === unknownType) {
49844                         links.type = getTypeFromBindingPattern(declaration.name);
49845                     }
49846                     assignBindingElementTypes(declaration.name);
49847                 }
49848             }
49849         }
49850         function assignBindingElementTypes(pattern) {
49851             for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
49852                 var element = _a[_i];
49853                 if (!ts.isOmittedExpression(element)) {
49854                     if (element.name.kind === 75) {
49855                         getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element);
49856                     }
49857                     else {
49858                         assignBindingElementTypes(element.name);
49859                     }
49860                 }
49861             }
49862         }
49863         function createPromiseType(promisedType) {
49864             var globalPromiseType = getGlobalPromiseType(true);
49865             if (globalPromiseType !== emptyGenericType) {
49866                 promisedType = getAwaitedType(promisedType) || unknownType;
49867                 return createTypeReference(globalPromiseType, [promisedType]);
49868             }
49869             return unknownType;
49870         }
49871         function createPromiseLikeType(promisedType) {
49872             var globalPromiseLikeType = getGlobalPromiseLikeType(true);
49873             if (globalPromiseLikeType !== emptyGenericType) {
49874                 promisedType = getAwaitedType(promisedType) || unknownType;
49875                 return createTypeReference(globalPromiseLikeType, [promisedType]);
49876             }
49877             return unknownType;
49878         }
49879         function createPromiseReturnType(func, promisedType) {
49880             var promiseType = createPromiseType(promisedType);
49881             if (promiseType === unknownType) {
49882                 error(func, ts.isImportCall(func) ?
49883                     ts.Diagnostics.A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option :
49884                     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);
49885                 return errorType;
49886             }
49887             else if (!getGlobalPromiseConstructorSymbol(true)) {
49888                 error(func, ts.isImportCall(func) ?
49889                     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 :
49890                     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);
49891             }
49892             return promiseType;
49893         }
49894         function getReturnTypeFromBody(func, checkMode) {
49895             if (!func.body) {
49896                 return errorType;
49897             }
49898             var functionFlags = ts.getFunctionFlags(func);
49899             var isAsync = (functionFlags & 2) !== 0;
49900             var isGenerator = (functionFlags & 1) !== 0;
49901             var returnType;
49902             var yieldType;
49903             var nextType;
49904             var fallbackReturnType = voidType;
49905             if (func.body.kind !== 223) {
49906                 returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8);
49907                 if (isAsync) {
49908                     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);
49909                 }
49910             }
49911             else if (isGenerator) {
49912                 var returnTypes = checkAndAggregateReturnExpressionTypes(func, checkMode);
49913                 if (!returnTypes) {
49914                     fallbackReturnType = neverType;
49915                 }
49916                 else if (returnTypes.length > 0) {
49917                     returnType = getUnionType(returnTypes, 2);
49918                 }
49919                 var _a = checkAndAggregateYieldOperandTypes(func, checkMode), yieldTypes = _a.yieldTypes, nextTypes = _a.nextTypes;
49920                 yieldType = ts.some(yieldTypes) ? getUnionType(yieldTypes, 2) : undefined;
49921                 nextType = ts.some(nextTypes) ? getIntersectionType(nextTypes) : undefined;
49922             }
49923             else {
49924                 var types = checkAndAggregateReturnExpressionTypes(func, checkMode);
49925                 if (!types) {
49926                     return functionFlags & 2
49927                         ? createPromiseReturnType(func, neverType)
49928                         : neverType;
49929                 }
49930                 if (types.length === 0) {
49931                     return functionFlags & 2
49932                         ? createPromiseReturnType(func, voidType)
49933                         : voidType;
49934                 }
49935                 returnType = getUnionType(types, 2);
49936             }
49937             if (returnType || yieldType || nextType) {
49938                 if (yieldType)
49939                     reportErrorsFromWidening(func, yieldType, 3);
49940                 if (returnType)
49941                     reportErrorsFromWidening(func, returnType, 1);
49942                 if (nextType)
49943                     reportErrorsFromWidening(func, nextType, 2);
49944                 if (returnType && isUnitType(returnType) ||
49945                     yieldType && isUnitType(yieldType) ||
49946                     nextType && isUnitType(nextType)) {
49947                     var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func);
49948                     var contextualType = !contextualSignature ? undefined :
49949                         contextualSignature === getSignatureFromDeclaration(func) ? isGenerator ? undefined : returnType :
49950                             instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func);
49951                     if (isGenerator) {
49952                         yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0, isAsync);
49953                         returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1, isAsync);
49954                         nextType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(nextType, contextualType, 2, isAsync);
49955                     }
49956                     else {
49957                         returnType = getWidenedLiteralLikeTypeForContextualReturnTypeIfNeeded(returnType, contextualType, isAsync);
49958                     }
49959                 }
49960                 if (yieldType)
49961                     yieldType = getWidenedType(yieldType);
49962                 if (returnType)
49963                     returnType = getWidenedType(returnType);
49964                 if (nextType)
49965                     nextType = getWidenedType(nextType);
49966             }
49967             if (isGenerator) {
49968                 return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2, func) || unknownType, isAsync);
49969             }
49970             else {
49971                 return isAsync
49972                     ? createPromiseType(returnType || fallbackReturnType)
49973                     : returnType || fallbackReturnType;
49974             }
49975         }
49976         function createGeneratorReturnType(yieldType, returnType, nextType, isAsyncGenerator) {
49977             var resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver;
49978             var globalGeneratorType = resolver.getGlobalGeneratorType(false);
49979             yieldType = resolver.resolveIterationType(yieldType, undefined) || unknownType;
49980             returnType = resolver.resolveIterationType(returnType, undefined) || unknownType;
49981             nextType = resolver.resolveIterationType(nextType, undefined) || unknownType;
49982             if (globalGeneratorType === emptyGenericType) {
49983                 var globalType = resolver.getGlobalIterableIteratorType(false);
49984                 var iterationTypes = globalType !== emptyGenericType ? getIterationTypesOfGlobalIterableType(globalType, resolver) : undefined;
49985                 var iterableIteratorReturnType = iterationTypes ? iterationTypes.returnType : anyType;
49986                 var iterableIteratorNextType = iterationTypes ? iterationTypes.nextType : undefinedType;
49987                 if (isTypeAssignableTo(returnType, iterableIteratorReturnType) &&
49988                     isTypeAssignableTo(iterableIteratorNextType, nextType)) {
49989                     if (globalType !== emptyGenericType) {
49990                         return createTypeFromGenericGlobalType(globalType, [yieldType]);
49991                     }
49992                     resolver.getGlobalIterableIteratorType(true);
49993                     return emptyObjectType;
49994                 }
49995                 resolver.getGlobalGeneratorType(true);
49996                 return emptyObjectType;
49997             }
49998             return createTypeFromGenericGlobalType(globalGeneratorType, [yieldType, returnType, nextType]);
49999         }
50000         function checkAndAggregateYieldOperandTypes(func, checkMode) {
50001             var yieldTypes = [];
50002             var nextTypes = [];
50003             var isAsync = (ts.getFunctionFlags(func) & 2) !== 0;
50004             ts.forEachYieldExpression(func.body, function (yieldExpression) {
50005                 var yieldExpressionType = yieldExpression.expression ? checkExpression(yieldExpression.expression, checkMode) : undefinedWideningType;
50006                 ts.pushIfUnique(yieldTypes, getYieldedTypeOfYieldExpression(yieldExpression, yieldExpressionType, anyType, isAsync));
50007                 var nextType;
50008                 if (yieldExpression.asteriskToken) {
50009                     var iterationTypes = getIterationTypesOfIterable(yieldExpressionType, isAsync ? 19 : 17, yieldExpression.expression);
50010                     nextType = iterationTypes && iterationTypes.nextType;
50011                 }
50012                 else {
50013                     nextType = getContextualType(yieldExpression);
50014                 }
50015                 if (nextType)
50016                     ts.pushIfUnique(nextTypes, nextType);
50017             });
50018             return { yieldTypes: yieldTypes, nextTypes: nextTypes };
50019         }
50020         function getYieldedTypeOfYieldExpression(node, expressionType, sentType, isAsync) {
50021             var errorNode = node.expression || node;
50022             var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(isAsync ? 19 : 17, expressionType, sentType, errorNode) : expressionType;
50023             return !isAsync ? yieldedType : getAwaitedType(yieldedType, errorNode, node.asteriskToken
50024                 ? 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
50025                 : ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
50026         }
50027         function getFactsFromTypeofSwitch(start, end, witnesses, hasDefault) {
50028             var facts = 0;
50029             if (hasDefault) {
50030                 for (var i = end; i < witnesses.length; i++) {
50031                     facts |= typeofNEFacts.get(witnesses[i]) || 32768;
50032                 }
50033                 for (var i = start; i < end; i++) {
50034                     facts &= ~(typeofNEFacts.get(witnesses[i]) || 0);
50035                 }
50036                 for (var i = 0; i < start; i++) {
50037                     facts |= typeofNEFacts.get(witnesses[i]) || 32768;
50038                 }
50039             }
50040             else {
50041                 for (var i = start; i < end; i++) {
50042                     facts |= typeofEQFacts.get(witnesses[i]) || 128;
50043                 }
50044                 for (var i = 0; i < start; i++) {
50045                     facts &= ~(typeofEQFacts.get(witnesses[i]) || 0);
50046                 }
50047             }
50048             return facts;
50049         }
50050         function isExhaustiveSwitchStatement(node) {
50051             var links = getNodeLinks(node);
50052             return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node));
50053         }
50054         function computeExhaustiveSwitchStatement(node) {
50055             if (node.expression.kind === 204) {
50056                 var operandType = getTypeOfExpression(node.expression.expression);
50057                 var witnesses = getSwitchClauseTypeOfWitnesses(node, false);
50058                 var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, true);
50059                 var type_3 = getBaseConstraintOfType(operandType) || operandType;
50060                 return !!(filterType(type_3, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072);
50061             }
50062             var type = getTypeOfExpression(node.expression);
50063             if (!isLiteralType(type)) {
50064                 return false;
50065             }
50066             var switchTypes = getSwitchClauseTypes(node);
50067             if (!switchTypes.length || ts.some(switchTypes, isNeitherUnitTypeNorNever)) {
50068                 return false;
50069             }
50070             return eachTypeContainedIn(mapType(type, getRegularTypeOfLiteralType), switchTypes);
50071         }
50072         function functionHasImplicitReturn(func) {
50073             return func.endFlowNode && isReachableFlowNode(func.endFlowNode);
50074         }
50075         function checkAndAggregateReturnExpressionTypes(func, checkMode) {
50076             var functionFlags = ts.getFunctionFlags(func);
50077             var aggregatedTypes = [];
50078             var hasReturnWithNoExpression = functionHasImplicitReturn(func);
50079             var hasReturnOfTypeNever = false;
50080             ts.forEachReturnStatement(func.body, function (returnStatement) {
50081                 var expr = returnStatement.expression;
50082                 if (expr) {
50083                     var type = checkExpressionCached(expr, checkMode && checkMode & ~8);
50084                     if (functionFlags & 2) {
50085                         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);
50086                     }
50087                     if (type.flags & 131072) {
50088                         hasReturnOfTypeNever = true;
50089                     }
50090                     ts.pushIfUnique(aggregatedTypes, type);
50091                 }
50092                 else {
50093                     hasReturnWithNoExpression = true;
50094                 }
50095             });
50096             if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || mayReturnNever(func))) {
50097                 return undefined;
50098             }
50099             if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression &&
50100                 !(isJSConstructor(func) && aggregatedTypes.some(function (t) { return t.symbol === func.symbol; }))) {
50101                 ts.pushIfUnique(aggregatedTypes, undefinedType);
50102             }
50103             return aggregatedTypes;
50104         }
50105         function mayReturnNever(func) {
50106             switch (func.kind) {
50107                 case 201:
50108                 case 202:
50109                     return true;
50110                 case 161:
50111                     return func.parent.kind === 193;
50112                 default:
50113                     return false;
50114             }
50115         }
50116         function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func, returnType) {
50117             if (!produceDiagnostics) {
50118                 return;
50119             }
50120             var functionFlags = ts.getFunctionFlags(func);
50121             var type = returnType && unwrapReturnType(returnType, functionFlags);
50122             if (type && maybeTypeOfKind(type, 1 | 16384)) {
50123                 return;
50124             }
50125             if (func.kind === 160 || ts.nodeIsMissing(func.body) || func.body.kind !== 223 || !functionHasImplicitReturn(func)) {
50126                 return;
50127             }
50128             var hasExplicitReturn = func.flags & 512;
50129             if (type && type.flags & 131072) {
50130                 error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point);
50131             }
50132             else if (type && !hasExplicitReturn) {
50133                 error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
50134             }
50135             else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) {
50136                 error(ts.getEffectiveReturnTypeNode(func) || func, ts.Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);
50137             }
50138             else if (compilerOptions.noImplicitReturns) {
50139                 if (!type) {
50140                     if (!hasExplicitReturn) {
50141                         return;
50142                     }
50143                     var inferredReturnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func));
50144                     if (isUnwrappedReturnTypeVoidOrAny(func, inferredReturnType)) {
50145                         return;
50146                     }
50147                 }
50148                 error(ts.getEffectiveReturnTypeNode(func) || func, ts.Diagnostics.Not_all_code_paths_return_a_value);
50149             }
50150         }
50151         function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) {
50152             ts.Debug.assert(node.kind !== 161 || ts.isObjectLiteralMethod(node));
50153             checkNodeDeferred(node);
50154             if (checkMode && checkMode & 4 && isContextSensitive(node)) {
50155                 if (!ts.getEffectiveReturnTypeNode(node) && !hasContextSensitiveParameters(node)) {
50156                     var contextualSignature = getContextualSignature(node);
50157                     if (contextualSignature && couldContainTypeVariables(getReturnTypeOfSignature(contextualSignature))) {
50158                         var links = getNodeLinks(node);
50159                         if (links.contextFreeType) {
50160                             return links.contextFreeType;
50161                         }
50162                         var returnType = getReturnTypeFromBody(node, checkMode);
50163                         var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, undefined, 0, 0);
50164                         var returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], ts.emptyArray, undefined, undefined);
50165                         returnOnlyType.objectFlags |= 2097152;
50166                         return links.contextFreeType = returnOnlyType;
50167                     }
50168                 }
50169                 return anyFunctionType;
50170             }
50171             var hasGrammarError = checkGrammarFunctionLikeDeclaration(node);
50172             if (!hasGrammarError && node.kind === 201) {
50173                 checkGrammarForGenerator(node);
50174             }
50175             contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode);
50176             return getTypeOfSymbol(getSymbolOfNode(node));
50177         }
50178         function contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode) {
50179             var links = getNodeLinks(node);
50180             if (!(links.flags & 1024)) {
50181                 var contextualSignature = getContextualSignature(node);
50182                 if (!(links.flags & 1024)) {
50183                     links.flags |= 1024;
50184                     var signature = ts.firstOrUndefined(getSignaturesOfType(getTypeOfSymbol(getSymbolOfNode(node)), 0));
50185                     if (!signature) {
50186                         return;
50187                     }
50188                     if (isContextSensitive(node)) {
50189                         if (contextualSignature) {
50190                             var inferenceContext = getInferenceContext(node);
50191                             if (checkMode && checkMode & 2) {
50192                                 inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext);
50193                             }
50194                             var instantiatedContextualSignature = inferenceContext ?
50195                                 instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature;
50196                             assignContextualParameterTypes(signature, instantiatedContextualSignature);
50197                         }
50198                         else {
50199                             assignNonContextualParameterTypes(signature);
50200                         }
50201                     }
50202                     if (contextualSignature && !getReturnTypeFromAnnotation(node) && !signature.resolvedReturnType) {
50203                         var returnType = getReturnTypeFromBody(node, checkMode);
50204                         if (!signature.resolvedReturnType) {
50205                             signature.resolvedReturnType = returnType;
50206                         }
50207                     }
50208                     checkSignatureDeclaration(node);
50209                 }
50210             }
50211         }
50212         function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) {
50213             ts.Debug.assert(node.kind !== 161 || ts.isObjectLiteralMethod(node));
50214             var functionFlags = ts.getFunctionFlags(node);
50215             var returnType = getReturnTypeFromAnnotation(node);
50216             checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType);
50217             if (node.body) {
50218                 if (!ts.getEffectiveReturnTypeNode(node)) {
50219                     getReturnTypeOfSignature(getSignatureFromDeclaration(node));
50220                 }
50221                 if (node.body.kind === 223) {
50222                     checkSourceElement(node.body);
50223                 }
50224                 else {
50225                     var exprType = checkExpression(node.body);
50226                     var returnOrPromisedType = returnType && unwrapReturnType(returnType, functionFlags);
50227                     if (returnOrPromisedType) {
50228                         if ((functionFlags & 3) === 2) {
50229                             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);
50230                             checkTypeAssignableToAndOptionallyElaborate(awaitedType, returnOrPromisedType, node.body, node.body);
50231                         }
50232                         else {
50233                             checkTypeAssignableToAndOptionallyElaborate(exprType, returnOrPromisedType, node.body, node.body);
50234                         }
50235                     }
50236                 }
50237             }
50238         }
50239         function checkArithmeticOperandType(operand, type, diagnostic, isAwaitValid) {
50240             if (isAwaitValid === void 0) { isAwaitValid = false; }
50241             if (!isTypeAssignableTo(type, numberOrBigIntType)) {
50242                 var awaitedType = isAwaitValid && getAwaitedTypeOfPromise(type);
50243                 errorAndMaybeSuggestAwait(operand, !!awaitedType && isTypeAssignableTo(awaitedType, numberOrBigIntType), diagnostic);
50244                 return false;
50245             }
50246             return true;
50247         }
50248         function isReadonlyAssignmentDeclaration(d) {
50249             if (!ts.isCallExpression(d)) {
50250                 return false;
50251             }
50252             if (!ts.isBindableObjectDefinePropertyCall(d)) {
50253                 return false;
50254             }
50255             var objectLitType = checkExpressionCached(d.arguments[2]);
50256             var valueType = getTypeOfPropertyOfType(objectLitType, "value");
50257             if (valueType) {
50258                 var writableProp = getPropertyOfType(objectLitType, "writable");
50259                 var writableType = writableProp && getTypeOfSymbol(writableProp);
50260                 if (!writableType || writableType === falseType || writableType === regularFalseType) {
50261                     return true;
50262                 }
50263                 if (writableProp && writableProp.valueDeclaration && ts.isPropertyAssignment(writableProp.valueDeclaration)) {
50264                     var initializer = writableProp.valueDeclaration.initializer;
50265                     var rawOriginalType = checkExpression(initializer);
50266                     if (rawOriginalType === falseType || rawOriginalType === regularFalseType) {
50267                         return true;
50268                     }
50269                 }
50270                 return false;
50271             }
50272             var setProp = getPropertyOfType(objectLitType, "set");
50273             return !setProp;
50274         }
50275         function isReadonlySymbol(symbol) {
50276             return !!(ts.getCheckFlags(symbol) & 8 ||
50277                 symbol.flags & 4 && ts.getDeclarationModifierFlagsFromSymbol(symbol) & 64 ||
50278                 symbol.flags & 3 && getDeclarationNodeFlagsFromSymbol(symbol) & 2 ||
50279                 symbol.flags & 98304 && !(symbol.flags & 65536) ||
50280                 symbol.flags & 8 ||
50281                 ts.some(symbol.declarations, isReadonlyAssignmentDeclaration));
50282         }
50283         function isAssignmentToReadonlyEntity(expr, symbol, assignmentKind) {
50284             var _a, _b;
50285             if (assignmentKind === 0) {
50286                 return false;
50287             }
50288             if (isReadonlySymbol(symbol)) {
50289                 if (symbol.flags & 4 &&
50290                     ts.isAccessExpression(expr) &&
50291                     expr.expression.kind === 104) {
50292                     var ctor = ts.getContainingFunction(expr);
50293                     if (!(ctor && ctor.kind === 162)) {
50294                         return true;
50295                     }
50296                     if (symbol.valueDeclaration) {
50297                         var isAssignmentDeclaration_1 = ts.isBinaryExpression(symbol.valueDeclaration);
50298                         var isLocalPropertyDeclaration = ctor.parent === symbol.valueDeclaration.parent;
50299                         var isLocalParameterProperty = ctor === symbol.valueDeclaration.parent;
50300                         var isLocalThisPropertyAssignment = isAssignmentDeclaration_1 && ((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.valueDeclaration) === ctor.parent;
50301                         var isLocalThisPropertyAssignmentConstructorFunction = isAssignmentDeclaration_1 && ((_b = symbol.parent) === null || _b === void 0 ? void 0 : _b.valueDeclaration) === ctor;
50302                         var isWriteableSymbol = isLocalPropertyDeclaration
50303                             || isLocalParameterProperty
50304                             || isLocalThisPropertyAssignment
50305                             || isLocalThisPropertyAssignmentConstructorFunction;
50306                         return !isWriteableSymbol;
50307                     }
50308                 }
50309                 return true;
50310             }
50311             if (ts.isAccessExpression(expr)) {
50312                 var node = ts.skipParentheses(expr.expression);
50313                 if (node.kind === 75) {
50314                     var symbol_2 = getNodeLinks(node).resolvedSymbol;
50315                     if (symbol_2.flags & 2097152) {
50316                         var declaration = getDeclarationOfAliasSymbol(symbol_2);
50317                         return !!declaration && declaration.kind === 256;
50318                     }
50319                 }
50320             }
50321             return false;
50322         }
50323         function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) {
50324             var node = ts.skipOuterExpressions(expr, 6 | 1);
50325             if (node.kind !== 75 && !ts.isAccessExpression(node)) {
50326                 error(expr, invalidReferenceMessage);
50327                 return false;
50328             }
50329             if (node.flags & 32) {
50330                 error(expr, invalidOptionalChainMessage);
50331                 return false;
50332             }
50333             return true;
50334         }
50335         function checkDeleteExpression(node) {
50336             checkExpression(node.expression);
50337             var expr = ts.skipParentheses(node.expression);
50338             if (!ts.isAccessExpression(expr)) {
50339                 error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference);
50340                 return booleanType;
50341             }
50342             if (expr.kind === 194 && ts.isPrivateIdentifier(expr.name)) {
50343                 error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_private_identifier);
50344             }
50345             var links = getNodeLinks(expr);
50346             var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol);
50347             if (symbol && isReadonlySymbol(symbol)) {
50348                 error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property);
50349             }
50350             return booleanType;
50351         }
50352         function checkTypeOfExpression(node) {
50353             checkExpression(node.expression);
50354             return typeofType;
50355         }
50356         function checkVoidExpression(node) {
50357             checkExpression(node.expression);
50358             return undefinedWideningType;
50359         }
50360         function isTopLevelAwait(node) {
50361             var container = ts.getThisContainer(node, true);
50362             return ts.isSourceFile(container);
50363         }
50364         function checkAwaitExpression(node) {
50365             if (produceDiagnostics) {
50366                 if (!(node.flags & 32768)) {
50367                     if (isTopLevelAwait(node)) {
50368                         var sourceFile = ts.getSourceFileOfNode(node);
50369                         if (!hasParseDiagnostics(sourceFile)) {
50370                             var span = void 0;
50371                             if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
50372                                 if (!span)
50373                                     span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
50374                                 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);
50375                                 diagnostics.add(diagnostic);
50376                             }
50377                             if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) || languageVersion < 4) {
50378                                 span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
50379                                 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);
50380                                 diagnostics.add(diagnostic);
50381                             }
50382                         }
50383                     }
50384                     else {
50385                         var sourceFile = ts.getSourceFileOfNode(node);
50386                         if (!hasParseDiagnostics(sourceFile)) {
50387                             var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
50388                             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);
50389                             var func = ts.getContainingFunction(node);
50390                             if (func && func.kind !== 162 && (ts.getFunctionFlags(func) & 2) === 0) {
50391                                 var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async);
50392                                 ts.addRelatedInfo(diagnostic, relatedInfo);
50393                             }
50394                             diagnostics.add(diagnostic);
50395                         }
50396                     }
50397                 }
50398                 if (isInParameterInitializerBeforeContainingFunction(node)) {
50399                     error(node, ts.Diagnostics.await_expressions_cannot_be_used_in_a_parameter_initializer);
50400                 }
50401             }
50402             var operandType = checkExpression(node.expression);
50403             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);
50404             if (awaitedType === operandType && awaitedType !== errorType && !(operandType.flags & 3)) {
50405                 addErrorOrSuggestion(false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression));
50406             }
50407             return awaitedType;
50408         }
50409         function checkPrefixUnaryExpression(node) {
50410             var operandType = checkExpression(node.operand);
50411             if (operandType === silentNeverType) {
50412                 return silentNeverType;
50413             }
50414             switch (node.operand.kind) {
50415                 case 8:
50416                     switch (node.operator) {
50417                         case 40:
50418                             return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text));
50419                         case 39:
50420                             return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text));
50421                     }
50422                     break;
50423                 case 9:
50424                     if (node.operator === 40) {
50425                         return getFreshTypeOfLiteralType(getLiteralType({
50426                             negative: true,
50427                             base10Value: ts.parsePseudoBigInt(node.operand.text)
50428                         }));
50429                     }
50430             }
50431             switch (node.operator) {
50432                 case 39:
50433                 case 40:
50434                 case 54:
50435                     checkNonNullType(operandType, node.operand);
50436                     if (maybeTypeOfKind(operandType, 12288)) {
50437                         error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator));
50438                     }
50439                     if (node.operator === 39) {
50440                         if (maybeTypeOfKind(operandType, 2112)) {
50441                             error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType)));
50442                         }
50443                         return numberType;
50444                     }
50445                     return getUnaryResultType(operandType);
50446                 case 53:
50447                     checkTruthinessExpression(node.operand);
50448                     var facts = getTypeFacts(operandType) & (4194304 | 8388608);
50449                     return facts === 4194304 ? falseType :
50450                         facts === 8388608 ? trueType :
50451                             booleanType;
50452                 case 45:
50453                 case 46:
50454                     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);
50455                     if (ok) {
50456                         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);
50457                     }
50458                     return getUnaryResultType(operandType);
50459             }
50460             return errorType;
50461         }
50462         function checkPostfixUnaryExpression(node) {
50463             var operandType = checkExpression(node.operand);
50464             if (operandType === silentNeverType) {
50465                 return silentNeverType;
50466             }
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         function getUnaryResultType(operandType) {
50474             if (maybeTypeOfKind(operandType, 2112)) {
50475                 return isTypeAssignableToKind(operandType, 3) || maybeTypeOfKind(operandType, 296)
50476                     ? numberOrBigIntType
50477                     : bigintType;
50478             }
50479             return numberType;
50480         }
50481         function maybeTypeOfKind(type, kind) {
50482             if (type.flags & kind) {
50483                 return true;
50484             }
50485             if (type.flags & 3145728) {
50486                 var types = type.types;
50487                 for (var _i = 0, types_19 = types; _i < types_19.length; _i++) {
50488                     var t = types_19[_i];
50489                     if (maybeTypeOfKind(t, kind)) {
50490                         return true;
50491                     }
50492                 }
50493             }
50494             return false;
50495         }
50496         function isTypeAssignableToKind(source, kind, strict) {
50497             if (source.flags & kind) {
50498                 return true;
50499             }
50500             if (strict && source.flags & (3 | 16384 | 32768 | 65536)) {
50501                 return false;
50502             }
50503             return !!(kind & 296) && isTypeAssignableTo(source, numberType) ||
50504                 !!(kind & 2112) && isTypeAssignableTo(source, bigintType) ||
50505                 !!(kind & 132) && isTypeAssignableTo(source, stringType) ||
50506                 !!(kind & 528) && isTypeAssignableTo(source, booleanType) ||
50507                 !!(kind & 16384) && isTypeAssignableTo(source, voidType) ||
50508                 !!(kind & 131072) && isTypeAssignableTo(source, neverType) ||
50509                 !!(kind & 65536) && isTypeAssignableTo(source, nullType) ||
50510                 !!(kind & 32768) && isTypeAssignableTo(source, undefinedType) ||
50511                 !!(kind & 4096) && isTypeAssignableTo(source, esSymbolType) ||
50512                 !!(kind & 67108864) && isTypeAssignableTo(source, nonPrimitiveType);
50513         }
50514         function allTypesAssignableToKind(source, kind, strict) {
50515             return source.flags & 1048576 ?
50516                 ts.every(source.types, function (subType) { return allTypesAssignableToKind(subType, kind, strict); }) :
50517                 isTypeAssignableToKind(source, kind, strict);
50518         }
50519         function isConstEnumObjectType(type) {
50520             return !!(ts.getObjectFlags(type) & 16) && !!type.symbol && isConstEnumSymbol(type.symbol);
50521         }
50522         function isConstEnumSymbol(symbol) {
50523             return (symbol.flags & 128) !== 0;
50524         }
50525         function checkInstanceOfExpression(left, right, leftType, rightType) {
50526             if (leftType === silentNeverType || rightType === silentNeverType) {
50527                 return silentNeverType;
50528             }
50529             if (!isTypeAny(leftType) &&
50530                 allTypesAssignableToKind(leftType, 131068)) {
50531                 error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
50532             }
50533             if (!(isTypeAny(rightType) || typeHasCallOrConstructSignatures(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) {
50534                 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);
50535             }
50536             return booleanType;
50537         }
50538         function checkInExpression(left, right, leftType, rightType) {
50539             if (leftType === silentNeverType || rightType === silentNeverType) {
50540                 return silentNeverType;
50541             }
50542             leftType = checkNonNullType(leftType, left);
50543             rightType = checkNonNullType(rightType, right);
50544             if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 296 | 12288))) {
50545                 error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol);
50546             }
50547             if (!allTypesAssignableToKind(rightType, 67108864 | 58982400)) {
50548                 error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
50549             }
50550             return booleanType;
50551         }
50552         function checkObjectLiteralAssignment(node, sourceType, rightIsThis) {
50553             var properties = node.properties;
50554             if (strictNullChecks && properties.length === 0) {
50555                 return checkNonNullType(sourceType, node);
50556             }
50557             for (var i = 0; i < properties.length; i++) {
50558                 checkObjectLiteralDestructuringPropertyAssignment(node, sourceType, i, properties, rightIsThis);
50559             }
50560             return sourceType;
50561         }
50562         function checkObjectLiteralDestructuringPropertyAssignment(node, objectLiteralType, propertyIndex, allProperties, rightIsThis) {
50563             if (rightIsThis === void 0) { rightIsThis = false; }
50564             var properties = node.properties;
50565             var property = properties[propertyIndex];
50566             if (property.kind === 281 || property.kind === 282) {
50567                 var name = property.name;
50568                 var exprType = getLiteralTypeFromPropertyName(name);
50569                 if (isTypeUsableAsPropertyName(exprType)) {
50570                     var text = getPropertyNameFromType(exprType);
50571                     var prop = getPropertyOfType(objectLiteralType, text);
50572                     if (prop) {
50573                         markPropertyAsReferenced(prop, property, rightIsThis);
50574                         checkPropertyAccessibility(property, false, objectLiteralType, prop);
50575                     }
50576                 }
50577                 var elementType = getIndexedAccessType(objectLiteralType, exprType, name);
50578                 var type = getFlowTypeOfDestructuring(property, elementType);
50579                 return checkDestructuringAssignment(property.kind === 282 ? property : property.initializer, type);
50580             }
50581             else if (property.kind === 283) {
50582                 if (propertyIndex < properties.length - 1) {
50583                     error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern);
50584                 }
50585                 else {
50586                     if (languageVersion < 99) {
50587                         checkExternalEmitHelpers(property, 4);
50588                     }
50589                     var nonRestNames = [];
50590                     if (allProperties) {
50591                         for (var _i = 0, allProperties_1 = allProperties; _i < allProperties_1.length; _i++) {
50592                             var otherProperty = allProperties_1[_i];
50593                             if (!ts.isSpreadAssignment(otherProperty)) {
50594                                 nonRestNames.push(otherProperty.name);
50595                             }
50596                         }
50597                     }
50598                     var type = getRestType(objectLiteralType, nonRestNames, objectLiteralType.symbol);
50599                     checkGrammarForDisallowedTrailingComma(allProperties, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
50600                     return checkDestructuringAssignment(property.expression, type);
50601                 }
50602             }
50603             else {
50604                 error(property, ts.Diagnostics.Property_assignment_expected);
50605             }
50606         }
50607         function checkArrayLiteralAssignment(node, sourceType, checkMode) {
50608             var elements = node.elements;
50609             if (languageVersion < 2 && compilerOptions.downlevelIteration) {
50610                 checkExternalEmitHelpers(node, 512);
50611             }
50612             var elementType = checkIteratedTypeOrElementType(65, sourceType, undefinedType, node) || errorType;
50613             for (var i = 0; i < elements.length; i++) {
50614                 checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, elementType, checkMode);
50615             }
50616             return sourceType;
50617         }
50618         function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) {
50619             var elements = node.elements;
50620             var element = elements[elementIndex];
50621             if (element.kind !== 215) {
50622                 if (element.kind !== 213) {
50623                     var indexType = getLiteralType(elementIndex);
50624                     if (isArrayLikeType(sourceType)) {
50625                         var accessFlags = hasDefaultValue(element) ? 8 : 0;
50626                         var elementType_2 = getIndexedAccessTypeOrUndefined(sourceType, indexType, createSyntheticExpression(element, indexType), accessFlags) || errorType;
50627                         var assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType_2, 524288) : elementType_2;
50628                         var type = getFlowTypeOfDestructuring(element, assignedType);
50629                         return checkDestructuringAssignment(element, type, checkMode);
50630                     }
50631                     return checkDestructuringAssignment(element, elementType, checkMode);
50632                 }
50633                 if (elementIndex < elements.length - 1) {
50634                     error(element, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern);
50635                 }
50636                 else {
50637                     var restExpression = element.expression;
50638                     if (restExpression.kind === 209 && restExpression.operatorToken.kind === 62) {
50639                         error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer);
50640                     }
50641                     else {
50642                         checkGrammarForDisallowedTrailingComma(node.elements, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
50643                         var type = everyType(sourceType, isTupleType) ?
50644                             mapType(sourceType, function (t) { return sliceTupleType(t, elementIndex); }) :
50645                             createArrayType(elementType);
50646                         return checkDestructuringAssignment(restExpression, type, checkMode);
50647                     }
50648                 }
50649             }
50650             return undefined;
50651         }
50652         function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) {
50653             var target;
50654             if (exprOrAssignment.kind === 282) {
50655                 var prop = exprOrAssignment;
50656                 if (prop.objectAssignmentInitializer) {
50657                     if (strictNullChecks &&
50658                         !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 32768)) {
50659                         sourceType = getTypeWithFacts(sourceType, 524288);
50660                     }
50661                     checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode);
50662                 }
50663                 target = exprOrAssignment.name;
50664             }
50665             else {
50666                 target = exprOrAssignment;
50667             }
50668             if (target.kind === 209 && target.operatorToken.kind === 62) {
50669                 checkBinaryExpression(target, checkMode);
50670                 target = target.left;
50671             }
50672             if (target.kind === 193) {
50673                 return checkObjectLiteralAssignment(target, sourceType, rightIsThis);
50674             }
50675             if (target.kind === 192) {
50676                 return checkArrayLiteralAssignment(target, sourceType, checkMode);
50677             }
50678             return checkReferenceAssignment(target, sourceType, checkMode);
50679         }
50680         function checkReferenceAssignment(target, sourceType, checkMode) {
50681             var targetType = checkExpression(target, checkMode);
50682             var error = target.parent.kind === 283 ?
50683                 ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access :
50684                 ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access;
50685             var optionalError = target.parent.kind === 283 ?
50686                 ts.Diagnostics.The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access :
50687                 ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access;
50688             if (checkReferenceExpression(target, error, optionalError)) {
50689                 checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target);
50690             }
50691             if (ts.isPrivateIdentifierPropertyAccessExpression(target)) {
50692                 checkExternalEmitHelpers(target.parent, 524288);
50693             }
50694             return sourceType;
50695         }
50696         function isSideEffectFree(node) {
50697             node = ts.skipParentheses(node);
50698             switch (node.kind) {
50699                 case 75:
50700                 case 10:
50701                 case 13:
50702                 case 198:
50703                 case 211:
50704                 case 14:
50705                 case 8:
50706                 case 9:
50707                 case 106:
50708                 case 91:
50709                 case 100:
50710                 case 146:
50711                 case 201:
50712                 case 214:
50713                 case 202:
50714                 case 192:
50715                 case 193:
50716                 case 204:
50717                 case 218:
50718                 case 267:
50719                 case 266:
50720                     return true;
50721                 case 210:
50722                     return isSideEffectFree(node.whenTrue) &&
50723                         isSideEffectFree(node.whenFalse);
50724                 case 209:
50725                     if (ts.isAssignmentOperator(node.operatorToken.kind)) {
50726                         return false;
50727                     }
50728                     return isSideEffectFree(node.left) &&
50729                         isSideEffectFree(node.right);
50730                 case 207:
50731                 case 208:
50732                     switch (node.operator) {
50733                         case 53:
50734                         case 39:
50735                         case 40:
50736                         case 54:
50737                             return true;
50738                     }
50739                     return false;
50740                 case 205:
50741                 case 199:
50742                 case 217:
50743                 default:
50744                     return false;
50745             }
50746         }
50747         function isTypeEqualityComparableTo(source, target) {
50748             return (target.flags & 98304) !== 0 || isTypeComparableTo(source, target);
50749         }
50750         function checkBinaryExpression(node, checkMode) {
50751             var workStacks = {
50752                 expr: [node],
50753                 state: [0],
50754                 leftType: [undefined]
50755             };
50756             var stackIndex = 0;
50757             var lastResult;
50758             while (stackIndex >= 0) {
50759                 node = workStacks.expr[stackIndex];
50760                 switch (workStacks.state[stackIndex]) {
50761                     case 0: {
50762                         if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) {
50763                             finishInvocation(checkExpression(node.right, checkMode));
50764                             break;
50765                         }
50766                         checkGrammarNullishCoalesceWithLogicalExpression(node);
50767                         var operator = node.operatorToken.kind;
50768                         if (operator === 62 && (node.left.kind === 193 || node.left.kind === 192)) {
50769                             finishInvocation(checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 104));
50770                             break;
50771                         }
50772                         advanceState(1);
50773                         maybeCheckExpression(node.left);
50774                         break;
50775                     }
50776                     case 1: {
50777                         var leftType = lastResult;
50778                         workStacks.leftType[stackIndex] = leftType;
50779                         var operator = node.operatorToken.kind;
50780                         if (operator === 55 || operator === 56 || operator === 60) {
50781                             checkTruthinessOfType(leftType, node.left);
50782                         }
50783                         advanceState(2);
50784                         maybeCheckExpression(node.right);
50785                         break;
50786                     }
50787                     case 2: {
50788                         var leftType = workStacks.leftType[stackIndex];
50789                         var rightType = lastResult;
50790                         finishInvocation(checkBinaryLikeExpressionWorker(node.left, node.operatorToken, node.right, leftType, rightType, node));
50791                         break;
50792                     }
50793                     default: return ts.Debug.fail("Invalid state " + workStacks.state[stackIndex] + " for checkBinaryExpression");
50794                 }
50795             }
50796             return lastResult;
50797             function finishInvocation(result) {
50798                 lastResult = result;
50799                 stackIndex--;
50800             }
50801             function advanceState(nextState) {
50802                 workStacks.state[stackIndex] = nextState;
50803             }
50804             function maybeCheckExpression(node) {
50805                 if (ts.isBinaryExpression(node)) {
50806                     stackIndex++;
50807                     workStacks.expr[stackIndex] = node;
50808                     workStacks.state[stackIndex] = 0;
50809                     workStacks.leftType[stackIndex] = undefined;
50810                 }
50811                 else {
50812                     lastResult = checkExpression(node, checkMode);
50813                 }
50814             }
50815         }
50816         function checkGrammarNullishCoalesceWithLogicalExpression(node) {
50817             var left = node.left, operatorToken = node.operatorToken, right = node.right;
50818             if (operatorToken.kind === 60) {
50819                 if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 || left.operatorToken.kind === 55)) {
50820                     grammarErrorOnNode(left, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(left.operatorToken.kind), ts.tokenToString(operatorToken.kind));
50821                 }
50822                 if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 || right.operatorToken.kind === 55)) {
50823                     grammarErrorOnNode(right, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(right.operatorToken.kind), ts.tokenToString(operatorToken.kind));
50824                 }
50825             }
50826         }
50827         function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) {
50828             var operator = operatorToken.kind;
50829             if (operator === 62 && (left.kind === 193 || left.kind === 192)) {
50830                 return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 104);
50831             }
50832             var leftType;
50833             if (operator === 55 || operator === 56 || operator === 60) {
50834                 leftType = checkTruthinessExpression(left, checkMode);
50835             }
50836             else {
50837                 leftType = checkExpression(left, checkMode);
50838             }
50839             var rightType = checkExpression(right, checkMode);
50840             return checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, errorNode);
50841         }
50842         function checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, errorNode) {
50843             var operator = operatorToken.kind;
50844             switch (operator) {
50845                 case 41:
50846                 case 42:
50847                 case 65:
50848                 case 66:
50849                 case 43:
50850                 case 67:
50851                 case 44:
50852                 case 68:
50853                 case 40:
50854                 case 64:
50855                 case 47:
50856                 case 69:
50857                 case 48:
50858                 case 70:
50859                 case 49:
50860                 case 71:
50861                 case 51:
50862                 case 73:
50863                 case 52:
50864                 case 74:
50865                 case 50:
50866                 case 72:
50867                     if (leftType === silentNeverType || rightType === silentNeverType) {
50868                         return silentNeverType;
50869                     }
50870                     leftType = checkNonNullType(leftType, left);
50871                     rightType = checkNonNullType(rightType, right);
50872                     var suggestedOperator = void 0;
50873                     if ((leftType.flags & 528) &&
50874                         (rightType.flags & 528) &&
50875                         (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) {
50876                         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));
50877                         return numberType;
50878                     }
50879                     else {
50880                         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);
50881                         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);
50882                         var resultType_1;
50883                         if ((isTypeAssignableToKind(leftType, 3) && isTypeAssignableToKind(rightType, 3)) ||
50884                             !(maybeTypeOfKind(leftType, 2112) || maybeTypeOfKind(rightType, 2112))) {
50885                             resultType_1 = numberType;
50886                         }
50887                         else if (bothAreBigIntLike(leftType, rightType)) {
50888                             switch (operator) {
50889                                 case 49:
50890                                 case 71:
50891                                     reportOperatorError();
50892                             }
50893                             resultType_1 = bigintType;
50894                         }
50895                         else {
50896                             reportOperatorError(bothAreBigIntLike);
50897                             resultType_1 = errorType;
50898                         }
50899                         if (leftOk && rightOk) {
50900                             checkAssignmentOperator(resultType_1);
50901                         }
50902                         return resultType_1;
50903                     }
50904                 case 39:
50905                 case 63:
50906                     if (leftType === silentNeverType || rightType === silentNeverType) {
50907                         return silentNeverType;
50908                     }
50909                     if (!isTypeAssignableToKind(leftType, 132) && !isTypeAssignableToKind(rightType, 132)) {
50910                         leftType = checkNonNullType(leftType, left);
50911                         rightType = checkNonNullType(rightType, right);
50912                     }
50913                     var resultType = void 0;
50914                     if (isTypeAssignableToKind(leftType, 296, true) && isTypeAssignableToKind(rightType, 296, true)) {
50915                         resultType = numberType;
50916                     }
50917                     else if (isTypeAssignableToKind(leftType, 2112, true) && isTypeAssignableToKind(rightType, 2112, true)) {
50918                         resultType = bigintType;
50919                     }
50920                     else if (isTypeAssignableToKind(leftType, 132, true) || isTypeAssignableToKind(rightType, 132, true)) {
50921                         resultType = stringType;
50922                     }
50923                     else if (isTypeAny(leftType) || isTypeAny(rightType)) {
50924                         resultType = leftType === errorType || rightType === errorType ? errorType : anyType;
50925                     }
50926                     if (resultType && !checkForDisallowedESSymbolOperand(operator)) {
50927                         return resultType;
50928                     }
50929                     if (!resultType) {
50930                         var closeEnoughKind_1 = 296 | 2112 | 132 | 3;
50931                         reportOperatorError(function (left, right) {
50932                             return isTypeAssignableToKind(left, closeEnoughKind_1) &&
50933                                 isTypeAssignableToKind(right, closeEnoughKind_1);
50934                         });
50935                         return anyType;
50936                     }
50937                     if (operator === 63) {
50938                         checkAssignmentOperator(resultType);
50939                     }
50940                     return resultType;
50941                 case 29:
50942                 case 31:
50943                 case 32:
50944                 case 33:
50945                     if (checkForDisallowedESSymbolOperand(operator)) {
50946                         leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left));
50947                         rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right));
50948                         reportOperatorErrorUnless(function (left, right) {
50949                             return isTypeComparableTo(left, right) || isTypeComparableTo(right, left) || (isTypeAssignableTo(left, numberOrBigIntType) && isTypeAssignableTo(right, numberOrBigIntType));
50950                         });
50951                     }
50952                     return booleanType;
50953                 case 34:
50954                 case 35:
50955                 case 36:
50956                 case 37:
50957                     reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); });
50958                     return booleanType;
50959                 case 98:
50960                     return checkInstanceOfExpression(left, right, leftType, rightType);
50961                 case 97:
50962                     return checkInExpression(left, right, leftType, rightType);
50963                 case 55:
50964                     return getTypeFacts(leftType) & 4194304 ?
50965                         getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) :
50966                         leftType;
50967                 case 56:
50968                     return getTypeFacts(leftType) & 8388608 ?
50969                         getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2) :
50970                         leftType;
50971                 case 60:
50972                     return getTypeFacts(leftType) & 262144 ?
50973                         getUnionType([getNonNullableType(leftType), rightType], 2) :
50974                         leftType;
50975                 case 62:
50976                     var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0;
50977                     checkAssignmentDeclaration(declKind, rightType);
50978                     if (isAssignmentDeclaration(declKind)) {
50979                         if (!(rightType.flags & 524288) ||
50980                             declKind !== 2 &&
50981                                 declKind !== 6 &&
50982                                 !isEmptyObjectType(rightType) &&
50983                                 !isFunctionObjectType(rightType) &&
50984                                 !(ts.getObjectFlags(rightType) & 1)) {
50985                             checkAssignmentOperator(rightType);
50986                         }
50987                         return leftType;
50988                     }
50989                     else {
50990                         checkAssignmentOperator(rightType);
50991                         return getRegularTypeOfObjectLiteral(rightType);
50992                     }
50993                 case 27:
50994                     if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right)) {
50995                         error(left, ts.Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects);
50996                     }
50997                     return rightType;
50998                 default:
50999                     return ts.Debug.fail();
51000             }
51001             function bothAreBigIntLike(left, right) {
51002                 return isTypeAssignableToKind(left, 2112) && isTypeAssignableToKind(right, 2112);
51003             }
51004             function checkAssignmentDeclaration(kind, rightType) {
51005                 if (kind === 2) {
51006                     for (var _i = 0, _a = getPropertiesOfObjectType(rightType); _i < _a.length; _i++) {
51007                         var prop = _a[_i];
51008                         var propType = getTypeOfSymbol(prop);
51009                         if (propType.symbol && propType.symbol.flags & 32) {
51010                             var name = prop.escapedName;
51011                             var symbol = resolveName(prop.valueDeclaration, name, 788968, undefined, name, false);
51012                             if (symbol && symbol.declarations.some(ts.isJSDocTypedefTag)) {
51013                                 addDuplicateDeclarationErrorsForSymbols(symbol, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), prop);
51014                                 addDuplicateDeclarationErrorsForSymbols(prop, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), symbol);
51015                             }
51016                         }
51017                     }
51018                 }
51019             }
51020             function isEvalNode(node) {
51021                 return node.kind === 75 && node.escapedText === "eval";
51022             }
51023             function checkForDisallowedESSymbolOperand(operator) {
51024                 var offendingSymbolOperand = maybeTypeOfKind(leftType, 12288) ? left :
51025                     maybeTypeOfKind(rightType, 12288) ? right :
51026                         undefined;
51027                 if (offendingSymbolOperand) {
51028                     error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator));
51029                     return false;
51030                 }
51031                 return true;
51032             }
51033             function getSuggestedBooleanOperator(operator) {
51034                 switch (operator) {
51035                     case 51:
51036                     case 73:
51037                         return 56;
51038                     case 52:
51039                     case 74:
51040                         return 37;
51041                     case 50:
51042                     case 72:
51043                         return 55;
51044                     default:
51045                         return undefined;
51046                 }
51047             }
51048             function checkAssignmentOperator(valueType) {
51049                 if (produceDiagnostics && ts.isAssignmentOperator(operator)) {
51050                     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)
51051                         && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) {
51052                         checkTypeAssignableToAndOptionallyElaborate(valueType, leftType, left, right);
51053                     }
51054                 }
51055             }
51056             function isAssignmentDeclaration(kind) {
51057                 switch (kind) {
51058                     case 2:
51059                         return true;
51060                     case 1:
51061                     case 5:
51062                     case 6:
51063                     case 3:
51064                     case 4:
51065                         var symbol = getSymbolOfNode(left);
51066                         var init = ts.getAssignedExpandoInitializer(right);
51067                         return init && ts.isObjectLiteralExpression(init) &&
51068                             symbol && ts.hasEntries(symbol.exports);
51069                     default:
51070                         return false;
51071                 }
51072             }
51073             function reportOperatorErrorUnless(typesAreCompatible) {
51074                 if (!typesAreCompatible(leftType, rightType)) {
51075                     reportOperatorError(typesAreCompatible);
51076                     return true;
51077                 }
51078                 return false;
51079             }
51080             function reportOperatorError(isRelated) {
51081                 var _a;
51082                 var wouldWorkWithAwait = false;
51083                 var errNode = errorNode || operatorToken;
51084                 if (isRelated) {
51085                     var awaitedLeftType = getAwaitedType(leftType);
51086                     var awaitedRightType = getAwaitedType(rightType);
51087                     wouldWorkWithAwait = !(awaitedLeftType === leftType && awaitedRightType === rightType)
51088                         && !!(awaitedLeftType && awaitedRightType)
51089                         && isRelated(awaitedLeftType, awaitedRightType);
51090                 }
51091                 var effectiveLeft = leftType;
51092                 var effectiveRight = rightType;
51093                 if (!wouldWorkWithAwait && isRelated) {
51094                     _a = getBaseTypesIfUnrelated(leftType, rightType, isRelated), effectiveLeft = _a[0], effectiveRight = _a[1];
51095                 }
51096                 var _b = getTypeNamesForErrorDisplay(effectiveLeft, effectiveRight), leftStr = _b[0], rightStr = _b[1];
51097                 if (!tryGiveBetterPrimaryError(errNode, wouldWorkWithAwait, leftStr, rightStr)) {
51098                     errorAndMaybeSuggestAwait(errNode, wouldWorkWithAwait, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), leftStr, rightStr);
51099                 }
51100             }
51101             function tryGiveBetterPrimaryError(errNode, maybeMissingAwait, leftStr, rightStr) {
51102                 var typeName;
51103                 switch (operatorToken.kind) {
51104                     case 36:
51105                     case 34:
51106                         typeName = "false";
51107                         break;
51108                     case 37:
51109                     case 35:
51110                         typeName = "true";
51111                 }
51112                 if (typeName) {
51113                     return errorAndMaybeSuggestAwait(errNode, maybeMissingAwait, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, typeName, leftStr, rightStr);
51114                 }
51115                 return undefined;
51116             }
51117         }
51118         function getBaseTypesIfUnrelated(leftType, rightType, isRelated) {
51119             var effectiveLeft = leftType;
51120             var effectiveRight = rightType;
51121             var leftBase = getBaseTypeOfLiteralType(leftType);
51122             var rightBase = getBaseTypeOfLiteralType(rightType);
51123             if (!isRelated(leftBase, rightBase)) {
51124                 effectiveLeft = leftBase;
51125                 effectiveRight = rightBase;
51126             }
51127             return [effectiveLeft, effectiveRight];
51128         }
51129         function checkYieldExpression(node) {
51130             if (produceDiagnostics) {
51131                 if (!(node.flags & 8192)) {
51132                     grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body);
51133                 }
51134                 if (isInParameterInitializerBeforeContainingFunction(node)) {
51135                     error(node, ts.Diagnostics.yield_expressions_cannot_be_used_in_a_parameter_initializer);
51136                 }
51137             }
51138             var func = ts.getContainingFunction(node);
51139             if (!func)
51140                 return anyType;
51141             var functionFlags = ts.getFunctionFlags(func);
51142             if (!(functionFlags & 1)) {
51143                 return anyType;
51144             }
51145             var isAsync = (functionFlags & 2) !== 0;
51146             if (node.asteriskToken) {
51147                 if (isAsync && languageVersion < 99) {
51148                     checkExternalEmitHelpers(node, 53248);
51149                 }
51150                 if (!isAsync && languageVersion < 2 && compilerOptions.downlevelIteration) {
51151                     checkExternalEmitHelpers(node, 256);
51152                 }
51153             }
51154             var returnType = getReturnTypeFromAnnotation(func);
51155             var iterationTypes = returnType && getIterationTypesOfGeneratorFunctionReturnType(returnType, isAsync);
51156             var signatureYieldType = iterationTypes && iterationTypes.yieldType || anyType;
51157             var signatureNextType = iterationTypes && iterationTypes.nextType || anyType;
51158             var resolvedSignatureNextType = isAsync ? getAwaitedType(signatureNextType) || anyType : signatureNextType;
51159             var yieldExpressionType = node.expression ? checkExpression(node.expression) : undefinedWideningType;
51160             var yieldedType = getYieldedTypeOfYieldExpression(node, yieldExpressionType, resolvedSignatureNextType, isAsync);
51161             if (returnType && yieldedType) {
51162                 checkTypeAssignableToAndOptionallyElaborate(yieldedType, signatureYieldType, node.expression || node, node.expression);
51163             }
51164             if (node.asteriskToken) {
51165                 var use = isAsync ? 19 : 17;
51166                 return getIterationTypeOfIterable(use, 1, yieldExpressionType, node.expression)
51167                     || anyType;
51168             }
51169             else if (returnType) {
51170                 return getIterationTypeOfGeneratorFunctionReturnType(2, returnType, isAsync)
51171                     || anyType;
51172             }
51173             return getContextualIterationType(2, func) || anyType;
51174         }
51175         function checkConditionalExpression(node, checkMode) {
51176             var type = checkTruthinessExpression(node.condition);
51177             checkTestingKnownTruthyCallableType(node.condition, node.whenTrue, type);
51178             var type1 = checkExpression(node.whenTrue, checkMode);
51179             var type2 = checkExpression(node.whenFalse, checkMode);
51180             return getUnionType([type1, type2], 2);
51181         }
51182         function checkTemplateExpression(node) {
51183             ts.forEach(node.templateSpans, function (templateSpan) {
51184                 if (maybeTypeOfKind(checkExpression(templateSpan.expression), 12288)) {
51185                     error(templateSpan.expression, ts.Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String);
51186                 }
51187             });
51188             return stringType;
51189         }
51190         function getContextNode(node) {
51191             if (node.kind === 274 && !ts.isJsxSelfClosingElement(node.parent)) {
51192                 return node.parent.parent;
51193             }
51194             return node;
51195         }
51196         function checkExpressionWithContextualType(node, contextualType, inferenceContext, checkMode) {
51197             var context = getContextNode(node);
51198             var saveContextualType = context.contextualType;
51199             var saveInferenceContext = context.inferenceContext;
51200             try {
51201                 context.contextualType = contextualType;
51202                 context.inferenceContext = inferenceContext;
51203                 var type = checkExpression(node, checkMode | 1 | (inferenceContext ? 2 : 0));
51204                 var result = maybeTypeOfKind(type, 2944) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ?
51205                     getRegularTypeOfLiteralType(type) : type;
51206                 return result;
51207             }
51208             finally {
51209                 context.contextualType = saveContextualType;
51210                 context.inferenceContext = saveInferenceContext;
51211             }
51212         }
51213         function checkExpressionCached(node, checkMode) {
51214             var links = getNodeLinks(node);
51215             if (!links.resolvedType) {
51216                 if (checkMode && checkMode !== 0) {
51217                     return checkExpression(node, checkMode);
51218                 }
51219                 var saveFlowLoopStart = flowLoopStart;
51220                 var saveFlowTypeCache = flowTypeCache;
51221                 flowLoopStart = flowLoopCount;
51222                 flowTypeCache = undefined;
51223                 links.resolvedType = checkExpression(node, checkMode);
51224                 flowTypeCache = saveFlowTypeCache;
51225                 flowLoopStart = saveFlowLoopStart;
51226             }
51227             return links.resolvedType;
51228         }
51229         function isTypeAssertion(node) {
51230             node = ts.skipParentheses(node);
51231             return node.kind === 199 || node.kind === 217;
51232         }
51233         function checkDeclarationInitializer(declaration, contextualType) {
51234             var initializer = ts.getEffectiveInitializer(declaration);
51235             var type = getQuickTypeOfExpression(initializer) ||
51236                 (contextualType ? checkExpressionWithContextualType(initializer, contextualType, undefined, 0) : checkExpressionCached(initializer));
51237             return ts.isParameter(declaration) && declaration.name.kind === 190 &&
51238                 isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ?
51239                 padTupleType(type, declaration.name) : type;
51240         }
51241         function padTupleType(type, pattern) {
51242             var patternElements = pattern.elements;
51243             var arity = getTypeReferenceArity(type);
51244             var elementTypes = arity ? getTypeArguments(type).slice() : [];
51245             for (var i = arity; i < patternElements.length; i++) {
51246                 var e = patternElements[i];
51247                 if (i < patternElements.length - 1 || !(e.kind === 191 && e.dotDotDotToken)) {
51248                     elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, false, false) : anyType);
51249                     if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) {
51250                         reportImplicitAny(e, anyType);
51251                     }
51252                 }
51253             }
51254             return createTupleType(elementTypes, type.target.minLength, false, type.target.readonly);
51255         }
51256         function widenTypeInferredFromInitializer(declaration, type) {
51257             var widened = ts.getCombinedNodeFlags(declaration) & 2 || ts.isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type);
51258             if (ts.isInJSFile(declaration)) {
51259                 if (widened.flags & 98304) {
51260                     reportImplicitAny(declaration, anyType);
51261                     return anyType;
51262                 }
51263                 else if (isEmptyArrayLiteralType(widened)) {
51264                     reportImplicitAny(declaration, anyArrayType);
51265                     return anyArrayType;
51266                 }
51267             }
51268             return widened;
51269         }
51270         function isLiteralOfContextualType(candidateType, contextualType) {
51271             if (contextualType) {
51272                 if (contextualType.flags & 3145728) {
51273                     var types = contextualType.types;
51274                     return ts.some(types, function (t) { return isLiteralOfContextualType(candidateType, t); });
51275                 }
51276                 if (contextualType.flags & 58982400) {
51277                     var constraint = getBaseConstraintOfType(contextualType) || unknownType;
51278                     return maybeTypeOfKind(constraint, 4) && maybeTypeOfKind(candidateType, 128) ||
51279                         maybeTypeOfKind(constraint, 8) && maybeTypeOfKind(candidateType, 256) ||
51280                         maybeTypeOfKind(constraint, 64) && maybeTypeOfKind(candidateType, 2048) ||
51281                         maybeTypeOfKind(constraint, 4096) && maybeTypeOfKind(candidateType, 8192) ||
51282                         isLiteralOfContextualType(candidateType, constraint);
51283                 }
51284                 return !!(contextualType.flags & (128 | 4194304) && maybeTypeOfKind(candidateType, 128) ||
51285                     contextualType.flags & 256 && maybeTypeOfKind(candidateType, 256) ||
51286                     contextualType.flags & 2048 && maybeTypeOfKind(candidateType, 2048) ||
51287                     contextualType.flags & 512 && maybeTypeOfKind(candidateType, 512) ||
51288                     contextualType.flags & 8192 && maybeTypeOfKind(candidateType, 8192));
51289             }
51290             return false;
51291         }
51292         function isConstContext(node) {
51293             var parent = node.parent;
51294             return ts.isAssertionExpression(parent) && ts.isConstTypeReference(parent.type) ||
51295                 (ts.isParenthesizedExpression(parent) || ts.isArrayLiteralExpression(parent) || ts.isSpreadElement(parent)) && isConstContext(parent) ||
51296                 (ts.isPropertyAssignment(parent) || ts.isShorthandPropertyAssignment(parent)) && isConstContext(parent.parent);
51297         }
51298         function checkExpressionForMutableLocation(node, checkMode, contextualType, forceTuple) {
51299             var type = checkExpression(node, checkMode, forceTuple);
51300             return isConstContext(node) ? getRegularTypeOfLiteralType(type) :
51301                 isTypeAssertion(node) ? type :
51302                     getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node) : contextualType, node));
51303         }
51304         function checkPropertyAssignment(node, checkMode) {
51305             if (node.name.kind === 154) {
51306                 checkComputedPropertyName(node.name);
51307             }
51308             return checkExpressionForMutableLocation(node.initializer, checkMode);
51309         }
51310         function checkObjectLiteralMethod(node, checkMode) {
51311             checkGrammarMethod(node);
51312             if (node.name.kind === 154) {
51313                 checkComputedPropertyName(node.name);
51314             }
51315             var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode);
51316             return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode);
51317         }
51318         function instantiateTypeWithSingleGenericCallSignature(node, type, checkMode) {
51319             if (checkMode && checkMode & (2 | 8)) {
51320                 var callSignature = getSingleSignature(type, 0, true);
51321                 var constructSignature = getSingleSignature(type, 1, true);
51322                 var signature = callSignature || constructSignature;
51323                 if (signature && signature.typeParameters) {
51324                     var contextualType = getApparentTypeOfContextualType(node, 2);
51325                     if (contextualType) {
51326                         var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 : 1, false);
51327                         if (contextualSignature && !contextualSignature.typeParameters) {
51328                             if (checkMode & 8) {
51329                                 skippedGenericFunction(node, checkMode);
51330                                 return anyFunctionType;
51331                             }
51332                             var context = getInferenceContext(node);
51333                             var returnType = context.signature && getReturnTypeOfSignature(context.signature);
51334                             var returnSignature = returnType && getSingleCallOrConstructSignature(returnType);
51335                             if (returnSignature && !returnSignature.typeParameters && !ts.every(context.inferences, hasInferenceCandidates)) {
51336                                 var uniqueTypeParameters = getUniqueTypeParameters(context, signature.typeParameters);
51337                                 var instantiatedSignature = getSignatureInstantiationWithoutFillingInTypeArguments(signature, uniqueTypeParameters);
51338                                 var inferences_3 = ts.map(context.inferences, function (info) { return createInferenceInfo(info.typeParameter); });
51339                                 applyToParameterTypes(instantiatedSignature, contextualSignature, function (source, target) {
51340                                     inferTypes(inferences_3, source, target, 0, true);
51341                                 });
51342                                 if (ts.some(inferences_3, hasInferenceCandidates)) {
51343                                     applyToReturnTypes(instantiatedSignature, contextualSignature, function (source, target) {
51344                                         inferTypes(inferences_3, source, target);
51345                                     });
51346                                     if (!hasOverlappingInferences(context.inferences, inferences_3)) {
51347                                         mergeInferences(context.inferences, inferences_3);
51348                                         context.inferredTypeParameters = ts.concatenate(context.inferredTypeParameters, uniqueTypeParameters);
51349                                         return getOrCreateTypeFromSignature(instantiatedSignature);
51350                                     }
51351                                 }
51352                             }
51353                             return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, context));
51354                         }
51355                     }
51356                 }
51357             }
51358             return type;
51359         }
51360         function skippedGenericFunction(node, checkMode) {
51361             if (checkMode & 2) {
51362                 var context = getInferenceContext(node);
51363                 context.flags |= 4;
51364             }
51365         }
51366         function hasInferenceCandidates(info) {
51367             return !!(info.candidates || info.contraCandidates);
51368         }
51369         function hasOverlappingInferences(a, b) {
51370             for (var i = 0; i < a.length; i++) {
51371                 if (hasInferenceCandidates(a[i]) && hasInferenceCandidates(b[i])) {
51372                     return true;
51373                 }
51374             }
51375             return false;
51376         }
51377         function mergeInferences(target, source) {
51378             for (var i = 0; i < target.length; i++) {
51379                 if (!hasInferenceCandidates(target[i]) && hasInferenceCandidates(source[i])) {
51380                     target[i] = source[i];
51381                 }
51382             }
51383         }
51384         function getUniqueTypeParameters(context, typeParameters) {
51385             var result = [];
51386             var oldTypeParameters;
51387             var newTypeParameters;
51388             for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) {
51389                 var tp = typeParameters_2[_i];
51390                 var name = tp.symbol.escapedName;
51391                 if (hasTypeParameterByName(context.inferredTypeParameters, name) || hasTypeParameterByName(result, name)) {
51392                     var newName = getUniqueTypeParameterName(ts.concatenate(context.inferredTypeParameters, result), name);
51393                     var symbol = createSymbol(262144, newName);
51394                     var newTypeParameter = createTypeParameter(symbol);
51395                     newTypeParameter.target = tp;
51396                     oldTypeParameters = ts.append(oldTypeParameters, tp);
51397                     newTypeParameters = ts.append(newTypeParameters, newTypeParameter);
51398                     result.push(newTypeParameter);
51399                 }
51400                 else {
51401                     result.push(tp);
51402                 }
51403             }
51404             if (newTypeParameters) {
51405                 var mapper = createTypeMapper(oldTypeParameters, newTypeParameters);
51406                 for (var _a = 0, newTypeParameters_1 = newTypeParameters; _a < newTypeParameters_1.length; _a++) {
51407                     var tp = newTypeParameters_1[_a];
51408                     tp.mapper = mapper;
51409                 }
51410             }
51411             return result;
51412         }
51413         function hasTypeParameterByName(typeParameters, name) {
51414             return ts.some(typeParameters, function (tp) { return tp.symbol.escapedName === name; });
51415         }
51416         function getUniqueTypeParameterName(typeParameters, baseName) {
51417             var len = baseName.length;
51418             while (len > 1 && baseName.charCodeAt(len - 1) >= 48 && baseName.charCodeAt(len - 1) <= 57)
51419                 len--;
51420             var s = baseName.slice(0, len);
51421             for (var index = 1; true; index++) {
51422                 var augmentedName = (s + index);
51423                 if (!hasTypeParameterByName(typeParameters, augmentedName)) {
51424                     return augmentedName;
51425                 }
51426             }
51427         }
51428         function getReturnTypeOfSingleNonGenericCallSignature(funcType) {
51429             var signature = getSingleCallSignature(funcType);
51430             if (signature && !signature.typeParameters) {
51431                 return getReturnTypeOfSignature(signature);
51432             }
51433         }
51434         function getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) {
51435             var funcType = checkExpression(expr.expression);
51436             var nonOptionalType = getOptionalExpressionType(funcType, expr.expression);
51437             var returnType = getReturnTypeOfSingleNonGenericCallSignature(funcType);
51438             return returnType && propagateOptionalTypeMarker(returnType, expr, nonOptionalType !== funcType);
51439         }
51440         function getTypeOfExpression(node) {
51441             var quickType = getQuickTypeOfExpression(node);
51442             if (quickType) {
51443                 return quickType;
51444             }
51445             if (node.flags & 67108864 && flowTypeCache) {
51446                 var cachedType = flowTypeCache[getNodeId(node)];
51447                 if (cachedType) {
51448                     return cachedType;
51449                 }
51450             }
51451             var startInvocationCount = flowInvocationCount;
51452             var type = checkExpression(node);
51453             if (flowInvocationCount !== startInvocationCount) {
51454                 var cache = flowTypeCache || (flowTypeCache = []);
51455                 cache[getNodeId(node)] = type;
51456                 node.flags |= 67108864;
51457             }
51458             return type;
51459         }
51460         function getQuickTypeOfExpression(node) {
51461             var expr = ts.skipParentheses(node);
51462             if (ts.isCallExpression(expr) && expr.expression.kind !== 102 && !ts.isRequireCall(expr, true) && !isSymbolOrSymbolForCall(expr)) {
51463                 var type = ts.isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) :
51464                     getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression));
51465                 if (type) {
51466                     return type;
51467                 }
51468             }
51469             else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) {
51470                 return getTypeFromTypeNode(expr.type);
51471             }
51472             else if (node.kind === 8 || node.kind === 10 ||
51473                 node.kind === 106 || node.kind === 91) {
51474                 return checkExpression(node);
51475             }
51476             return undefined;
51477         }
51478         function getContextFreeTypeOfExpression(node) {
51479             var links = getNodeLinks(node);
51480             if (links.contextFreeType) {
51481                 return links.contextFreeType;
51482             }
51483             var saveContextualType = node.contextualType;
51484             node.contextualType = anyType;
51485             try {
51486                 var type = links.contextFreeType = checkExpression(node, 4);
51487                 return type;
51488             }
51489             finally {
51490                 node.contextualType = saveContextualType;
51491             }
51492         }
51493         function checkExpression(node, checkMode, forceTuple) {
51494             var saveCurrentNode = currentNode;
51495             currentNode = node;
51496             instantiationCount = 0;
51497             var uninstantiatedType = checkExpressionWorker(node, checkMode, forceTuple);
51498             var type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode);
51499             if (isConstEnumObjectType(type)) {
51500                 checkConstEnumAccess(node, type);
51501             }
51502             currentNode = saveCurrentNode;
51503             return type;
51504         }
51505         function checkConstEnumAccess(node, type) {
51506             var ok = (node.parent.kind === 194 && node.parent.expression === node) ||
51507                 (node.parent.kind === 195 && node.parent.expression === node) ||
51508                 ((node.kind === 75 || node.kind === 153) && isInRightSideOfImportOrExportAssignment(node) ||
51509                     (node.parent.kind === 172 && node.parent.exprName === node)) ||
51510                 (node.parent.kind === 263);
51511             if (!ok) {
51512                 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);
51513             }
51514             if (compilerOptions.isolatedModules) {
51515                 ts.Debug.assert(!!(type.symbol.flags & 128));
51516                 var constEnumDeclaration = type.symbol.valueDeclaration;
51517                 if (constEnumDeclaration.flags & 8388608) {
51518                     error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided);
51519                 }
51520             }
51521         }
51522         function checkParenthesizedExpression(node, checkMode) {
51523             var tag = ts.isInJSFile(node) ? ts.getJSDocTypeTag(node) : undefined;
51524             if (tag) {
51525                 return checkAssertionWorker(tag, tag.typeExpression.type, node.expression, checkMode);
51526             }
51527             return checkExpression(node.expression, checkMode);
51528         }
51529         function checkExpressionWorker(node, checkMode, forceTuple) {
51530             var kind = node.kind;
51531             if (cancellationToken) {
51532                 switch (kind) {
51533                     case 214:
51534                     case 201:
51535                     case 202:
51536                         cancellationToken.throwIfCancellationRequested();
51537                 }
51538             }
51539             switch (kind) {
51540                 case 75:
51541                     return checkIdentifier(node);
51542                 case 104:
51543                     return checkThisExpression(node);
51544                 case 102:
51545                     return checkSuperExpression(node);
51546                 case 100:
51547                     return nullWideningType;
51548                 case 14:
51549                 case 10:
51550                     return getFreshTypeOfLiteralType(getLiteralType(node.text));
51551                 case 8:
51552                     checkGrammarNumericLiteral(node);
51553                     return getFreshTypeOfLiteralType(getLiteralType(+node.text));
51554                 case 9:
51555                     checkGrammarBigIntLiteral(node);
51556                     return getFreshTypeOfLiteralType(getBigIntLiteralType(node));
51557                 case 106:
51558                     return trueType;
51559                 case 91:
51560                     return falseType;
51561                 case 211:
51562                     return checkTemplateExpression(node);
51563                 case 13:
51564                     return globalRegExpType;
51565                 case 192:
51566                     return checkArrayLiteral(node, checkMode, forceTuple);
51567                 case 193:
51568                     return checkObjectLiteral(node, checkMode);
51569                 case 194:
51570                     return checkPropertyAccessExpression(node);
51571                 case 153:
51572                     return checkQualifiedName(node);
51573                 case 195:
51574                     return checkIndexedAccess(node);
51575                 case 196:
51576                     if (node.expression.kind === 96) {
51577                         return checkImportCallExpression(node);
51578                     }
51579                 case 197:
51580                     return checkCallExpression(node, checkMode);
51581                 case 198:
51582                     return checkTaggedTemplateExpression(node);
51583                 case 200:
51584                     return checkParenthesizedExpression(node, checkMode);
51585                 case 214:
51586                     return checkClassExpression(node);
51587                 case 201:
51588                 case 202:
51589                     return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode);
51590                 case 204:
51591                     return checkTypeOfExpression(node);
51592                 case 199:
51593                 case 217:
51594                     return checkAssertion(node);
51595                 case 218:
51596                     return checkNonNullAssertion(node);
51597                 case 219:
51598                     return checkMetaProperty(node);
51599                 case 203:
51600                     return checkDeleteExpression(node);
51601                 case 205:
51602                     return checkVoidExpression(node);
51603                 case 206:
51604                     return checkAwaitExpression(node);
51605                 case 207:
51606                     return checkPrefixUnaryExpression(node);
51607                 case 208:
51608                     return checkPostfixUnaryExpression(node);
51609                 case 209:
51610                     return checkBinaryExpression(node, checkMode);
51611                 case 210:
51612                     return checkConditionalExpression(node, checkMode);
51613                 case 213:
51614                     return checkSpreadExpression(node, checkMode);
51615                 case 215:
51616                     return undefinedWideningType;
51617                 case 212:
51618                     return checkYieldExpression(node);
51619                 case 220:
51620                     return node.type;
51621                 case 276:
51622                     return checkJsxExpression(node, checkMode);
51623                 case 266:
51624                     return checkJsxElement(node, checkMode);
51625                 case 267:
51626                     return checkJsxSelfClosingElement(node, checkMode);
51627                 case 270:
51628                     return checkJsxFragment(node);
51629                 case 274:
51630                     return checkJsxAttributes(node, checkMode);
51631                 case 268:
51632                     ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement");
51633             }
51634             return errorType;
51635         }
51636         function checkTypeParameter(node) {
51637             if (node.expression) {
51638                 grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected);
51639             }
51640             checkSourceElement(node.constraint);
51641             checkSourceElement(node.default);
51642             var typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node));
51643             getBaseConstraintOfType(typeParameter);
51644             if (!hasNonCircularTypeParameterDefault(typeParameter)) {
51645                 error(node.default, ts.Diagnostics.Type_parameter_0_has_a_circular_default, typeToString(typeParameter));
51646             }
51647             var constraintType = getConstraintOfTypeParameter(typeParameter);
51648             var defaultType = getDefaultFromTypeParameter(typeParameter);
51649             if (constraintType && defaultType) {
51650                 checkTypeAssignableTo(defaultType, getTypeWithThisArgument(instantiateType(constraintType, makeUnaryTypeMapper(typeParameter, defaultType)), defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
51651             }
51652             if (produceDiagnostics) {
51653                 checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0);
51654             }
51655         }
51656         function checkParameter(node) {
51657             checkGrammarDecoratorsAndModifiers(node);
51658             checkVariableLikeDeclaration(node);
51659             var func = ts.getContainingFunction(node);
51660             if (ts.hasModifier(node, 92)) {
51661                 if (!(func.kind === 162 && ts.nodeIsPresent(func.body))) {
51662                     error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation);
51663                 }
51664                 if (func.kind === 162 && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") {
51665                     error(node.name, ts.Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name);
51666                 }
51667             }
51668             if (node.questionToken && ts.isBindingPattern(node.name) && func.body) {
51669                 error(node, ts.Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature);
51670             }
51671             if (node.name && ts.isIdentifier(node.name) && (node.name.escapedText === "this" || node.name.escapedText === "new")) {
51672                 if (func.parameters.indexOf(node) !== 0) {
51673                     error(node, ts.Diagnostics.A_0_parameter_must_be_the_first_parameter, node.name.escapedText);
51674                 }
51675                 if (func.kind === 162 || func.kind === 166 || func.kind === 171) {
51676                     error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter);
51677                 }
51678                 if (func.kind === 202) {
51679                     error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter);
51680                 }
51681                 if (func.kind === 163 || func.kind === 164) {
51682                     error(node, ts.Diagnostics.get_and_set_accessors_cannot_declare_this_parameters);
51683                 }
51684             }
51685             if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isTypeAssignableTo(getReducedType(getTypeOfSymbol(node.symbol)), anyReadonlyArrayType)) {
51686                 error(node, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type);
51687             }
51688         }
51689         function checkTypePredicate(node) {
51690             var parent = getTypePredicateParent(node);
51691             if (!parent) {
51692                 error(node, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods);
51693                 return;
51694             }
51695             var signature = getSignatureFromDeclaration(parent);
51696             var typePredicate = getTypePredicateOfSignature(signature);
51697             if (!typePredicate) {
51698                 return;
51699             }
51700             checkSourceElement(node.type);
51701             var parameterName = node.parameterName;
51702             if (typePredicate.kind === 0 || typePredicate.kind === 2) {
51703                 getTypeFromThisTypeNode(parameterName);
51704             }
51705             else {
51706                 if (typePredicate.parameterIndex >= 0) {
51707                     if (signatureHasRestParameter(signature) && typePredicate.parameterIndex === signature.parameters.length - 1) {
51708                         error(parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter);
51709                     }
51710                     else {
51711                         if (typePredicate.type) {
51712                             var leadingError = function () { return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); };
51713                             checkTypeAssignableTo(typePredicate.type, getTypeOfSymbol(signature.parameters[typePredicate.parameterIndex]), node.type, undefined, leadingError);
51714                         }
51715                     }
51716                 }
51717                 else if (parameterName) {
51718                     var hasReportedError = false;
51719                     for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) {
51720                         var name = _a[_i].name;
51721                         if (ts.isBindingPattern(name) &&
51722                             checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, parameterName, typePredicate.parameterName)) {
51723                             hasReportedError = true;
51724                             break;
51725                         }
51726                     }
51727                     if (!hasReportedError) {
51728                         error(node.parameterName, ts.Diagnostics.Cannot_find_parameter_0, typePredicate.parameterName);
51729                     }
51730                 }
51731             }
51732         }
51733         function getTypePredicateParent(node) {
51734             switch (node.parent.kind) {
51735                 case 202:
51736                 case 165:
51737                 case 244:
51738                 case 201:
51739                 case 170:
51740                 case 161:
51741                 case 160:
51742                     var parent = node.parent;
51743                     if (node === parent.type) {
51744                         return parent;
51745                     }
51746             }
51747         }
51748         function checkIfTypePredicateVariableIsDeclaredInBindingPattern(pattern, predicateVariableNode, predicateVariableName) {
51749             for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
51750                 var element = _a[_i];
51751                 if (ts.isOmittedExpression(element)) {
51752                     continue;
51753                 }
51754                 var name = element.name;
51755                 if (name.kind === 75 && name.escapedText === predicateVariableName) {
51756                     error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName);
51757                     return true;
51758                 }
51759                 else if (name.kind === 190 || name.kind === 189) {
51760                     if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) {
51761                         return true;
51762                     }
51763                 }
51764             }
51765         }
51766         function checkSignatureDeclaration(node) {
51767             if (node.kind === 167) {
51768                 checkGrammarIndexSignature(node);
51769             }
51770             else if (node.kind === 170 || node.kind === 244 || node.kind === 171 ||
51771                 node.kind === 165 || node.kind === 162 ||
51772                 node.kind === 166) {
51773                 checkGrammarFunctionLikeDeclaration(node);
51774             }
51775             var functionFlags = ts.getFunctionFlags(node);
51776             if (!(functionFlags & 4)) {
51777                 if ((functionFlags & 3) === 3 && languageVersion < 99) {
51778                     checkExternalEmitHelpers(node, 12288);
51779                 }
51780                 if ((functionFlags & 3) === 2 && languageVersion < 4) {
51781                     checkExternalEmitHelpers(node, 64);
51782                 }
51783                 if ((functionFlags & 3) !== 0 && languageVersion < 2) {
51784                     checkExternalEmitHelpers(node, 128);
51785                 }
51786             }
51787             checkTypeParameters(node.typeParameters);
51788             ts.forEach(node.parameters, checkParameter);
51789             if (node.type) {
51790                 checkSourceElement(node.type);
51791             }
51792             if (produceDiagnostics) {
51793                 checkCollisionWithArgumentsInGeneratedCode(node);
51794                 var returnTypeNode = ts.getEffectiveReturnTypeNode(node);
51795                 if (noImplicitAny && !returnTypeNode) {
51796                     switch (node.kind) {
51797                         case 166:
51798                             error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type);
51799                             break;
51800                         case 165:
51801                             error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type);
51802                             break;
51803                     }
51804                 }
51805                 if (returnTypeNode) {
51806                     var functionFlags_1 = ts.getFunctionFlags(node);
51807                     if ((functionFlags_1 & (4 | 1)) === 1) {
51808                         var returnType = getTypeFromTypeNode(returnTypeNode);
51809                         if (returnType === voidType) {
51810                             error(returnTypeNode, ts.Diagnostics.A_generator_cannot_have_a_void_type_annotation);
51811                         }
51812                         else {
51813                             var generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0, returnType, (functionFlags_1 & 2) !== 0) || anyType;
51814                             var generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1, returnType, (functionFlags_1 & 2) !== 0) || generatorYieldType;
51815                             var generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2, returnType, (functionFlags_1 & 2) !== 0) || unknownType;
51816                             var generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags_1 & 2));
51817                             checkTypeAssignableTo(generatorInstantiation, returnType, returnTypeNode);
51818                         }
51819                     }
51820                     else if ((functionFlags_1 & 3) === 2) {
51821                         checkAsyncFunctionReturnType(node, returnTypeNode);
51822                     }
51823                 }
51824                 if (node.kind !== 167 && node.kind !== 300) {
51825                     registerForUnusedIdentifiersCheck(node);
51826                 }
51827             }
51828         }
51829         function checkClassForDuplicateDeclarations(node) {
51830             var instanceNames = ts.createUnderscoreEscapedMap();
51831             var staticNames = ts.createUnderscoreEscapedMap();
51832             var privateIdentifiers = ts.createUnderscoreEscapedMap();
51833             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
51834                 var member = _a[_i];
51835                 if (member.kind === 162) {
51836                     for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) {
51837                         var param = _c[_b];
51838                         if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) {
51839                             addName(instanceNames, param.name, param.name.escapedText, 3);
51840                         }
51841                     }
51842                 }
51843                 else {
51844                     var isStatic = ts.hasModifier(member, 32);
51845                     var name = member.name;
51846                     if (!name) {
51847                         return;
51848                     }
51849                     var names = ts.isPrivateIdentifier(name) ? privateIdentifiers :
51850                         isStatic ? staticNames :
51851                             instanceNames;
51852                     var memberName = name && ts.getPropertyNameForPropertyNameNode(name);
51853                     if (memberName) {
51854                         switch (member.kind) {
51855                             case 163:
51856                                 addName(names, name, memberName, 1);
51857                                 break;
51858                             case 164:
51859                                 addName(names, name, memberName, 2);
51860                                 break;
51861                             case 159:
51862                                 addName(names, name, memberName, 3);
51863                                 break;
51864                             case 161:
51865                                 addName(names, name, memberName, 8);
51866                                 break;
51867                         }
51868                     }
51869                 }
51870             }
51871             function addName(names, location, name, meaning) {
51872                 var prev = names.get(name);
51873                 if (prev) {
51874                     if (prev & 8) {
51875                         if (meaning !== 8) {
51876                             error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location));
51877                         }
51878                     }
51879                     else if (prev & meaning) {
51880                         error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location));
51881                     }
51882                     else {
51883                         names.set(name, prev | meaning);
51884                     }
51885                 }
51886                 else {
51887                     names.set(name, meaning);
51888                 }
51889             }
51890         }
51891         function checkClassForStaticPropertyNameConflicts(node) {
51892             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
51893                 var member = _a[_i];
51894                 var memberNameNode = member.name;
51895                 var isStatic = ts.hasModifier(member, 32);
51896                 if (isStatic && memberNameNode) {
51897                     var memberName = ts.getPropertyNameForPropertyNameNode(memberNameNode);
51898                     switch (memberName) {
51899                         case "name":
51900                         case "length":
51901                         case "caller":
51902                         case "arguments":
51903                         case "prototype":
51904                             var message = ts.Diagnostics.Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1;
51905                             var className = getNameOfSymbolAsWritten(getSymbolOfNode(node));
51906                             error(memberNameNode, message, memberName, className);
51907                             break;
51908                     }
51909                 }
51910             }
51911         }
51912         function checkObjectTypeForDuplicateDeclarations(node) {
51913             var names = ts.createMap();
51914             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
51915                 var member = _a[_i];
51916                 if (member.kind === 158) {
51917                     var memberName = void 0;
51918                     var name = member.name;
51919                     switch (name.kind) {
51920                         case 10:
51921                         case 8:
51922                             memberName = name.text;
51923                             break;
51924                         case 75:
51925                             memberName = ts.idText(name);
51926                             break;
51927                         default:
51928                             continue;
51929                     }
51930                     if (names.get(memberName)) {
51931                         error(ts.getNameOfDeclaration(member.symbol.valueDeclaration), ts.Diagnostics.Duplicate_identifier_0, memberName);
51932                         error(member.name, ts.Diagnostics.Duplicate_identifier_0, memberName);
51933                     }
51934                     else {
51935                         names.set(memberName, true);
51936                     }
51937                 }
51938             }
51939         }
51940         function checkTypeForDuplicateIndexSignatures(node) {
51941             if (node.kind === 246) {
51942                 var nodeSymbol = getSymbolOfNode(node);
51943                 if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) {
51944                     return;
51945                 }
51946             }
51947             var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
51948             if (indexSymbol) {
51949                 var seenNumericIndexer = false;
51950                 var seenStringIndexer = false;
51951                 for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
51952                     var decl = _a[_i];
51953                     var declaration = decl;
51954                     if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
51955                         switch (declaration.parameters[0].type.kind) {
51956                             case 143:
51957                                 if (!seenStringIndexer) {
51958                                     seenStringIndexer = true;
51959                                 }
51960                                 else {
51961                                     error(declaration, ts.Diagnostics.Duplicate_string_index_signature);
51962                                 }
51963                                 break;
51964                             case 140:
51965                                 if (!seenNumericIndexer) {
51966                                     seenNumericIndexer = true;
51967                                 }
51968                                 else {
51969                                     error(declaration, ts.Diagnostics.Duplicate_number_index_signature);
51970                                 }
51971                                 break;
51972                         }
51973                     }
51974                 }
51975             }
51976         }
51977         function checkPropertyDeclaration(node) {
51978             if (!checkGrammarDecoratorsAndModifiers(node) && !checkGrammarProperty(node))
51979                 checkGrammarComputedPropertyName(node.name);
51980             checkVariableLikeDeclaration(node);
51981             if (ts.isPrivateIdentifier(node.name) && languageVersion < 99) {
51982                 for (var lexicalScope = ts.getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = ts.getEnclosingBlockScopeContainer(lexicalScope)) {
51983                     getNodeLinks(lexicalScope).flags |= 67108864;
51984                 }
51985             }
51986         }
51987         function checkPropertySignature(node) {
51988             if (ts.isPrivateIdentifier(node.name)) {
51989                 error(node, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
51990             }
51991             return checkPropertyDeclaration(node);
51992         }
51993         function checkMethodDeclaration(node) {
51994             if (!checkGrammarMethod(node))
51995                 checkGrammarComputedPropertyName(node.name);
51996             if (ts.isPrivateIdentifier(node.name)) {
51997                 error(node, ts.Diagnostics.A_method_cannot_be_named_with_a_private_identifier);
51998             }
51999             checkFunctionOrMethodDeclaration(node);
52000             if (ts.hasModifier(node, 128) && node.kind === 161 && node.body) {
52001                 error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name));
52002             }
52003         }
52004         function checkConstructorDeclaration(node) {
52005             checkSignatureDeclaration(node);
52006             if (!checkGrammarConstructorTypeParameters(node))
52007                 checkGrammarConstructorTypeAnnotation(node);
52008             checkSourceElement(node.body);
52009             var symbol = getSymbolOfNode(node);
52010             var firstDeclaration = ts.getDeclarationOfKind(symbol, node.kind);
52011             if (node === firstDeclaration) {
52012                 checkFunctionOrConstructorSymbol(symbol);
52013             }
52014             if (ts.nodeIsMissing(node.body)) {
52015                 return;
52016             }
52017             if (!produceDiagnostics) {
52018                 return;
52019             }
52020             function isInstancePropertyWithInitializerOrPrivateIdentifierProperty(n) {
52021                 if (ts.isPrivateIdentifierPropertyDeclaration(n)) {
52022                     return true;
52023                 }
52024                 return n.kind === 159 &&
52025                     !ts.hasModifier(n, 32) &&
52026                     !!n.initializer;
52027             }
52028             var containingClassDecl = node.parent;
52029             if (ts.getClassExtendsHeritageElement(containingClassDecl)) {
52030                 captureLexicalThis(node.parent, containingClassDecl);
52031                 var classExtendsNull = classDeclarationExtendsNull(containingClassDecl);
52032                 var superCall = getSuperCallInConstructor(node);
52033                 if (superCall) {
52034                     if (classExtendsNull) {
52035                         error(superCall, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null);
52036                     }
52037                     var superCallShouldBeFirst = (compilerOptions.target !== 99 || !compilerOptions.useDefineForClassFields) &&
52038                         (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) ||
52039                             ts.some(node.parameters, function (p) { return ts.hasModifier(p, 92); }));
52040                     if (superCallShouldBeFirst) {
52041                         var statements = node.body.statements;
52042                         var superCallStatement = void 0;
52043                         for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) {
52044                             var statement = statements_3[_i];
52045                             if (statement.kind === 226 && ts.isSuperCall(statement.expression)) {
52046                                 superCallStatement = statement;
52047                                 break;
52048                             }
52049                             if (!ts.isPrologueDirective(statement)) {
52050                                 break;
52051                             }
52052                         }
52053                         if (!superCallStatement) {
52054                             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);
52055                         }
52056                     }
52057                 }
52058                 else if (!classExtendsNull) {
52059                     error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call);
52060                 }
52061             }
52062         }
52063         function checkAccessorDeclaration(node) {
52064             if (produceDiagnostics) {
52065                 if (!checkGrammarFunctionLikeDeclaration(node) && !checkGrammarAccessor(node))
52066                     checkGrammarComputedPropertyName(node.name);
52067                 checkDecorators(node);
52068                 checkSignatureDeclaration(node);
52069                 if (node.kind === 163) {
52070                     if (!(node.flags & 8388608) && ts.nodeIsPresent(node.body) && (node.flags & 256)) {
52071                         if (!(node.flags & 512)) {
52072                             error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value);
52073                         }
52074                     }
52075                 }
52076                 if (node.name.kind === 154) {
52077                     checkComputedPropertyName(node.name);
52078                 }
52079                 if (ts.isPrivateIdentifier(node.name)) {
52080                     error(node.name, ts.Diagnostics.An_accessor_cannot_be_named_with_a_private_identifier);
52081                 }
52082                 if (!hasNonBindableDynamicName(node)) {
52083                     var otherKind = node.kind === 163 ? 164 : 163;
52084                     var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind);
52085                     if (otherAccessor) {
52086                         var nodeFlags = ts.getModifierFlags(node);
52087                         var otherFlags = ts.getModifierFlags(otherAccessor);
52088                         if ((nodeFlags & 28) !== (otherFlags & 28)) {
52089                             error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility);
52090                         }
52091                         if ((nodeFlags & 128) !== (otherFlags & 128)) {
52092                             error(node.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract);
52093                         }
52094                         checkAccessorDeclarationTypesIdentical(node, otherAccessor, getAnnotatedAccessorType, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type);
52095                         checkAccessorDeclarationTypesIdentical(node, otherAccessor, getThisTypeOfDeclaration, ts.Diagnostics.get_and_set_accessor_must_have_the_same_this_type);
52096                     }
52097                 }
52098                 var returnType = getTypeOfAccessors(getSymbolOfNode(node));
52099                 if (node.kind === 163) {
52100                     checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType);
52101                 }
52102             }
52103             checkSourceElement(node.body);
52104         }
52105         function checkAccessorDeclarationTypesIdentical(first, second, getAnnotatedType, message) {
52106             var firstType = getAnnotatedType(first);
52107             var secondType = getAnnotatedType(second);
52108             if (firstType && secondType && !isTypeIdenticalTo(firstType, secondType)) {
52109                 error(first, message);
52110             }
52111         }
52112         function checkMissingDeclaration(node) {
52113             checkDecorators(node);
52114         }
52115         function getEffectiveTypeArguments(node, typeParameters) {
52116             return fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(node));
52117         }
52118         function checkTypeArgumentConstraints(node, typeParameters) {
52119             var typeArguments;
52120             var mapper;
52121             var result = true;
52122             for (var i = 0; i < typeParameters.length; i++) {
52123                 var constraint = getConstraintOfTypeParameter(typeParameters[i]);
52124                 if (constraint) {
52125                     if (!typeArguments) {
52126                         typeArguments = getEffectiveTypeArguments(node, typeParameters);
52127                         mapper = createTypeMapper(typeParameters, typeArguments);
52128                     }
52129                     result = result && checkTypeAssignableTo(typeArguments[i], instantiateType(constraint, mapper), node.typeArguments[i], ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
52130                 }
52131             }
52132             return result;
52133         }
52134         function getTypeParametersForTypeReference(node) {
52135             var type = getTypeFromTypeReference(node);
52136             if (type !== errorType) {
52137                 var symbol = getNodeLinks(node).resolvedSymbol;
52138                 if (symbol) {
52139                     return symbol.flags & 524288 && getSymbolLinks(symbol).typeParameters ||
52140                         (ts.getObjectFlags(type) & 4 ? type.target.localTypeParameters : undefined);
52141                 }
52142             }
52143             return undefined;
52144         }
52145         function checkTypeReferenceNode(node) {
52146             checkGrammarTypeArguments(node, node.typeArguments);
52147             if (node.kind === 169 && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) {
52148                 grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments);
52149             }
52150             ts.forEach(node.typeArguments, checkSourceElement);
52151             var type = getTypeFromTypeReference(node);
52152             if (type !== errorType) {
52153                 if (node.typeArguments && produceDiagnostics) {
52154                     var typeParameters = getTypeParametersForTypeReference(node);
52155                     if (typeParameters) {
52156                         checkTypeArgumentConstraints(node, typeParameters);
52157                     }
52158                 }
52159                 if (type.flags & 32 && getNodeLinks(node).resolvedSymbol.flags & 8) {
52160                     error(node, ts.Diagnostics.Enum_type_0_has_members_with_initializers_that_are_not_literals, typeToString(type));
52161                 }
52162             }
52163         }
52164         function getTypeArgumentConstraint(node) {
52165             var typeReferenceNode = ts.tryCast(node.parent, ts.isTypeReferenceType);
52166             if (!typeReferenceNode)
52167                 return undefined;
52168             var typeParameters = getTypeParametersForTypeReference(typeReferenceNode);
52169             var constraint = getConstraintOfTypeParameter(typeParameters[typeReferenceNode.typeArguments.indexOf(node)]);
52170             return constraint && instantiateType(constraint, createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReferenceNode, typeParameters)));
52171         }
52172         function checkTypeQuery(node) {
52173             getTypeFromTypeQueryNode(node);
52174         }
52175         function checkTypeLiteral(node) {
52176             ts.forEach(node.members, checkSourceElement);
52177             if (produceDiagnostics) {
52178                 var type = getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node);
52179                 checkIndexConstraints(type);
52180                 checkTypeForDuplicateIndexSignatures(node);
52181                 checkObjectTypeForDuplicateDeclarations(node);
52182             }
52183         }
52184         function checkArrayType(node) {
52185             checkSourceElement(node.elementType);
52186         }
52187         function checkTupleType(node) {
52188             var elementTypes = node.elementTypes;
52189             var seenOptionalElement = false;
52190             for (var i = 0; i < elementTypes.length; i++) {
52191                 var e = elementTypes[i];
52192                 if (e.kind === 177) {
52193                     if (i !== elementTypes.length - 1) {
52194                         grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type);
52195                         break;
52196                     }
52197                     if (!isArrayType(getTypeFromTypeNode(e.type))) {
52198                         error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type);
52199                     }
52200                 }
52201                 else if (e.kind === 176) {
52202                     seenOptionalElement = true;
52203                 }
52204                 else if (seenOptionalElement) {
52205                     grammarErrorOnNode(e, ts.Diagnostics.A_required_element_cannot_follow_an_optional_element);
52206                     break;
52207                 }
52208             }
52209             ts.forEach(node.elementTypes, checkSourceElement);
52210         }
52211         function checkUnionOrIntersectionType(node) {
52212             ts.forEach(node.types, checkSourceElement);
52213         }
52214         function checkIndexedAccessIndexType(type, accessNode) {
52215             if (!(type.flags & 8388608)) {
52216                 return type;
52217             }
52218             var objectType = type.objectType;
52219             var indexType = type.indexType;
52220             if (isTypeAssignableTo(indexType, getIndexType(objectType, false))) {
52221                 if (accessNode.kind === 195 && ts.isAssignmentTarget(accessNode) &&
52222                     ts.getObjectFlags(objectType) & 32 && getMappedTypeModifiers(objectType) & 1) {
52223                     error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType));
52224                 }
52225                 return type;
52226             }
52227             var apparentObjectType = getApparentType(objectType);
52228             if (getIndexInfoOfType(apparentObjectType, 1) && isTypeAssignableToKind(indexType, 296)) {
52229                 return type;
52230             }
52231             if (isGenericObjectType(objectType)) {
52232                 var propertyName_1 = getPropertyNameFromIndex(indexType, accessNode);
52233                 if (propertyName_1) {
52234                     var propertySymbol = forEachType(apparentObjectType, function (t) { return getPropertyOfType(t, propertyName_1); });
52235                     if (propertySymbol && ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 24) {
52236                         error(accessNode, ts.Diagnostics.Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter, ts.unescapeLeadingUnderscores(propertyName_1));
52237                         return errorType;
52238                     }
52239                 }
52240             }
52241             error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType));
52242             return errorType;
52243         }
52244         function checkIndexedAccessType(node) {
52245             checkSourceElement(node.objectType);
52246             checkSourceElement(node.indexType);
52247             checkIndexedAccessIndexType(getTypeFromIndexedAccessTypeNode(node), node);
52248         }
52249         function checkMappedType(node) {
52250             checkSourceElement(node.typeParameter);
52251             checkSourceElement(node.type);
52252             if (!node.type) {
52253                 reportImplicitAny(node, anyType);
52254             }
52255             var type = getTypeFromMappedTypeNode(node);
52256             var constraintType = getConstraintTypeFromMappedType(type);
52257             checkTypeAssignableTo(constraintType, keyofConstraintType, ts.getEffectiveConstraintOfTypeParameter(node.typeParameter));
52258         }
52259         function checkThisType(node) {
52260             getTypeFromThisTypeNode(node);
52261         }
52262         function checkTypeOperator(node) {
52263             checkGrammarTypeOperatorNode(node);
52264             checkSourceElement(node.type);
52265         }
52266         function checkConditionalType(node) {
52267             ts.forEachChild(node, checkSourceElement);
52268         }
52269         function checkInferType(node) {
52270             if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 180 && n.parent.extendsType === n; })) {
52271                 grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type);
52272             }
52273             checkSourceElement(node.typeParameter);
52274             registerForUnusedIdentifiersCheck(node);
52275         }
52276         function checkImportType(node) {
52277             checkSourceElement(node.argument);
52278             getTypeFromTypeNode(node);
52279         }
52280         function isPrivateWithinAmbient(node) {
52281             return (ts.hasModifier(node, 8) || ts.isPrivateIdentifierPropertyDeclaration(node)) && !!(node.flags & 8388608);
52282         }
52283         function getEffectiveDeclarationFlags(n, flagsToCheck) {
52284             var flags = ts.getCombinedModifierFlags(n);
52285             if (n.parent.kind !== 246 &&
52286                 n.parent.kind !== 245 &&
52287                 n.parent.kind !== 214 &&
52288                 n.flags & 8388608) {
52289                 if (!(flags & 2) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) {
52290                     flags |= 1;
52291                 }
52292                 flags |= 2;
52293             }
52294             return flags & flagsToCheck;
52295         }
52296         function checkFunctionOrConstructorSymbol(symbol) {
52297             if (!produceDiagnostics) {
52298                 return;
52299             }
52300             function getCanonicalOverload(overloads, implementation) {
52301                 var implementationSharesContainerWithFirstOverload = implementation !== undefined && implementation.parent === overloads[0].parent;
52302                 return implementationSharesContainerWithFirstOverload ? implementation : overloads[0];
52303             }
52304             function checkFlagAgreementBetweenOverloads(overloads, implementation, flagsToCheck, someOverloadFlags, allOverloadFlags) {
52305                 var someButNotAllOverloadFlags = someOverloadFlags ^ allOverloadFlags;
52306                 if (someButNotAllOverloadFlags !== 0) {
52307                     var canonicalFlags_1 = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck);
52308                     ts.forEach(overloads, function (o) {
52309                         var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags_1;
52310                         if (deviation & 1) {
52311                             error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported);
52312                         }
52313                         else if (deviation & 2) {
52314                             error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient);
52315                         }
52316                         else if (deviation & (8 | 16)) {
52317                             error(ts.getNameOfDeclaration(o) || o, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected);
52318                         }
52319                         else if (deviation & 128) {
52320                             error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract);
52321                         }
52322                     });
52323                 }
52324             }
52325             function checkQuestionTokenAgreementBetweenOverloads(overloads, implementation, someHaveQuestionToken, allHaveQuestionToken) {
52326                 if (someHaveQuestionToken !== allHaveQuestionToken) {
52327                     var canonicalHasQuestionToken_1 = ts.hasQuestionToken(getCanonicalOverload(overloads, implementation));
52328                     ts.forEach(overloads, function (o) {
52329                         var deviation = ts.hasQuestionToken(o) !== canonicalHasQuestionToken_1;
52330                         if (deviation) {
52331                             error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_optional_or_required);
52332                         }
52333                     });
52334                 }
52335             }
52336             var flagsToCheck = 1 | 2 | 8 | 16 | 128;
52337             var someNodeFlags = 0;
52338             var allNodeFlags = flagsToCheck;
52339             var someHaveQuestionToken = false;
52340             var allHaveQuestionToken = true;
52341             var hasOverloads = false;
52342             var bodyDeclaration;
52343             var lastSeenNonAmbientDeclaration;
52344             var previousDeclaration;
52345             var declarations = symbol.declarations;
52346             var isConstructor = (symbol.flags & 16384) !== 0;
52347             function reportImplementationExpectedError(node) {
52348                 if (node.name && ts.nodeIsMissing(node.name)) {
52349                     return;
52350                 }
52351                 var seen = false;
52352                 var subsequentNode = ts.forEachChild(node.parent, function (c) {
52353                     if (seen) {
52354                         return c;
52355                     }
52356                     else {
52357                         seen = c === node;
52358                     }
52359                 });
52360                 if (subsequentNode && subsequentNode.pos === node.end) {
52361                     if (subsequentNode.kind === node.kind) {
52362                         var errorNode_1 = subsequentNode.name || subsequentNode;
52363                         var subsequentName = subsequentNode.name;
52364                         if (node.name && subsequentName && (ts.isPrivateIdentifier(node.name) && ts.isPrivateIdentifier(subsequentName) && node.name.escapedText === subsequentName.escapedText ||
52365                             ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) ||
52366                             ts.isPropertyNameLiteral(node.name) && ts.isPropertyNameLiteral(subsequentName) &&
52367                                 ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) {
52368                             var reportError = (node.kind === 161 || node.kind === 160) &&
52369                                 ts.hasModifier(node, 32) !== ts.hasModifier(subsequentNode, 32);
52370                             if (reportError) {
52371                                 var diagnostic = ts.hasModifier(node, 32) ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static;
52372                                 error(errorNode_1, diagnostic);
52373                             }
52374                             return;
52375                         }
52376                         if (ts.nodeIsPresent(subsequentNode.body)) {
52377                             error(errorNode_1, ts.Diagnostics.Function_implementation_name_must_be_0, ts.declarationNameToString(node.name));
52378                             return;
52379                         }
52380                     }
52381                 }
52382                 var errorNode = node.name || node;
52383                 if (isConstructor) {
52384                     error(errorNode, ts.Diagnostics.Constructor_implementation_is_missing);
52385                 }
52386                 else {
52387                     if (ts.hasModifier(node, 128)) {
52388                         error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive);
52389                     }
52390                     else {
52391                         error(errorNode, ts.Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration);
52392                     }
52393                 }
52394             }
52395             var duplicateFunctionDeclaration = false;
52396             var multipleConstructorImplementation = false;
52397             var hasNonAmbientClass = false;
52398             for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) {
52399                 var current = declarations_4[_i];
52400                 var node = current;
52401                 var inAmbientContext = node.flags & 8388608;
52402                 var inAmbientContextOrInterface = node.parent.kind === 246 || node.parent.kind === 173 || inAmbientContext;
52403                 if (inAmbientContextOrInterface) {
52404                     previousDeclaration = undefined;
52405                 }
52406                 if ((node.kind === 245 || node.kind === 214) && !inAmbientContext) {
52407                     hasNonAmbientClass = true;
52408                 }
52409                 if (node.kind === 244 || node.kind === 161 || node.kind === 160 || node.kind === 162) {
52410                     var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck);
52411                     someNodeFlags |= currentNodeFlags;
52412                     allNodeFlags &= currentNodeFlags;
52413                     someHaveQuestionToken = someHaveQuestionToken || ts.hasQuestionToken(node);
52414                     allHaveQuestionToken = allHaveQuestionToken && ts.hasQuestionToken(node);
52415                     if (ts.nodeIsPresent(node.body) && bodyDeclaration) {
52416                         if (isConstructor) {
52417                             multipleConstructorImplementation = true;
52418                         }
52419                         else {
52420                             duplicateFunctionDeclaration = true;
52421                         }
52422                     }
52423                     else if (previousDeclaration && previousDeclaration.parent === node.parent && previousDeclaration.end !== node.pos) {
52424                         reportImplementationExpectedError(previousDeclaration);
52425                     }
52426                     if (ts.nodeIsPresent(node.body)) {
52427                         if (!bodyDeclaration) {
52428                             bodyDeclaration = node;
52429                         }
52430                     }
52431                     else {
52432                         hasOverloads = true;
52433                     }
52434                     previousDeclaration = node;
52435                     if (!inAmbientContextOrInterface) {
52436                         lastSeenNonAmbientDeclaration = node;
52437                     }
52438                 }
52439             }
52440             if (multipleConstructorImplementation) {
52441                 ts.forEach(declarations, function (declaration) {
52442                     error(declaration, ts.Diagnostics.Multiple_constructor_implementations_are_not_allowed);
52443                 });
52444             }
52445             if (duplicateFunctionDeclaration) {
52446                 ts.forEach(declarations, function (declaration) {
52447                     error(ts.getNameOfDeclaration(declaration), ts.Diagnostics.Duplicate_function_implementation);
52448                 });
52449             }
52450             if (hasNonAmbientClass && !isConstructor && symbol.flags & 16) {
52451                 ts.forEach(declarations, function (declaration) {
52452                     addDuplicateDeclarationError(declaration, ts.Diagnostics.Duplicate_identifier_0, ts.symbolName(symbol), declarations);
52453                 });
52454             }
52455             if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body &&
52456                 !ts.hasModifier(lastSeenNonAmbientDeclaration, 128) && !lastSeenNonAmbientDeclaration.questionToken) {
52457                 reportImplementationExpectedError(lastSeenNonAmbientDeclaration);
52458             }
52459             if (hasOverloads) {
52460                 checkFlagAgreementBetweenOverloads(declarations, bodyDeclaration, flagsToCheck, someNodeFlags, allNodeFlags);
52461                 checkQuestionTokenAgreementBetweenOverloads(declarations, bodyDeclaration, someHaveQuestionToken, allHaveQuestionToken);
52462                 if (bodyDeclaration) {
52463                     var signatures = getSignaturesOfSymbol(symbol);
52464                     var bodySignature = getSignatureFromDeclaration(bodyDeclaration);
52465                     for (var _a = 0, signatures_10 = signatures; _a < signatures_10.length; _a++) {
52466                         var signature = signatures_10[_a];
52467                         if (!isImplementationCompatibleWithOverload(bodySignature, signature)) {
52468                             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));
52469                             break;
52470                         }
52471                     }
52472                 }
52473             }
52474         }
52475         function checkExportsOnMergedDeclarations(node) {
52476             if (!produceDiagnostics) {
52477                 return;
52478             }
52479             var symbol = node.localSymbol;
52480             if (!symbol) {
52481                 symbol = getSymbolOfNode(node);
52482                 if (!symbol.exportSymbol) {
52483                     return;
52484                 }
52485             }
52486             if (ts.getDeclarationOfKind(symbol, node.kind) !== node) {
52487                 return;
52488             }
52489             var exportedDeclarationSpaces = 0;
52490             var nonExportedDeclarationSpaces = 0;
52491             var defaultExportedDeclarationSpaces = 0;
52492             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
52493                 var d = _a[_i];
52494                 var declarationSpaces = getDeclarationSpaces(d);
52495                 var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 | 512);
52496                 if (effectiveDeclarationFlags & 1) {
52497                     if (effectiveDeclarationFlags & 512) {
52498                         defaultExportedDeclarationSpaces |= declarationSpaces;
52499                     }
52500                     else {
52501                         exportedDeclarationSpaces |= declarationSpaces;
52502                     }
52503                 }
52504                 else {
52505                     nonExportedDeclarationSpaces |= declarationSpaces;
52506                 }
52507             }
52508             var nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces;
52509             var commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces;
52510             var commonDeclarationSpacesForDefaultAndNonDefault = defaultExportedDeclarationSpaces & nonDefaultExportedDeclarationSpaces;
52511             if (commonDeclarationSpacesForExportsAndLocals || commonDeclarationSpacesForDefaultAndNonDefault) {
52512                 for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) {
52513                     var d = _c[_b];
52514                     var declarationSpaces = getDeclarationSpaces(d);
52515                     var name = ts.getNameOfDeclaration(d);
52516                     if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) {
52517                         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));
52518                     }
52519                     else if (declarationSpaces & commonDeclarationSpacesForExportsAndLocals) {
52520                         error(name, ts.Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, ts.declarationNameToString(name));
52521                     }
52522                 }
52523             }
52524             function getDeclarationSpaces(decl) {
52525                 var d = decl;
52526                 switch (d.kind) {
52527                     case 246:
52528                     case 247:
52529                     case 322:
52530                     case 315:
52531                     case 316:
52532                         return 2;
52533                     case 249:
52534                         return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0
52535                             ? 4 | 1
52536                             : 4;
52537                     case 245:
52538                     case 248:
52539                     case 284:
52540                         return 2 | 1;
52541                     case 290:
52542                         return 2 | 1 | 4;
52543                     case 259:
52544                         if (!ts.isEntityNameExpression(d.expression)) {
52545                             return 1;
52546                         }
52547                         d = d.expression;
52548                     case 253:
52549                     case 256:
52550                     case 255:
52551                         var result_10 = 0;
52552                         var target = resolveAlias(getSymbolOfNode(d));
52553                         ts.forEach(target.declarations, function (d) { result_10 |= getDeclarationSpaces(d); });
52554                         return result_10;
52555                     case 242:
52556                     case 191:
52557                     case 244:
52558                     case 258:
52559                     case 75:
52560                         return 1;
52561                     default:
52562                         return ts.Debug.failBadSyntaxKind(d);
52563                 }
52564             }
52565         }
52566         function getAwaitedTypeOfPromise(type, errorNode, diagnosticMessage, arg0) {
52567             var promisedType = getPromisedTypeOfPromise(type, errorNode);
52568             return promisedType && getAwaitedType(promisedType, errorNode, diagnosticMessage, arg0);
52569         }
52570         function getPromisedTypeOfPromise(type, errorNode) {
52571             if (isTypeAny(type)) {
52572                 return undefined;
52573             }
52574             var typeAsPromise = type;
52575             if (typeAsPromise.promisedTypeOfPromise) {
52576                 return typeAsPromise.promisedTypeOfPromise;
52577             }
52578             if (isReferenceToType(type, getGlobalPromiseType(false))) {
52579                 return typeAsPromise.promisedTypeOfPromise = getTypeArguments(type)[0];
52580             }
52581             var thenFunction = getTypeOfPropertyOfType(type, "then");
52582             if (isTypeAny(thenFunction)) {
52583                 return undefined;
52584             }
52585             var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0) : ts.emptyArray;
52586             if (thenSignatures.length === 0) {
52587                 if (errorNode) {
52588                     error(errorNode, ts.Diagnostics.A_promise_must_have_a_then_method);
52589                 }
52590                 return undefined;
52591             }
52592             var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 2097152);
52593             if (isTypeAny(onfulfilledParameterType)) {
52594                 return undefined;
52595             }
52596             var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0);
52597             if (onfulfilledParameterSignatures.length === 0) {
52598                 if (errorNode) {
52599                     error(errorNode, ts.Diagnostics.The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback);
52600                 }
52601                 return undefined;
52602             }
52603             return typeAsPromise.promisedTypeOfPromise = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), 2);
52604         }
52605         function checkAwaitedType(type, errorNode, diagnosticMessage, arg0) {
52606             var awaitedType = getAwaitedType(type, errorNode, diagnosticMessage, arg0);
52607             return awaitedType || errorType;
52608         }
52609         function isThenableType(type) {
52610             var thenFunction = getTypeOfPropertyOfType(type, "then");
52611             return !!thenFunction && getSignaturesOfType(getTypeWithFacts(thenFunction, 2097152), 0).length > 0;
52612         }
52613         function getAwaitedType(type, errorNode, diagnosticMessage, arg0) {
52614             if (isTypeAny(type)) {
52615                 return type;
52616             }
52617             var typeAsAwaitable = type;
52618             if (typeAsAwaitable.awaitedTypeOfType) {
52619                 return typeAsAwaitable.awaitedTypeOfType;
52620             }
52621             return typeAsAwaitable.awaitedTypeOfType =
52622                 mapType(type, errorNode ? function (constituentType) { return getAwaitedTypeWorker(constituentType, errorNode, diagnosticMessage, arg0); } : getAwaitedTypeWorker);
52623         }
52624         function getAwaitedTypeWorker(type, errorNode, diagnosticMessage, arg0) {
52625             var typeAsAwaitable = type;
52626             if (typeAsAwaitable.awaitedTypeOfType) {
52627                 return typeAsAwaitable.awaitedTypeOfType;
52628             }
52629             var promisedType = getPromisedTypeOfPromise(type);
52630             if (promisedType) {
52631                 if (type.id === promisedType.id || awaitedTypeStack.lastIndexOf(promisedType.id) >= 0) {
52632                     if (errorNode) {
52633                         error(errorNode, ts.Diagnostics.Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method);
52634                     }
52635                     return undefined;
52636                 }
52637                 awaitedTypeStack.push(type.id);
52638                 var awaitedType = getAwaitedType(promisedType, errorNode, diagnosticMessage, arg0);
52639                 awaitedTypeStack.pop();
52640                 if (!awaitedType) {
52641                     return undefined;
52642                 }
52643                 return typeAsAwaitable.awaitedTypeOfType = awaitedType;
52644             }
52645             if (isThenableType(type)) {
52646                 if (errorNode) {
52647                     if (!diagnosticMessage)
52648                         return ts.Debug.fail();
52649                     error(errorNode, diagnosticMessage, arg0);
52650                 }
52651                 return undefined;
52652             }
52653             return typeAsAwaitable.awaitedTypeOfType = type;
52654         }
52655         function checkAsyncFunctionReturnType(node, returnTypeNode) {
52656             var returnType = getTypeFromTypeNode(returnTypeNode);
52657             if (languageVersion >= 2) {
52658                 if (returnType === errorType) {
52659                     return;
52660                 }
52661                 var globalPromiseType = getGlobalPromiseType(true);
52662                 if (globalPromiseType !== emptyGenericType && !isReferenceToType(returnType, globalPromiseType)) {
52663                     error(returnTypeNode, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type);
52664                     return;
52665                 }
52666             }
52667             else {
52668                 markTypeNodeAsReferenced(returnTypeNode);
52669                 if (returnType === errorType) {
52670                     return;
52671                 }
52672                 var promiseConstructorName = ts.getEntityNameFromTypeNode(returnTypeNode);
52673                 if (promiseConstructorName === undefined) {
52674                     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));
52675                     return;
52676                 }
52677                 var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551, true);
52678                 var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType;
52679                 if (promiseConstructorType === errorType) {
52680                     if (promiseConstructorName.kind === 75 && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(false)) {
52681                         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);
52682                     }
52683                     else {
52684                         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));
52685                     }
52686                     return;
52687                 }
52688                 var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(true);
52689                 if (globalPromiseConstructorLikeType === emptyObjectType) {
52690                     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));
52691                     return;
52692                 }
52693                 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)) {
52694                     return;
52695                 }
52696                 var rootName = promiseConstructorName && ts.getFirstIdentifier(promiseConstructorName);
52697                 var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551);
52698                 if (collidingSymbol) {
52699                     error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName));
52700                     return;
52701                 }
52702             }
52703             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);
52704         }
52705         function checkDecorator(node) {
52706             var signature = getResolvedSignature(node);
52707             var returnType = getReturnTypeOfSignature(signature);
52708             if (returnType.flags & 1) {
52709                 return;
52710             }
52711             var expectedReturnType;
52712             var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node);
52713             var errorInfo;
52714             switch (node.parent.kind) {
52715                 case 245:
52716                     var classSymbol = getSymbolOfNode(node.parent);
52717                     var classConstructorType = getTypeOfSymbol(classSymbol);
52718                     expectedReturnType = getUnionType([classConstructorType, voidType]);
52719                     break;
52720                 case 156:
52721                     expectedReturnType = voidType;
52722                     errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any);
52723                     break;
52724                 case 159:
52725                     expectedReturnType = voidType;
52726                     errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any);
52727                     break;
52728                 case 161:
52729                 case 163:
52730                 case 164:
52731                     var methodType = getTypeOfNode(node.parent);
52732                     var descriptorType = createTypedPropertyDescriptorType(methodType);
52733                     expectedReturnType = getUnionType([descriptorType, voidType]);
52734                     break;
52735                 default:
52736                     return ts.Debug.fail();
52737             }
52738             checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, function () { return errorInfo; });
52739         }
52740         function markTypeNodeAsReferenced(node) {
52741             markEntityNameOrEntityExpressionAsReference(node && ts.getEntityNameFromTypeNode(node));
52742         }
52743         function markEntityNameOrEntityExpressionAsReference(typeName) {
52744             if (!typeName)
52745                 return;
52746             var rootName = ts.getFirstIdentifier(typeName);
52747             var meaning = (typeName.kind === 75 ? 788968 : 1920) | 2097152;
52748             var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, undefined, undefined, true);
52749             if (rootSymbol
52750                 && rootSymbol.flags & 2097152
52751                 && symbolIsValue(rootSymbol)
52752                 && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))
52753                 && !getTypeOnlyAliasDeclaration(rootSymbol)) {
52754                 markAliasSymbolAsReferenced(rootSymbol);
52755             }
52756         }
52757         function markDecoratorMedataDataTypeNodeAsReferenced(node) {
52758             var entityName = getEntityNameForDecoratorMetadata(node);
52759             if (entityName && ts.isEntityName(entityName)) {
52760                 markEntityNameOrEntityExpressionAsReference(entityName);
52761             }
52762         }
52763         function getEntityNameForDecoratorMetadata(node) {
52764             if (node) {
52765                 switch (node.kind) {
52766                     case 179:
52767                     case 178:
52768                         return getEntityNameForDecoratorMetadataFromTypeList(node.types);
52769                     case 180:
52770                         return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]);
52771                     case 182:
52772                         return getEntityNameForDecoratorMetadata(node.type);
52773                     case 169:
52774                         return node.typeName;
52775                 }
52776             }
52777         }
52778         function getEntityNameForDecoratorMetadataFromTypeList(types) {
52779             var commonEntityName;
52780             for (var _i = 0, types_20 = types; _i < types_20.length; _i++) {
52781                 var typeNode = types_20[_i];
52782                 while (typeNode.kind === 182) {
52783                     typeNode = typeNode.type;
52784                 }
52785                 if (typeNode.kind === 137) {
52786                     continue;
52787                 }
52788                 if (!strictNullChecks && (typeNode.kind === 100 || typeNode.kind === 146)) {
52789                     continue;
52790                 }
52791                 var individualEntityName = getEntityNameForDecoratorMetadata(typeNode);
52792                 if (!individualEntityName) {
52793                     return undefined;
52794                 }
52795                 if (commonEntityName) {
52796                     if (!ts.isIdentifier(commonEntityName) ||
52797                         !ts.isIdentifier(individualEntityName) ||
52798                         commonEntityName.escapedText !== individualEntityName.escapedText) {
52799                         return undefined;
52800                     }
52801                 }
52802                 else {
52803                     commonEntityName = individualEntityName;
52804                 }
52805             }
52806             return commonEntityName;
52807         }
52808         function getParameterTypeNodeForDecoratorCheck(node) {
52809             var typeNode = ts.getEffectiveTypeAnnotationNode(node);
52810             return ts.isRestParameter(node) ? ts.getRestParameterElementType(typeNode) : typeNode;
52811         }
52812         function checkDecorators(node) {
52813             if (!node.decorators) {
52814                 return;
52815             }
52816             if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) {
52817                 return;
52818             }
52819             if (!compilerOptions.experimentalDecorators) {
52820                 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);
52821             }
52822             var firstDecorator = node.decorators[0];
52823             checkExternalEmitHelpers(firstDecorator, 8);
52824             if (node.kind === 156) {
52825                 checkExternalEmitHelpers(firstDecorator, 32);
52826             }
52827             if (compilerOptions.emitDecoratorMetadata) {
52828                 checkExternalEmitHelpers(firstDecorator, 16);
52829                 switch (node.kind) {
52830                     case 245:
52831                         var constructor = ts.getFirstConstructorWithBody(node);
52832                         if (constructor) {
52833                             for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) {
52834                                 var parameter = _a[_i];
52835                                 markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter));
52836                             }
52837                         }
52838                         break;
52839                     case 163:
52840                     case 164:
52841                         var otherKind = node.kind === 163 ? 164 : 163;
52842                         var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind);
52843                         markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor));
52844                         break;
52845                     case 161:
52846                         for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) {
52847                             var parameter = _c[_b];
52848                             markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter));
52849                         }
52850                         markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveReturnTypeNode(node));
52851                         break;
52852                     case 159:
52853                         markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node));
52854                         break;
52855                     case 156:
52856                         markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node));
52857                         var containingSignature = node.parent;
52858                         for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) {
52859                             var parameter = _e[_d];
52860                             markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter));
52861                         }
52862                         break;
52863                 }
52864             }
52865             ts.forEach(node.decorators, checkDecorator);
52866         }
52867         function checkFunctionDeclaration(node) {
52868             if (produceDiagnostics) {
52869                 checkFunctionOrMethodDeclaration(node);
52870                 checkGrammarForGenerator(node);
52871                 checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
52872                 checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
52873             }
52874         }
52875         function checkJSDocTypeAliasTag(node) {
52876             if (!node.typeExpression) {
52877                 error(node.name, ts.Diagnostics.JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags);
52878             }
52879             if (node.name) {
52880                 checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0);
52881             }
52882             checkSourceElement(node.typeExpression);
52883         }
52884         function checkJSDocTemplateTag(node) {
52885             checkSourceElement(node.constraint);
52886             for (var _i = 0, _a = node.typeParameters; _i < _a.length; _i++) {
52887                 var tp = _a[_i];
52888                 checkSourceElement(tp);
52889             }
52890         }
52891         function checkJSDocTypeTag(node) {
52892             checkSourceElement(node.typeExpression);
52893         }
52894         function checkJSDocParameterTag(node) {
52895             checkSourceElement(node.typeExpression);
52896             if (!ts.getParameterSymbolFromJSDoc(node)) {
52897                 var decl = ts.getHostSignatureFromJSDoc(node);
52898                 if (decl) {
52899                     var i = ts.getJSDocTags(decl).filter(ts.isJSDocParameterTag).indexOf(node);
52900                     if (i > -1 && i < decl.parameters.length && ts.isBindingPattern(decl.parameters[i].name)) {
52901                         return;
52902                     }
52903                     if (!containsArgumentsReference(decl)) {
52904                         if (ts.isQualifiedName(node.name)) {
52905                             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));
52906                         }
52907                         else {
52908                             error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name));
52909                         }
52910                     }
52911                     else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node &&
52912                         node.typeExpression && node.typeExpression.type &&
52913                         !isArrayType(getTypeFromTypeNode(node.typeExpression.type))) {
52914                         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));
52915                     }
52916                 }
52917             }
52918         }
52919         function checkJSDocPropertyTag(node) {
52920             checkSourceElement(node.typeExpression);
52921         }
52922         function checkJSDocFunctionType(node) {
52923             if (produceDiagnostics && !node.type && !ts.isJSDocConstructSignature(node)) {
52924                 reportImplicitAny(node, anyType);
52925             }
52926             checkSignatureDeclaration(node);
52927         }
52928         function checkJSDocImplementsTag(node) {
52929             var classLike = ts.getEffectiveJSDocHost(node);
52930             if (!classLike || !ts.isClassDeclaration(classLike) && !ts.isClassExpression(classLike)) {
52931                 error(classLike, ts.Diagnostics.JSDoc_0_is_not_attached_to_a_class, ts.idText(node.tagName));
52932             }
52933         }
52934         function checkJSDocAugmentsTag(node) {
52935             var classLike = ts.getEffectiveJSDocHost(node);
52936             if (!classLike || !ts.isClassDeclaration(classLike) && !ts.isClassExpression(classLike)) {
52937                 error(classLike, ts.Diagnostics.JSDoc_0_is_not_attached_to_a_class, ts.idText(node.tagName));
52938                 return;
52939             }
52940             var augmentsTags = ts.getJSDocTags(classLike).filter(ts.isJSDocAugmentsTag);
52941             ts.Debug.assert(augmentsTags.length > 0);
52942             if (augmentsTags.length > 1) {
52943                 error(augmentsTags[1], ts.Diagnostics.Class_declarations_cannot_have_more_than_one_augments_or_extends_tag);
52944             }
52945             var name = getIdentifierFromEntityNameExpression(node.class.expression);
52946             var extend = ts.getClassExtendsHeritageElement(classLike);
52947             if (extend) {
52948                 var className = getIdentifierFromEntityNameExpression(extend.expression);
52949                 if (className && name.escapedText !== className.escapedText) {
52950                     error(name, ts.Diagnostics.JSDoc_0_1_does_not_match_the_extends_2_clause, ts.idText(node.tagName), ts.idText(name), ts.idText(className));
52951                 }
52952             }
52953         }
52954         function getIdentifierFromEntityNameExpression(node) {
52955             switch (node.kind) {
52956                 case 75:
52957                     return node;
52958                 case 194:
52959                     return node.name;
52960                 default:
52961                     return undefined;
52962             }
52963         }
52964         function checkFunctionOrMethodDeclaration(node) {
52965             checkDecorators(node);
52966             checkSignatureDeclaration(node);
52967             var functionFlags = ts.getFunctionFlags(node);
52968             if (node.name && node.name.kind === 154) {
52969                 checkComputedPropertyName(node.name);
52970             }
52971             if (!hasNonBindableDynamicName(node)) {
52972                 var symbol = getSymbolOfNode(node);
52973                 var localSymbol = node.localSymbol || symbol;
52974                 var firstDeclaration = ts.find(localSymbol.declarations, function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 131072); });
52975                 if (node === firstDeclaration) {
52976                     checkFunctionOrConstructorSymbol(localSymbol);
52977                 }
52978                 if (symbol.parent) {
52979                     if (ts.getDeclarationOfKind(symbol, node.kind) === node) {
52980                         checkFunctionOrConstructorSymbol(symbol);
52981                     }
52982                 }
52983             }
52984             var body = node.kind === 160 ? undefined : node.body;
52985             checkSourceElement(body);
52986             checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node));
52987             if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) {
52988                 if (ts.nodeIsMissing(body) && !isPrivateWithinAmbient(node)) {
52989                     reportImplicitAny(node, anyType);
52990                 }
52991                 if (functionFlags & 1 && ts.nodeIsPresent(body)) {
52992                     getReturnTypeOfSignature(getSignatureFromDeclaration(node));
52993                 }
52994             }
52995             if (ts.isInJSFile(node)) {
52996                 var typeTag = ts.getJSDocTypeTag(node);
52997                 if (typeTag && typeTag.typeExpression && !getContextualCallSignature(getTypeFromTypeNode(typeTag.typeExpression), node)) {
52998                     error(typeTag, ts.Diagnostics.The_type_of_a_function_declaration_must_match_the_function_s_signature);
52999                 }
53000             }
53001         }
53002         function registerForUnusedIdentifiersCheck(node) {
53003             if (produceDiagnostics) {
53004                 var sourceFile = ts.getSourceFileOfNode(node);
53005                 var potentiallyUnusedIdentifiers = allPotentiallyUnusedIdentifiers.get(sourceFile.path);
53006                 if (!potentiallyUnusedIdentifiers) {
53007                     potentiallyUnusedIdentifiers = [];
53008                     allPotentiallyUnusedIdentifiers.set(sourceFile.path, potentiallyUnusedIdentifiers);
53009                 }
53010                 potentiallyUnusedIdentifiers.push(node);
53011             }
53012         }
53013         function checkUnusedIdentifiers(potentiallyUnusedIdentifiers, addDiagnostic) {
53014             for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) {
53015                 var node = potentiallyUnusedIdentifiers_1[_i];
53016                 switch (node.kind) {
53017                     case 245:
53018                     case 214:
53019                         checkUnusedClassMembers(node, addDiagnostic);
53020                         checkUnusedTypeParameters(node, addDiagnostic);
53021                         break;
53022                     case 290:
53023                     case 249:
53024                     case 223:
53025                     case 251:
53026                     case 230:
53027                     case 231:
53028                     case 232:
53029                         checkUnusedLocalsAndParameters(node, addDiagnostic);
53030                         break;
53031                     case 162:
53032                     case 201:
53033                     case 244:
53034                     case 202:
53035                     case 161:
53036                     case 163:
53037                     case 164:
53038                         if (node.body) {
53039                             checkUnusedLocalsAndParameters(node, addDiagnostic);
53040                         }
53041                         checkUnusedTypeParameters(node, addDiagnostic);
53042                         break;
53043                     case 160:
53044                     case 165:
53045                     case 166:
53046                     case 170:
53047                     case 171:
53048                     case 247:
53049                     case 246:
53050                         checkUnusedTypeParameters(node, addDiagnostic);
53051                         break;
53052                     case 181:
53053                         checkUnusedInferTypeParameter(node, addDiagnostic);
53054                         break;
53055                     default:
53056                         ts.Debug.assertNever(node, "Node should not have been registered for unused identifiers check");
53057                 }
53058             }
53059         }
53060         function errorUnusedLocal(declaration, name, addDiagnostic) {
53061             var node = ts.getNameOfDeclaration(declaration) || declaration;
53062             var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read;
53063             addDiagnostic(declaration, 0, ts.createDiagnosticForNode(node, message, name));
53064         }
53065         function isIdentifierThatStartsWithUnderscore(node) {
53066             return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95;
53067         }
53068         function checkUnusedClassMembers(node, addDiagnostic) {
53069             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
53070                 var member = _a[_i];
53071                 switch (member.kind) {
53072                     case 161:
53073                     case 159:
53074                     case 163:
53075                     case 164:
53076                         if (member.kind === 164 && member.symbol.flags & 32768) {
53077                             break;
53078                         }
53079                         var symbol = getSymbolOfNode(member);
53080                         if (!symbol.isReferenced
53081                             && (ts.hasModifier(member, 8) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name))
53082                             && !(member.flags & 8388608)) {
53083                             addDiagnostic(member, 0, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol)));
53084                         }
53085                         break;
53086                     case 162:
53087                         for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) {
53088                             var parameter = _c[_b];
53089                             if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8)) {
53090                                 addDiagnostic(parameter, 0, ts.createDiagnosticForNode(parameter.name, ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read, ts.symbolName(parameter.symbol)));
53091                             }
53092                         }
53093                         break;
53094                     case 167:
53095                     case 222:
53096                         break;
53097                     default:
53098                         ts.Debug.fail();
53099                 }
53100             }
53101         }
53102         function checkUnusedInferTypeParameter(node, addDiagnostic) {
53103             var typeParameter = node.typeParameter;
53104             if (isTypeParameterUnused(typeParameter)) {
53105                 addDiagnostic(node, 1, ts.createDiagnosticForNode(node, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(typeParameter.name)));
53106             }
53107         }
53108         function checkUnusedTypeParameters(node, addDiagnostic) {
53109             if (ts.last(getSymbolOfNode(node).declarations) !== node)
53110                 return;
53111             var typeParameters = ts.getEffectiveTypeParameterDeclarations(node);
53112             var seenParentsWithEveryUnused = new ts.NodeSet();
53113             for (var _i = 0, typeParameters_3 = typeParameters; _i < typeParameters_3.length; _i++) {
53114                 var typeParameter = typeParameters_3[_i];
53115                 if (!isTypeParameterUnused(typeParameter))
53116                     continue;
53117                 var name = ts.idText(typeParameter.name);
53118                 var parent = typeParameter.parent;
53119                 if (parent.kind !== 181 && parent.typeParameters.every(isTypeParameterUnused)) {
53120                     if (seenParentsWithEveryUnused.tryAdd(parent)) {
53121                         var range = ts.isJSDocTemplateTag(parent)
53122                             ? ts.rangeOfNode(parent)
53123                             : ts.rangeOfTypeParameters(parent.typeParameters);
53124                         var only = parent.typeParameters.length === 1;
53125                         var message = only ? ts.Diagnostics._0_is_declared_but_its_value_is_never_read : ts.Diagnostics.All_type_parameters_are_unused;
53126                         var arg0 = only ? name : undefined;
53127                         addDiagnostic(typeParameter, 1, ts.createFileDiagnostic(ts.getSourceFileOfNode(parent), range.pos, range.end - range.pos, message, arg0));
53128                     }
53129                 }
53130                 else {
53131                     addDiagnostic(typeParameter, 1, ts.createDiagnosticForNode(typeParameter, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, name));
53132                 }
53133             }
53134         }
53135         function isTypeParameterUnused(typeParameter) {
53136             return !(getMergedSymbol(typeParameter.symbol).isReferenced & 262144) && !isIdentifierThatStartsWithUnderscore(typeParameter.name);
53137         }
53138         function addToGroup(map, key, value, getKey) {
53139             var keyString = String(getKey(key));
53140             var group = map.get(keyString);
53141             if (group) {
53142                 group[1].push(value);
53143             }
53144             else {
53145                 map.set(keyString, [key, [value]]);
53146             }
53147         }
53148         function tryGetRootParameterDeclaration(node) {
53149             return ts.tryCast(ts.getRootDeclaration(node), ts.isParameter);
53150         }
53151         function isValidUnusedLocalDeclaration(declaration) {
53152             if (ts.isBindingElement(declaration) && isIdentifierThatStartsWithUnderscore(declaration.name)) {
53153                 return !!ts.findAncestor(declaration.parent, function (ancestor) {
53154                     return ts.isArrayBindingPattern(ancestor) || ts.isVariableDeclaration(ancestor) || ts.isVariableDeclarationList(ancestor) ? false :
53155                         ts.isForOfStatement(ancestor) ? true : "quit";
53156                 });
53157             }
53158             return ts.isAmbientModule(declaration) ||
53159                 (ts.isVariableDeclaration(declaration) && ts.isForInOrOfStatement(declaration.parent.parent) || isImportedDeclaration(declaration)) && isIdentifierThatStartsWithUnderscore(declaration.name);
53160         }
53161         function checkUnusedLocalsAndParameters(nodeWithLocals, addDiagnostic) {
53162             var unusedImports = ts.createMap();
53163             var unusedDestructures = ts.createMap();
53164             var unusedVariables = ts.createMap();
53165             nodeWithLocals.locals.forEach(function (local) {
53166                 if (local.flags & 262144 ? !(local.flags & 3 && !(local.isReferenced & 3)) : local.isReferenced || local.exportSymbol) {
53167                     return;
53168                 }
53169                 for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) {
53170                     var declaration = _a[_i];
53171                     if (isValidUnusedLocalDeclaration(declaration)) {
53172                         continue;
53173                     }
53174                     if (isImportedDeclaration(declaration)) {
53175                         addToGroup(unusedImports, importClauseFromImported(declaration), declaration, getNodeId);
53176                     }
53177                     else if (ts.isBindingElement(declaration) && ts.isObjectBindingPattern(declaration.parent)) {
53178                         var lastElement = ts.last(declaration.parent.elements);
53179                         if (declaration === lastElement || !ts.last(declaration.parent.elements).dotDotDotToken) {
53180                             addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId);
53181                         }
53182                     }
53183                     else if (ts.isVariableDeclaration(declaration)) {
53184                         addToGroup(unusedVariables, declaration.parent, declaration, getNodeId);
53185                     }
53186                     else {
53187                         var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration);
53188                         var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration);
53189                         if (parameter && name) {
53190                             if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) {
53191                                 addDiagnostic(parameter, 1, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local)));
53192                             }
53193                         }
53194                         else {
53195                             errorUnusedLocal(declaration, ts.symbolName(local), addDiagnostic);
53196                         }
53197                     }
53198                 }
53199             });
53200             unusedImports.forEach(function (_a) {
53201                 var importClause = _a[0], unuseds = _a[1];
53202                 var importDecl = importClause.parent;
53203                 var nDeclarations = (importClause.name ? 1 : 0) +
53204                     (importClause.namedBindings ?
53205                         (importClause.namedBindings.kind === 256 ? 1 : importClause.namedBindings.elements.length)
53206                         : 0);
53207                 if (nDeclarations === unuseds.length) {
53208                     addDiagnostic(importDecl, 0, unuseds.length === 1
53209                         ? ts.createDiagnosticForNode(importDecl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.first(unuseds).name))
53210                         : ts.createDiagnosticForNode(importDecl, ts.Diagnostics.All_imports_in_import_declaration_are_unused));
53211                 }
53212                 else {
53213                     for (var _i = 0, unuseds_1 = unuseds; _i < unuseds_1.length; _i++) {
53214                         var unused = unuseds_1[_i];
53215                         errorUnusedLocal(unused, ts.idText(unused.name), addDiagnostic);
53216                     }
53217                 }
53218             });
53219             unusedDestructures.forEach(function (_a) {
53220                 var bindingPattern = _a[0], bindingElements = _a[1];
53221                 var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 : 0;
53222                 if (bindingPattern.elements.length === bindingElements.length) {
53223                     if (bindingElements.length === 1 && bindingPattern.parent.kind === 242 && bindingPattern.parent.parent.kind === 243) {
53224                         addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId);
53225                     }
53226                     else {
53227                         addDiagnostic(bindingPattern, kind, bindingElements.length === 1
53228                             ? ts.createDiagnosticForNode(bindingPattern, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(bindingElements).name))
53229                             : ts.createDiagnosticForNode(bindingPattern, ts.Diagnostics.All_destructured_elements_are_unused));
53230                     }
53231                 }
53232                 else {
53233                     for (var _i = 0, bindingElements_1 = bindingElements; _i < bindingElements_1.length; _i++) {
53234                         var e = bindingElements_1[_i];
53235                         addDiagnostic(e, kind, ts.createDiagnosticForNode(e, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(e.name)));
53236                     }
53237                 }
53238             });
53239             unusedVariables.forEach(function (_a) {
53240                 var declarationList = _a[0], declarations = _a[1];
53241                 if (declarationList.declarations.length === declarations.length) {
53242                     addDiagnostic(declarationList, 0, declarations.length === 1
53243                         ? ts.createDiagnosticForNode(ts.first(declarations).name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(declarations).name))
53244                         : ts.createDiagnosticForNode(declarationList.parent.kind === 225 ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused));
53245                 }
53246                 else {
53247                     for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) {
53248                         var decl = declarations_5[_i];
53249                         addDiagnostic(decl, 0, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name)));
53250                     }
53251                 }
53252             });
53253         }
53254         function bindingNameText(name) {
53255             switch (name.kind) {
53256                 case 75:
53257                     return ts.idText(name);
53258                 case 190:
53259                 case 189:
53260                     return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name);
53261                 default:
53262                     return ts.Debug.assertNever(name);
53263             }
53264         }
53265         function isImportedDeclaration(node) {
53266             return node.kind === 255 || node.kind === 258 || node.kind === 256;
53267         }
53268         function importClauseFromImported(decl) {
53269             return decl.kind === 255 ? decl : decl.kind === 256 ? decl.parent : decl.parent.parent;
53270         }
53271         function checkBlock(node) {
53272             if (node.kind === 223) {
53273                 checkGrammarStatementInAmbientContext(node);
53274             }
53275             if (ts.isFunctionOrModuleBlock(node)) {
53276                 var saveFlowAnalysisDisabled = flowAnalysisDisabled;
53277                 ts.forEach(node.statements, checkSourceElement);
53278                 flowAnalysisDisabled = saveFlowAnalysisDisabled;
53279             }
53280             else {
53281                 ts.forEach(node.statements, checkSourceElement);
53282             }
53283             if (node.locals) {
53284                 registerForUnusedIdentifiersCheck(node);
53285             }
53286         }
53287         function checkCollisionWithArgumentsInGeneratedCode(node) {
53288             if (languageVersion >= 2 || compilerOptions.noEmit || !ts.hasRestParameter(node) || node.flags & 8388608 || ts.nodeIsMissing(node.body)) {
53289                 return;
53290             }
53291             ts.forEach(node.parameters, function (p) {
53292                 if (p.name && !ts.isBindingPattern(p.name) && p.name.escapedText === argumentsSymbol.escapedName) {
53293                     error(p, ts.Diagnostics.Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters);
53294                 }
53295             });
53296         }
53297         function needCollisionCheckForIdentifier(node, identifier, name) {
53298             if (!(identifier && identifier.escapedText === name)) {
53299                 return false;
53300             }
53301             if (node.kind === 159 ||
53302                 node.kind === 158 ||
53303                 node.kind === 161 ||
53304                 node.kind === 160 ||
53305                 node.kind === 163 ||
53306                 node.kind === 164) {
53307                 return false;
53308             }
53309             if (node.flags & 8388608) {
53310                 return false;
53311             }
53312             var root = ts.getRootDeclaration(node);
53313             if (root.kind === 156 && ts.nodeIsMissing(root.parent.body)) {
53314                 return false;
53315             }
53316             return true;
53317         }
53318         function checkIfThisIsCapturedInEnclosingScope(node) {
53319             ts.findAncestor(node, function (current) {
53320                 if (getNodeCheckFlags(current) & 4) {
53321                     var isDeclaration_1 = node.kind !== 75;
53322                     if (isDeclaration_1) {
53323                         error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference);
53324                     }
53325                     else {
53326                         error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference);
53327                     }
53328                     return true;
53329                 }
53330                 return false;
53331             });
53332         }
53333         function checkIfNewTargetIsCapturedInEnclosingScope(node) {
53334             ts.findAncestor(node, function (current) {
53335                 if (getNodeCheckFlags(current) & 8) {
53336                     var isDeclaration_2 = node.kind !== 75;
53337                     if (isDeclaration_2) {
53338                         error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference);
53339                     }
53340                     else {
53341                         error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference);
53342                     }
53343                     return true;
53344                 }
53345                 return false;
53346             });
53347         }
53348         function checkWeakMapCollision(node) {
53349             var enclosingBlockScope = ts.getEnclosingBlockScopeContainer(node);
53350             if (getNodeCheckFlags(enclosingBlockScope) & 67108864) {
53351                 error(node, ts.Diagnostics.Compiler_reserves_name_0_when_emitting_private_identifier_downlevel, "WeakMap");
53352             }
53353         }
53354         function checkCollisionWithRequireExportsInGeneratedCode(node, name) {
53355             if (moduleKind >= ts.ModuleKind.ES2015 || compilerOptions.noEmit) {
53356                 return;
53357             }
53358             if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) {
53359                 return;
53360             }
53361             if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1) {
53362                 return;
53363             }
53364             var parent = getDeclarationContainer(node);
53365             if (parent.kind === 290 && ts.isExternalOrCommonJsModule(parent)) {
53366                 error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name));
53367             }
53368         }
53369         function checkCollisionWithGlobalPromiseInGeneratedCode(node, name) {
53370             if (languageVersion >= 4 || compilerOptions.noEmit || !needCollisionCheckForIdentifier(node, name, "Promise")) {
53371                 return;
53372             }
53373             if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1) {
53374                 return;
53375             }
53376             var parent = getDeclarationContainer(node);
53377             if (parent.kind === 290 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048) {
53378                 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));
53379             }
53380         }
53381         function checkVarDeclaredNamesNotShadowed(node) {
53382             if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) {
53383                 return;
53384             }
53385             if (node.kind === 242 && !node.initializer) {
53386                 return;
53387             }
53388             var symbol = getSymbolOfNode(node);
53389             if (symbol.flags & 1) {
53390                 if (!ts.isIdentifier(node.name))
53391                     return ts.Debug.fail();
53392                 var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3, undefined, undefined, false);
53393                 if (localDeclarationSymbol &&
53394                     localDeclarationSymbol !== symbol &&
53395                     localDeclarationSymbol.flags & 2) {
53396                     if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) {
53397                         var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 243);
53398                         var container = varDeclList.parent.kind === 225 && varDeclList.parent.parent
53399                             ? varDeclList.parent.parent
53400                             : undefined;
53401                         var namesShareScope = container &&
53402                             (container.kind === 223 && ts.isFunctionLike(container.parent) ||
53403                                 container.kind === 250 ||
53404                                 container.kind === 249 ||
53405                                 container.kind === 290);
53406                         if (!namesShareScope) {
53407                             var name = symbolToString(localDeclarationSymbol);
53408                             error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name, name);
53409                         }
53410                     }
53411                 }
53412             }
53413         }
53414         function convertAutoToAny(type) {
53415             return type === autoType ? anyType : type === autoArrayType ? anyArrayType : type;
53416         }
53417         function checkVariableLikeDeclaration(node) {
53418             checkDecorators(node);
53419             if (!ts.isBindingElement(node)) {
53420                 checkSourceElement(node.type);
53421             }
53422             if (!node.name) {
53423                 return;
53424             }
53425             if (node.name.kind === 154) {
53426                 checkComputedPropertyName(node.name);
53427                 if (node.initializer) {
53428                     checkExpressionCached(node.initializer);
53429                 }
53430             }
53431             if (node.kind === 191) {
53432                 if (node.parent.kind === 189 && languageVersion < 99) {
53433                     checkExternalEmitHelpers(node, 4);
53434                 }
53435                 if (node.propertyName && node.propertyName.kind === 154) {
53436                     checkComputedPropertyName(node.propertyName);
53437                 }
53438                 var parent = node.parent.parent;
53439                 var parentType = getTypeForBindingElementParent(parent);
53440                 var name = node.propertyName || node.name;
53441                 if (parentType && !ts.isBindingPattern(name)) {
53442                     var exprType = getLiteralTypeFromPropertyName(name);
53443                     if (isTypeUsableAsPropertyName(exprType)) {
53444                         var nameText = getPropertyNameFromType(exprType);
53445                         var property = getPropertyOfType(parentType, nameText);
53446                         if (property) {
53447                             markPropertyAsReferenced(property, undefined, false);
53448                             checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 102, parentType, property);
53449                         }
53450                     }
53451                 }
53452             }
53453             if (ts.isBindingPattern(node.name)) {
53454                 if (node.name.kind === 190 && languageVersion < 2 && compilerOptions.downlevelIteration) {
53455                     checkExternalEmitHelpers(node, 512);
53456                 }
53457                 ts.forEach(node.name.elements, checkSourceElement);
53458             }
53459             if (node.initializer && ts.getRootDeclaration(node).kind === 156 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) {
53460                 error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation);
53461                 return;
53462             }
53463             if (ts.isBindingPattern(node.name)) {
53464                 var needCheckInitializer = node.initializer && node.parent.parent.kind !== 231;
53465                 var needCheckWidenedType = node.name.elements.length === 0;
53466                 if (needCheckInitializer || needCheckWidenedType) {
53467                     var widenedType = getWidenedTypeForVariableLikeDeclaration(node);
53468                     if (needCheckInitializer) {
53469                         var initializerType = checkExpressionCached(node.initializer);
53470                         if (strictNullChecks && needCheckWidenedType) {
53471                             checkNonNullNonVoidType(initializerType, node);
53472                         }
53473                         else {
53474                             checkTypeAssignableToAndOptionallyElaborate(initializerType, getWidenedTypeForVariableLikeDeclaration(node), node, node.initializer);
53475                         }
53476                     }
53477                     if (needCheckWidenedType) {
53478                         if (ts.isArrayBindingPattern(node.name)) {
53479                             checkIteratedTypeOrElementType(65, widenedType, undefinedType, node);
53480                         }
53481                         else if (strictNullChecks) {
53482                             checkNonNullNonVoidType(widenedType, node);
53483                         }
53484                     }
53485                 }
53486                 return;
53487             }
53488             var symbol = getSymbolOfNode(node);
53489             var type = convertAutoToAny(getTypeOfSymbol(symbol));
53490             if (node === symbol.valueDeclaration) {
53491                 var initializer = ts.getEffectiveInitializer(node);
53492                 if (initializer) {
53493                     var isJSObjectLiteralInitializer = ts.isInJSFile(node) &&
53494                         ts.isObjectLiteralExpression(initializer) &&
53495                         (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) &&
53496                         ts.hasEntries(symbol.exports);
53497                     if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 231) {
53498                         checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, undefined);
53499                     }
53500                 }
53501                 if (symbol.declarations.length > 1) {
53502                     if (ts.some(symbol.declarations, function (d) { return d !== node && ts.isVariableLike(d) && !areDeclarationFlagsIdentical(d, node); })) {
53503                         error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name));
53504                     }
53505                 }
53506             }
53507             else {
53508                 var declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node));
53509                 if (type !== errorType && declarationType !== errorType &&
53510                     !isTypeIdenticalTo(type, declarationType) &&
53511                     !(symbol.flags & 67108864)) {
53512                     errorNextVariableOrPropertyDeclarationMustHaveSameType(symbol.valueDeclaration, type, node, declarationType);
53513                 }
53514                 if (node.initializer) {
53515                     checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, undefined);
53516                 }
53517                 if (!areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) {
53518                     error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name));
53519                 }
53520             }
53521             if (node.kind !== 159 && node.kind !== 158) {
53522                 checkExportsOnMergedDeclarations(node);
53523                 if (node.kind === 242 || node.kind === 191) {
53524                     checkVarDeclaredNamesNotShadowed(node);
53525                 }
53526                 checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
53527                 checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
53528                 if (!compilerOptions.noEmit && languageVersion < 99 && needCollisionCheckForIdentifier(node, node.name, "WeakMap")) {
53529                     potentialWeakMapCollisions.push(node);
53530                 }
53531             }
53532         }
53533         function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) {
53534             var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration);
53535             var message = nextDeclaration.kind === 159 || nextDeclaration.kind === 158
53536                 ? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2
53537                 : ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2;
53538             var declName = ts.declarationNameToString(nextDeclarationName);
53539             var err = error(nextDeclarationName, message, declName, typeToString(firstType), typeToString(nextType));
53540             if (firstDeclaration) {
53541                 ts.addRelatedInfo(err, ts.createDiagnosticForNode(firstDeclaration, ts.Diagnostics._0_was_also_declared_here, declName));
53542             }
53543         }
53544         function areDeclarationFlagsIdentical(left, right) {
53545             if ((left.kind === 156 && right.kind === 242) ||
53546                 (left.kind === 242 && right.kind === 156)) {
53547                 return true;
53548             }
53549             if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) {
53550                 return false;
53551             }
53552             var interestingFlags = 8 |
53553                 16 |
53554                 256 |
53555                 128 |
53556                 64 |
53557                 32;
53558             return ts.getSelectedModifierFlags(left, interestingFlags) === ts.getSelectedModifierFlags(right, interestingFlags);
53559         }
53560         function checkVariableDeclaration(node) {
53561             checkGrammarVariableDeclaration(node);
53562             return checkVariableLikeDeclaration(node);
53563         }
53564         function checkBindingElement(node) {
53565             checkGrammarBindingElement(node);
53566             return checkVariableLikeDeclaration(node);
53567         }
53568         function checkVariableStatement(node) {
53569             if (!checkGrammarDecoratorsAndModifiers(node) && !checkGrammarVariableDeclarationList(node.declarationList))
53570                 checkGrammarForDisallowedLetOrConstStatement(node);
53571             ts.forEach(node.declarationList.declarations, checkSourceElement);
53572         }
53573         function checkExpressionStatement(node) {
53574             checkGrammarStatementInAmbientContext(node);
53575             checkExpression(node.expression);
53576         }
53577         function checkIfStatement(node) {
53578             checkGrammarStatementInAmbientContext(node);
53579             var type = checkTruthinessExpression(node.expression);
53580             checkTestingKnownTruthyCallableType(node.expression, node.thenStatement, type);
53581             checkSourceElement(node.thenStatement);
53582             if (node.thenStatement.kind === 224) {
53583                 error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement);
53584             }
53585             checkSourceElement(node.elseStatement);
53586         }
53587         function checkTestingKnownTruthyCallableType(condExpr, body, type) {
53588             if (!strictNullChecks) {
53589                 return;
53590             }
53591             var testedNode = ts.isIdentifier(condExpr)
53592                 ? condExpr
53593                 : ts.isPropertyAccessExpression(condExpr)
53594                     ? condExpr.name
53595                     : undefined;
53596             if (!testedNode) {
53597                 return;
53598             }
53599             var possiblyFalsy = getFalsyFlags(type);
53600             if (possiblyFalsy) {
53601                 return;
53602             }
53603             var callSignatures = getSignaturesOfType(type, 0);
53604             if (callSignatures.length === 0) {
53605                 return;
53606             }
53607             var testedFunctionSymbol = getSymbolAtLocation(testedNode);
53608             if (!testedFunctionSymbol) {
53609                 return;
53610             }
53611             var functionIsUsedInBody = ts.forEachChild(body, function check(childNode) {
53612                 if (ts.isIdentifier(childNode)) {
53613                     var childSymbol = getSymbolAtLocation(childNode);
53614                     if (childSymbol && childSymbol === testedFunctionSymbol) {
53615                         if (ts.isIdentifier(condExpr)) {
53616                             return true;
53617                         }
53618                         var testedExpression = testedNode.parent;
53619                         var childExpression = childNode.parent;
53620                         while (testedExpression && childExpression) {
53621                             if (ts.isIdentifier(testedExpression) && ts.isIdentifier(childExpression) ||
53622                                 testedExpression.kind === 104 && childExpression.kind === 104) {
53623                                 return getSymbolAtLocation(testedExpression) === getSymbolAtLocation(childExpression);
53624                             }
53625                             if (ts.isPropertyAccessExpression(testedExpression) && ts.isPropertyAccessExpression(childExpression)) {
53626                                 if (getSymbolAtLocation(testedExpression.name) !== getSymbolAtLocation(childExpression.name)) {
53627                                     return false;
53628                                 }
53629                                 childExpression = childExpression.expression;
53630                                 testedExpression = testedExpression.expression;
53631                             }
53632                             else {
53633                                 return false;
53634                             }
53635                         }
53636                     }
53637                 }
53638                 return ts.forEachChild(childNode, check);
53639             });
53640             if (!functionIsUsedInBody) {
53641                 error(condExpr, ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead);
53642             }
53643         }
53644         function checkDoStatement(node) {
53645             checkGrammarStatementInAmbientContext(node);
53646             checkSourceElement(node.statement);
53647             checkTruthinessExpression(node.expression);
53648         }
53649         function checkWhileStatement(node) {
53650             checkGrammarStatementInAmbientContext(node);
53651             checkTruthinessExpression(node.expression);
53652             checkSourceElement(node.statement);
53653         }
53654         function checkTruthinessOfType(type, node) {
53655             if (type.flags & 16384) {
53656                 error(node, ts.Diagnostics.An_expression_of_type_void_cannot_be_tested_for_truthiness);
53657             }
53658             return type;
53659         }
53660         function checkTruthinessExpression(node, checkMode) {
53661             return checkTruthinessOfType(checkExpression(node, checkMode), node);
53662         }
53663         function checkForStatement(node) {
53664             if (!checkGrammarStatementInAmbientContext(node)) {
53665                 if (node.initializer && node.initializer.kind === 243) {
53666                     checkGrammarVariableDeclarationList(node.initializer);
53667                 }
53668             }
53669             if (node.initializer) {
53670                 if (node.initializer.kind === 243) {
53671                     ts.forEach(node.initializer.declarations, checkVariableDeclaration);
53672                 }
53673                 else {
53674                     checkExpression(node.initializer);
53675                 }
53676             }
53677             if (node.condition)
53678                 checkTruthinessExpression(node.condition);
53679             if (node.incrementor)
53680                 checkExpression(node.incrementor);
53681             checkSourceElement(node.statement);
53682             if (node.locals) {
53683                 registerForUnusedIdentifiersCheck(node);
53684             }
53685         }
53686         function checkForOfStatement(node) {
53687             checkGrammarForInOrForOfStatement(node);
53688             if (node.awaitModifier) {
53689                 var functionFlags = ts.getFunctionFlags(ts.getContainingFunction(node));
53690                 if ((functionFlags & (4 | 2)) === 2 && languageVersion < 99) {
53691                     checkExternalEmitHelpers(node, 32768);
53692                 }
53693             }
53694             else if (compilerOptions.downlevelIteration && languageVersion < 2) {
53695                 checkExternalEmitHelpers(node, 256);
53696             }
53697             if (node.initializer.kind === 243) {
53698                 checkForInOrForOfVariableDeclaration(node);
53699             }
53700             else {
53701                 var varExpr = node.initializer;
53702                 var iteratedType = checkRightHandSideOfForOf(node);
53703                 if (varExpr.kind === 192 || varExpr.kind === 193) {
53704                     checkDestructuringAssignment(varExpr, iteratedType || errorType);
53705                 }
53706                 else {
53707                     var leftType = checkExpression(varExpr);
53708                     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);
53709                     if (iteratedType) {
53710                         checkTypeAssignableToAndOptionallyElaborate(iteratedType, leftType, varExpr, node.expression);
53711                     }
53712                 }
53713             }
53714             checkSourceElement(node.statement);
53715             if (node.locals) {
53716                 registerForUnusedIdentifiersCheck(node);
53717             }
53718         }
53719         function checkForInStatement(node) {
53720             checkGrammarForInOrForOfStatement(node);
53721             var rightType = getNonNullableTypeIfNeeded(checkExpression(node.expression));
53722             if (node.initializer.kind === 243) {
53723                 var variable = node.initializer.declarations[0];
53724                 if (variable && ts.isBindingPattern(variable.name)) {
53725                     error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern);
53726                 }
53727                 checkForInOrForOfVariableDeclaration(node);
53728             }
53729             else {
53730                 var varExpr = node.initializer;
53731                 var leftType = checkExpression(varExpr);
53732                 if (varExpr.kind === 192 || varExpr.kind === 193) {
53733                     error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern);
53734                 }
53735                 else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) {
53736                     error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any);
53737                 }
53738                 else {
53739                     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);
53740                 }
53741             }
53742             if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 | 58982400)) {
53743                 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));
53744             }
53745             checkSourceElement(node.statement);
53746             if (node.locals) {
53747                 registerForUnusedIdentifiersCheck(node);
53748             }
53749         }
53750         function checkForInOrForOfVariableDeclaration(iterationStatement) {
53751             var variableDeclarationList = iterationStatement.initializer;
53752             if (variableDeclarationList.declarations.length >= 1) {
53753                 var decl = variableDeclarationList.declarations[0];
53754                 checkVariableDeclaration(decl);
53755             }
53756         }
53757         function checkRightHandSideOfForOf(statement) {
53758             var use = statement.awaitModifier ? 15 : 13;
53759             return checkIteratedTypeOrElementType(use, checkNonNullExpression(statement.expression), undefinedType, statement.expression);
53760         }
53761         function checkIteratedTypeOrElementType(use, inputType, sentType, errorNode) {
53762             if (isTypeAny(inputType)) {
53763                 return inputType;
53764             }
53765             return getIteratedTypeOrElementType(use, inputType, sentType, errorNode, true) || anyType;
53766         }
53767         function getIteratedTypeOrElementType(use, inputType, sentType, errorNode, checkAssignability) {
53768             var allowAsyncIterables = (use & 2) !== 0;
53769             if (inputType === neverType) {
53770                 reportTypeNotIterableError(errorNode, inputType, allowAsyncIterables);
53771                 return undefined;
53772             }
53773             var uplevelIteration = languageVersion >= 2;
53774             var downlevelIteration = !uplevelIteration && compilerOptions.downlevelIteration;
53775             if (uplevelIteration || downlevelIteration || allowAsyncIterables) {
53776                 var iterationTypes = getIterationTypesOfIterable(inputType, use, uplevelIteration ? errorNode : undefined);
53777                 if (checkAssignability) {
53778                     if (iterationTypes) {
53779                         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 :
53780                             use & 32 ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_always_send_0 :
53781                                 use & 64 ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring_will_always_send_0 :
53782                                     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 :
53783                                         undefined;
53784                         if (diagnostic) {
53785                             checkTypeAssignableTo(sentType, iterationTypes.nextType, errorNode, diagnostic);
53786                         }
53787                     }
53788                 }
53789                 if (iterationTypes || uplevelIteration) {
53790                     return iterationTypes && iterationTypes.yieldType;
53791                 }
53792             }
53793             var arrayType = inputType;
53794             var reportedError = false;
53795             var hasStringConstituent = false;
53796             if (use & 4) {
53797                 if (arrayType.flags & 1048576) {
53798                     var arrayTypes = inputType.types;
53799                     var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 132); });
53800                     if (filteredTypes !== arrayTypes) {
53801                         arrayType = getUnionType(filteredTypes, 2);
53802                     }
53803                 }
53804                 else if (arrayType.flags & 132) {
53805                     arrayType = neverType;
53806                 }
53807                 hasStringConstituent = arrayType !== inputType;
53808                 if (hasStringConstituent) {
53809                     if (languageVersion < 1) {
53810                         if (errorNode) {
53811                             error(errorNode, ts.Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher);
53812                             reportedError = true;
53813                         }
53814                     }
53815                     if (arrayType.flags & 131072) {
53816                         return stringType;
53817                     }
53818                 }
53819             }
53820             if (!isArrayLikeType(arrayType)) {
53821                 if (errorNode && !reportedError) {
53822                     var yieldType = getIterationTypeOfIterable(use, 0, inputType, undefined);
53823                     var _a = !(use & 4) || hasStringConstituent
53824                         ? downlevelIteration
53825                             ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true]
53826                             : yieldType
53827                                 ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false]
53828                                 : [ts.Diagnostics.Type_0_is_not_an_array_type, true]
53829                         : downlevelIteration
53830                             ? [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]
53831                             : yieldType
53832                                 ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false]
53833                                 : [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type, true], defaultDiagnostic = _a[0], maybeMissingAwait = _a[1];
53834                     errorAndMaybeSuggestAwait(errorNode, maybeMissingAwait && !!getAwaitedTypeOfPromise(arrayType), defaultDiagnostic, typeToString(arrayType));
53835                 }
53836                 return hasStringConstituent ? stringType : undefined;
53837             }
53838             var arrayElementType = getIndexTypeOfType(arrayType, 1);
53839             if (hasStringConstituent && arrayElementType) {
53840                 if (arrayElementType.flags & 132) {
53841                     return stringType;
53842                 }
53843                 return getUnionType([arrayElementType, stringType], 2);
53844             }
53845             return arrayElementType;
53846         }
53847         function getIterationTypeOfIterable(use, typeKind, inputType, errorNode) {
53848             if (isTypeAny(inputType)) {
53849                 return undefined;
53850             }
53851             var iterationTypes = getIterationTypesOfIterable(inputType, use, errorNode);
53852             return iterationTypes && iterationTypes[getIterationTypesKeyFromIterationTypeKind(typeKind)];
53853         }
53854         function createIterationTypes(yieldType, returnType, nextType) {
53855             if (yieldType === void 0) { yieldType = neverType; }
53856             if (returnType === void 0) { returnType = neverType; }
53857             if (nextType === void 0) { nextType = unknownType; }
53858             if (yieldType.flags & 67359327 &&
53859                 returnType.flags & (1 | 131072 | 2 | 16384 | 32768) &&
53860                 nextType.flags & (1 | 131072 | 2 | 16384 | 32768)) {
53861                 var id = getTypeListId([yieldType, returnType, nextType]);
53862                 var iterationTypes = iterationTypesCache.get(id);
53863                 if (!iterationTypes) {
53864                     iterationTypes = { yieldType: yieldType, returnType: returnType, nextType: nextType };
53865                     iterationTypesCache.set(id, iterationTypes);
53866                 }
53867                 return iterationTypes;
53868             }
53869             return { yieldType: yieldType, returnType: returnType, nextType: nextType };
53870         }
53871         function combineIterationTypes(array) {
53872             var yieldTypes;
53873             var returnTypes;
53874             var nextTypes;
53875             for (var _i = 0, array_10 = array; _i < array_10.length; _i++) {
53876                 var iterationTypes = array_10[_i];
53877                 if (iterationTypes === undefined || iterationTypes === noIterationTypes) {
53878                     continue;
53879                 }
53880                 if (iterationTypes === anyIterationTypes) {
53881                     return anyIterationTypes;
53882                 }
53883                 yieldTypes = ts.append(yieldTypes, iterationTypes.yieldType);
53884                 returnTypes = ts.append(returnTypes, iterationTypes.returnType);
53885                 nextTypes = ts.append(nextTypes, iterationTypes.nextType);
53886             }
53887             if (yieldTypes || returnTypes || nextTypes) {
53888                 return createIterationTypes(yieldTypes && getUnionType(yieldTypes), returnTypes && getUnionType(returnTypes), nextTypes && getIntersectionType(nextTypes));
53889             }
53890             return noIterationTypes;
53891         }
53892         function getCachedIterationTypes(type, cacheKey) {
53893             return type[cacheKey];
53894         }
53895         function setCachedIterationTypes(type, cacheKey, cachedTypes) {
53896             return type[cacheKey] = cachedTypes;
53897         }
53898         function getIterationTypesOfIterable(type, use, errorNode) {
53899             if (isTypeAny(type)) {
53900                 return anyIterationTypes;
53901             }
53902             if (!(type.flags & 1048576)) {
53903                 var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode);
53904                 if (iterationTypes_1 === noIterationTypes) {
53905                     if (errorNode) {
53906                         reportTypeNotIterableError(errorNode, type, !!(use & 2));
53907                     }
53908                     return undefined;
53909                 }
53910                 return iterationTypes_1;
53911             }
53912             var cacheKey = use & 2 ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable";
53913             var cachedTypes = getCachedIterationTypes(type, cacheKey);
53914             if (cachedTypes)
53915                 return cachedTypes === noIterationTypes ? undefined : cachedTypes;
53916             var allIterationTypes;
53917             for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
53918                 var constituent = _a[_i];
53919                 var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode);
53920                 if (iterationTypes_2 === noIterationTypes) {
53921                     if (errorNode) {
53922                         reportTypeNotIterableError(errorNode, type, !!(use & 2));
53923                         errorNode = undefined;
53924                     }
53925                 }
53926                 else {
53927                     allIterationTypes = ts.append(allIterationTypes, iterationTypes_2);
53928                 }
53929             }
53930             var iterationTypes = allIterationTypes ? combineIterationTypes(allIterationTypes) : noIterationTypes;
53931             setCachedIterationTypes(type, cacheKey, iterationTypes);
53932             return iterationTypes === noIterationTypes ? undefined : iterationTypes;
53933         }
53934         function getAsyncFromSyncIterationTypes(iterationTypes, errorNode) {
53935             if (iterationTypes === noIterationTypes)
53936                 return noIterationTypes;
53937             if (iterationTypes === anyIterationTypes)
53938                 return anyIterationTypes;
53939             var yieldType = iterationTypes.yieldType, returnType = iterationTypes.returnType, nextType = iterationTypes.nextType;
53940             return createIterationTypes(getAwaitedType(yieldType, errorNode) || anyType, getAwaitedType(returnType, errorNode) || anyType, nextType);
53941         }
53942         function getIterationTypesOfIterableWorker(type, use, errorNode) {
53943             if (isTypeAny(type)) {
53944                 return anyIterationTypes;
53945             }
53946             if (use & 2) {
53947                 var iterationTypes = getIterationTypesOfIterableCached(type, asyncIterationTypesResolver) ||
53948                     getIterationTypesOfIterableFast(type, asyncIterationTypesResolver);
53949                 if (iterationTypes) {
53950                     return iterationTypes;
53951                 }
53952             }
53953             if (use & 1) {
53954                 var iterationTypes = getIterationTypesOfIterableCached(type, syncIterationTypesResolver) ||
53955                     getIterationTypesOfIterableFast(type, syncIterationTypesResolver);
53956                 if (iterationTypes) {
53957                     if (use & 2) {
53958                         if (iterationTypes !== noIterationTypes) {
53959                             return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", getAsyncFromSyncIterationTypes(iterationTypes, errorNode));
53960                         }
53961                     }
53962                     else {
53963                         return iterationTypes;
53964                     }
53965                 }
53966             }
53967             if (use & 2) {
53968                 var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode);
53969                 if (iterationTypes !== noIterationTypes) {
53970                     return iterationTypes;
53971                 }
53972             }
53973             if (use & 1) {
53974                 var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode);
53975                 if (iterationTypes !== noIterationTypes) {
53976                     if (use & 2) {
53977                         return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes
53978                             ? getAsyncFromSyncIterationTypes(iterationTypes, errorNode)
53979                             : noIterationTypes);
53980                     }
53981                     else {
53982                         return iterationTypes;
53983                     }
53984                 }
53985             }
53986             return noIterationTypes;
53987         }
53988         function getIterationTypesOfIterableCached(type, resolver) {
53989             return getCachedIterationTypes(type, resolver.iterableCacheKey);
53990         }
53991         function getIterationTypesOfGlobalIterableType(globalType, resolver) {
53992             var globalIterationTypes = getIterationTypesOfIterableCached(globalType, resolver) ||
53993                 getIterationTypesOfIterableSlow(globalType, resolver, undefined);
53994             return globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes;
53995         }
53996         function getIterationTypesOfIterableFast(type, resolver) {
53997             var globalType;
53998             if (isReferenceToType(type, globalType = resolver.getGlobalIterableType(false)) ||
53999                 isReferenceToType(type, globalType = resolver.getGlobalIterableIteratorType(false))) {
54000                 var yieldType = getTypeArguments(type)[0];
54001                 var _a = getIterationTypesOfGlobalIterableType(globalType, resolver), returnType = _a.returnType, nextType = _a.nextType;
54002                 return setCachedIterationTypes(type, resolver.iterableCacheKey, createIterationTypes(yieldType, returnType, nextType));
54003             }
54004             if (isReferenceToType(type, resolver.getGlobalGeneratorType(false))) {
54005                 var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2];
54006                 return setCachedIterationTypes(type, resolver.iterableCacheKey, createIterationTypes(yieldType, returnType, nextType));
54007             }
54008         }
54009         function getIterationTypesOfIterableSlow(type, resolver, errorNode) {
54010             var _a;
54011             var method = getPropertyOfType(type, ts.getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName));
54012             var methodType = method && !(method.flags & 16777216) ? getTypeOfSymbol(method) : undefined;
54013             if (isTypeAny(methodType)) {
54014                 return setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes);
54015             }
54016             var signatures = methodType ? getSignaturesOfType(methodType, 0) : undefined;
54017             if (!ts.some(signatures)) {
54018                 return setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes);
54019             }
54020             var iteratorType = getUnionType(ts.map(signatures, getReturnTypeOfSignature), 2);
54021             var iterationTypes = (_a = getIterationTypesOfIterator(iteratorType, resolver, errorNode)) !== null && _a !== void 0 ? _a : noIterationTypes;
54022             return setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes);
54023         }
54024         function reportTypeNotIterableError(errorNode, type, allowAsyncIterables) {
54025             var message = allowAsyncIterables
54026                 ? ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator
54027                 : ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator;
54028             errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type));
54029         }
54030         function getIterationTypesOfIterator(type, resolver, errorNode) {
54031             if (isTypeAny(type)) {
54032                 return anyIterationTypes;
54033             }
54034             var iterationTypes = getIterationTypesOfIteratorCached(type, resolver) ||
54035                 getIterationTypesOfIteratorFast(type, resolver) ||
54036                 getIterationTypesOfIteratorSlow(type, resolver, errorNode);
54037             return iterationTypes === noIterationTypes ? undefined : iterationTypes;
54038         }
54039         function getIterationTypesOfIteratorCached(type, resolver) {
54040             return getCachedIterationTypes(type, resolver.iteratorCacheKey);
54041         }
54042         function getIterationTypesOfIteratorFast(type, resolver) {
54043             var globalType = resolver.getGlobalIterableIteratorType(false);
54044             if (isReferenceToType(type, globalType)) {
54045                 var yieldType = getTypeArguments(type)[0];
54046                 var globalIterationTypes = getIterationTypesOfIteratorCached(globalType, resolver) ||
54047                     getIterationTypesOfIteratorSlow(globalType, resolver, undefined);
54048                 var _a = globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes, returnType = _a.returnType, nextType = _a.nextType;
54049                 return setCachedIterationTypes(type, resolver.iteratorCacheKey, createIterationTypes(yieldType, returnType, nextType));
54050             }
54051             if (isReferenceToType(type, resolver.getGlobalIteratorType(false)) ||
54052                 isReferenceToType(type, resolver.getGlobalGeneratorType(false))) {
54053                 var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2];
54054                 return setCachedIterationTypes(type, resolver.iteratorCacheKey, createIterationTypes(yieldType, returnType, nextType));
54055             }
54056         }
54057         function isIteratorResult(type, kind) {
54058             var doneType = getTypeOfPropertyOfType(type, "done") || falseType;
54059             return isTypeAssignableTo(kind === 0 ? falseType : trueType, doneType);
54060         }
54061         function isYieldIteratorResult(type) {
54062             return isIteratorResult(type, 0);
54063         }
54064         function isReturnIteratorResult(type) {
54065             return isIteratorResult(type, 1);
54066         }
54067         function getIterationTypesOfIteratorResult(type) {
54068             if (isTypeAny(type)) {
54069                 return anyIterationTypes;
54070             }
54071             var cachedTypes = getCachedIterationTypes(type, "iterationTypesOfIteratorResult");
54072             if (cachedTypes) {
54073                 return cachedTypes;
54074             }
54075             if (isReferenceToType(type, getGlobalIteratorYieldResultType(false))) {
54076                 var yieldType_1 = getTypeArguments(type)[0];
54077                 return setCachedIterationTypes(type, "iterationTypesOfIteratorResult", createIterationTypes(yieldType_1, undefined, undefined));
54078             }
54079             if (isReferenceToType(type, getGlobalIteratorReturnResultType(false))) {
54080                 var returnType_1 = getTypeArguments(type)[0];
54081                 return setCachedIterationTypes(type, "iterationTypesOfIteratorResult", createIterationTypes(undefined, returnType_1, undefined));
54082             }
54083             var yieldIteratorResult = filterType(type, isYieldIteratorResult);
54084             var yieldType = yieldIteratorResult !== neverType ? getTypeOfPropertyOfType(yieldIteratorResult, "value") : undefined;
54085             var returnIteratorResult = filterType(type, isReturnIteratorResult);
54086             var returnType = returnIteratorResult !== neverType ? getTypeOfPropertyOfType(returnIteratorResult, "value") : undefined;
54087             if (!yieldType && !returnType) {
54088                 return setCachedIterationTypes(type, "iterationTypesOfIteratorResult", noIterationTypes);
54089             }
54090             return setCachedIterationTypes(type, "iterationTypesOfIteratorResult", createIterationTypes(yieldType, returnType || voidType, undefined));
54091         }
54092         function getIterationTypesOfMethod(type, resolver, methodName, errorNode) {
54093             var method = getPropertyOfType(type, methodName);
54094             if (!method && methodName !== "next") {
54095                 return undefined;
54096             }
54097             var methodType = method && !(methodName === "next" && (method.flags & 16777216))
54098                 ? methodName === "next" ? getTypeOfSymbol(method) : getTypeWithFacts(getTypeOfSymbol(method), 2097152)
54099                 : undefined;
54100             if (isTypeAny(methodType)) {
54101                 return methodName === "next" ? anyIterationTypes : anyIterationTypesExceptNext;
54102             }
54103             var methodSignatures = methodType ? getSignaturesOfType(methodType, 0) : ts.emptyArray;
54104             if (methodSignatures.length === 0) {
54105                 if (errorNode) {
54106                     var diagnostic = methodName === "next"
54107                         ? resolver.mustHaveANextMethodDiagnostic
54108                         : resolver.mustBeAMethodDiagnostic;
54109                     error(errorNode, diagnostic, methodName);
54110                 }
54111                 return methodName === "next" ? anyIterationTypes : undefined;
54112             }
54113             var methodParameterTypes;
54114             var methodReturnTypes;
54115             for (var _i = 0, methodSignatures_1 = methodSignatures; _i < methodSignatures_1.length; _i++) {
54116                 var signature = methodSignatures_1[_i];
54117                 if (methodName !== "throw" && ts.some(signature.parameters)) {
54118                     methodParameterTypes = ts.append(methodParameterTypes, getTypeAtPosition(signature, 0));
54119                 }
54120                 methodReturnTypes = ts.append(methodReturnTypes, getReturnTypeOfSignature(signature));
54121             }
54122             var returnTypes;
54123             var nextType;
54124             if (methodName !== "throw") {
54125                 var methodParameterType = methodParameterTypes ? getUnionType(methodParameterTypes) : unknownType;
54126                 if (methodName === "next") {
54127                     nextType = methodParameterType;
54128                 }
54129                 else if (methodName === "return") {
54130                     var resolvedMethodParameterType = resolver.resolveIterationType(methodParameterType, errorNode) || anyType;
54131                     returnTypes = ts.append(returnTypes, resolvedMethodParameterType);
54132                 }
54133             }
54134             var yieldType;
54135             var methodReturnType = methodReturnTypes ? getUnionType(methodReturnTypes, 2) : neverType;
54136             var resolvedMethodReturnType = resolver.resolveIterationType(methodReturnType, errorNode) || anyType;
54137             var iterationTypes = getIterationTypesOfIteratorResult(resolvedMethodReturnType);
54138             if (iterationTypes === noIterationTypes) {
54139                 if (errorNode) {
54140                     error(errorNode, resolver.mustHaveAValueDiagnostic, methodName);
54141                 }
54142                 yieldType = anyType;
54143                 returnTypes = ts.append(returnTypes, anyType);
54144             }
54145             else {
54146                 yieldType = iterationTypes.yieldType;
54147                 returnTypes = ts.append(returnTypes, iterationTypes.returnType);
54148             }
54149             return createIterationTypes(yieldType, getUnionType(returnTypes), nextType);
54150         }
54151         function getIterationTypesOfIteratorSlow(type, resolver, errorNode) {
54152             var iterationTypes = combineIterationTypes([
54153                 getIterationTypesOfMethod(type, resolver, "next", errorNode),
54154                 getIterationTypesOfMethod(type, resolver, "return", errorNode),
54155                 getIterationTypesOfMethod(type, resolver, "throw", errorNode),
54156             ]);
54157             return setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes);
54158         }
54159         function getIterationTypeOfGeneratorFunctionReturnType(kind, returnType, isAsyncGenerator) {
54160             if (isTypeAny(returnType)) {
54161                 return undefined;
54162             }
54163             var iterationTypes = getIterationTypesOfGeneratorFunctionReturnType(returnType, isAsyncGenerator);
54164             return iterationTypes && iterationTypes[getIterationTypesKeyFromIterationTypeKind(kind)];
54165         }
54166         function getIterationTypesOfGeneratorFunctionReturnType(type, isAsyncGenerator) {
54167             if (isTypeAny(type)) {
54168                 return anyIterationTypes;
54169             }
54170             var use = isAsyncGenerator ? 2 : 1;
54171             var resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver;
54172             return getIterationTypesOfIterable(type, use, undefined) ||
54173                 getIterationTypesOfIterator(type, resolver, undefined);
54174         }
54175         function checkBreakOrContinueStatement(node) {
54176             if (!checkGrammarStatementInAmbientContext(node))
54177                 checkGrammarBreakOrContinueStatement(node);
54178         }
54179         function unwrapReturnType(returnType, functionFlags) {
54180             var _a, _b;
54181             var isGenerator = !!(functionFlags & 1);
54182             var isAsync = !!(functionFlags & 2);
54183             return isGenerator ? (_a = getIterationTypeOfGeneratorFunctionReturnType(1, returnType, isAsync)) !== null && _a !== void 0 ? _a : errorType :
54184                 isAsync ? (_b = getAwaitedType(returnType)) !== null && _b !== void 0 ? _b : errorType :
54185                     returnType;
54186         }
54187         function isUnwrappedReturnTypeVoidOrAny(func, returnType) {
54188             var unwrappedReturnType = unwrapReturnType(returnType, ts.getFunctionFlags(func));
54189             return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 | 3);
54190         }
54191         function checkReturnStatement(node) {
54192             var _a;
54193             if (checkGrammarStatementInAmbientContext(node)) {
54194                 return;
54195             }
54196             var func = ts.getContainingFunction(node);
54197             if (!func) {
54198                 grammarErrorOnFirstToken(node, ts.Diagnostics.A_return_statement_can_only_be_used_within_a_function_body);
54199                 return;
54200             }
54201             var signature = getSignatureFromDeclaration(func);
54202             var returnType = getReturnTypeOfSignature(signature);
54203             var functionFlags = ts.getFunctionFlags(func);
54204             if (strictNullChecks || node.expression || returnType.flags & 131072) {
54205                 var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType;
54206                 if (func.kind === 164) {
54207                     if (node.expression) {
54208                         error(node, ts.Diagnostics.Setters_cannot_return_a_value);
54209                     }
54210                 }
54211                 else if (func.kind === 162) {
54212                     if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) {
54213                         error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class);
54214                     }
54215                 }
54216                 else if (getReturnTypeFromAnnotation(func)) {
54217                     var unwrappedReturnType = (_a = unwrapReturnType(returnType, functionFlags)) !== null && _a !== void 0 ? _a : returnType;
54218                     var unwrappedExprType = functionFlags & 2
54219                         ? 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)
54220                         : exprType;
54221                     if (unwrappedReturnType) {
54222                         checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, node, node.expression);
54223                     }
54224                 }
54225             }
54226             else if (func.kind !== 162 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) {
54227                 error(node, ts.Diagnostics.Not_all_code_paths_return_a_value);
54228             }
54229         }
54230         function checkWithStatement(node) {
54231             if (!checkGrammarStatementInAmbientContext(node)) {
54232                 if (node.flags & 32768) {
54233                     grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block);
54234                 }
54235             }
54236             checkExpression(node.expression);
54237             var sourceFile = ts.getSourceFileOfNode(node);
54238             if (!hasParseDiagnostics(sourceFile)) {
54239                 var start = ts.getSpanOfTokenAtPosition(sourceFile, node.pos).start;
54240                 var end = node.statement.pos;
54241                 grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any);
54242             }
54243         }
54244         function checkSwitchStatement(node) {
54245             checkGrammarStatementInAmbientContext(node);
54246             var firstDefaultClause;
54247             var hasDuplicateDefaultClause = false;
54248             var expressionType = checkExpression(node.expression);
54249             var expressionIsLiteral = isLiteralType(expressionType);
54250             ts.forEach(node.caseBlock.clauses, function (clause) {
54251                 if (clause.kind === 278 && !hasDuplicateDefaultClause) {
54252                     if (firstDefaultClause === undefined) {
54253                         firstDefaultClause = clause;
54254                     }
54255                     else {
54256                         grammarErrorOnNode(clause, ts.Diagnostics.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement);
54257                         hasDuplicateDefaultClause = true;
54258                     }
54259                 }
54260                 if (produceDiagnostics && clause.kind === 277) {
54261                     var caseType = checkExpression(clause.expression);
54262                     var caseIsLiteral = isLiteralType(caseType);
54263                     var comparedExpressionType = expressionType;
54264                     if (!caseIsLiteral || !expressionIsLiteral) {
54265                         caseType = caseIsLiteral ? getBaseTypeOfLiteralType(caseType) : caseType;
54266                         comparedExpressionType = getBaseTypeOfLiteralType(expressionType);
54267                     }
54268                     if (!isTypeEqualityComparableTo(comparedExpressionType, caseType)) {
54269                         checkTypeComparableTo(caseType, comparedExpressionType, clause.expression, undefined);
54270                     }
54271                 }
54272                 ts.forEach(clause.statements, checkSourceElement);
54273                 if (compilerOptions.noFallthroughCasesInSwitch && clause.fallthroughFlowNode && isReachableFlowNode(clause.fallthroughFlowNode)) {
54274                     error(clause, ts.Diagnostics.Fallthrough_case_in_switch);
54275                 }
54276             });
54277             if (node.caseBlock.locals) {
54278                 registerForUnusedIdentifiersCheck(node.caseBlock);
54279             }
54280         }
54281         function checkLabeledStatement(node) {
54282             if (!checkGrammarStatementInAmbientContext(node)) {
54283                 ts.findAncestor(node.parent, function (current) {
54284                     if (ts.isFunctionLike(current)) {
54285                         return "quit";
54286                     }
54287                     if (current.kind === 238 && current.label.escapedText === node.label.escapedText) {
54288                         grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label));
54289                         return true;
54290                     }
54291                     return false;
54292                 });
54293             }
54294             checkSourceElement(node.statement);
54295         }
54296         function checkThrowStatement(node) {
54297             if (!checkGrammarStatementInAmbientContext(node)) {
54298                 if (node.expression === undefined) {
54299                     grammarErrorAfterFirstToken(node, ts.Diagnostics.Line_break_not_permitted_here);
54300                 }
54301             }
54302             if (node.expression) {
54303                 checkExpression(node.expression);
54304             }
54305         }
54306         function checkTryStatement(node) {
54307             checkGrammarStatementInAmbientContext(node);
54308             checkBlock(node.tryBlock);
54309             var catchClause = node.catchClause;
54310             if (catchClause) {
54311                 if (catchClause.variableDeclaration) {
54312                     if (catchClause.variableDeclaration.type) {
54313                         grammarErrorOnFirstToken(catchClause.variableDeclaration.type, ts.Diagnostics.Catch_clause_variable_cannot_have_a_type_annotation);
54314                     }
54315                     else if (catchClause.variableDeclaration.initializer) {
54316                         grammarErrorOnFirstToken(catchClause.variableDeclaration.initializer, ts.Diagnostics.Catch_clause_variable_cannot_have_an_initializer);
54317                     }
54318                     else {
54319                         var blockLocals_1 = catchClause.block.locals;
54320                         if (blockLocals_1) {
54321                             ts.forEachKey(catchClause.locals, function (caughtName) {
54322                                 var blockLocal = blockLocals_1.get(caughtName);
54323                                 if (blockLocal && (blockLocal.flags & 2) !== 0) {
54324                                     grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName);
54325                                 }
54326                             });
54327                         }
54328                     }
54329                 }
54330                 checkBlock(catchClause.block);
54331             }
54332             if (node.finallyBlock) {
54333                 checkBlock(node.finallyBlock);
54334             }
54335         }
54336         function checkIndexConstraints(type) {
54337             var declaredNumberIndexer = getIndexDeclarationOfSymbol(type.symbol, 1);
54338             var declaredStringIndexer = getIndexDeclarationOfSymbol(type.symbol, 0);
54339             var stringIndexType = getIndexTypeOfType(type, 0);
54340             var numberIndexType = getIndexTypeOfType(type, 1);
54341             if (stringIndexType || numberIndexType) {
54342                 ts.forEach(getPropertiesOfObjectType(type), function (prop) {
54343                     var propType = getTypeOfSymbol(prop);
54344                     checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0);
54345                     checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1);
54346                 });
54347                 var classDeclaration = type.symbol.valueDeclaration;
54348                 if (ts.getObjectFlags(type) & 1 && ts.isClassLike(classDeclaration)) {
54349                     for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) {
54350                         var member = _a[_i];
54351                         if (!ts.hasModifier(member, 32) && hasNonBindableDynamicName(member)) {
54352                             var symbol = getSymbolOfNode(member);
54353                             var propType = getTypeOfSymbol(symbol);
54354                             checkIndexConstraintForProperty(symbol, propType, type, declaredStringIndexer, stringIndexType, 0);
54355                             checkIndexConstraintForProperty(symbol, propType, type, declaredNumberIndexer, numberIndexType, 1);
54356                         }
54357                     }
54358                 }
54359             }
54360             var errorNode;
54361             if (stringIndexType && numberIndexType) {
54362                 errorNode = declaredNumberIndexer || declaredStringIndexer;
54363                 if (!errorNode && (ts.getObjectFlags(type) & 2)) {
54364                     var someBaseTypeHasBothIndexers = ts.forEach(getBaseTypes(type), function (base) { return getIndexTypeOfType(base, 0) && getIndexTypeOfType(base, 1); });
54365                     errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0];
54366                 }
54367             }
54368             if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) {
54369                 error(errorNode, ts.Diagnostics.Numeric_index_type_0_is_not_assignable_to_string_index_type_1, typeToString(numberIndexType), typeToString(stringIndexType));
54370             }
54371             function checkIndexConstraintForProperty(prop, propertyType, containingType, indexDeclaration, indexType, indexKind) {
54372                 if (!indexType || ts.isKnownSymbol(prop)) {
54373                     return;
54374                 }
54375                 var propDeclaration = prop.valueDeclaration;
54376                 var name = propDeclaration && ts.getNameOfDeclaration(propDeclaration);
54377                 if (name && ts.isPrivateIdentifier(name)) {
54378                     return;
54379                 }
54380                 if (indexKind === 1 && !(name ? isNumericName(name) : isNumericLiteralName(prop.escapedName))) {
54381                     return;
54382                 }
54383                 var errorNode;
54384                 if (propDeclaration && name &&
54385                     (propDeclaration.kind === 209 ||
54386                         name.kind === 154 ||
54387                         prop.parent === containingType.symbol)) {
54388                     errorNode = propDeclaration;
54389                 }
54390                 else if (indexDeclaration) {
54391                     errorNode = indexDeclaration;
54392                 }
54393                 else if (ts.getObjectFlags(containingType) & 2) {
54394                     var someBaseClassHasBothPropertyAndIndexer = ts.forEach(getBaseTypes(containingType), function (base) { return getPropertyOfObjectType(base, prop.escapedName) && getIndexTypeOfType(base, indexKind); });
54395                     errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0];
54396                 }
54397                 if (errorNode && !isTypeAssignableTo(propertyType, indexType)) {
54398                     var errorMessage = indexKind === 0
54399                         ? ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_string_index_type_2
54400                         : ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2;
54401                     error(errorNode, errorMessage, symbolToString(prop), typeToString(propertyType), typeToString(indexType));
54402                 }
54403             }
54404         }
54405         function checkTypeNameIsReserved(name, message) {
54406             switch (name.escapedText) {
54407                 case "any":
54408                 case "unknown":
54409                 case "number":
54410                 case "bigint":
54411                 case "boolean":
54412                 case "string":
54413                 case "symbol":
54414                 case "void":
54415                 case "object":
54416                     error(name, message, name.escapedText);
54417             }
54418         }
54419         function checkClassNameCollisionWithObject(name) {
54420             if (languageVersion === 1 && name.escapedText === "Object"
54421                 && moduleKind < ts.ModuleKind.ES2015) {
54422                 error(name, ts.Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ts.ModuleKind[moduleKind]);
54423             }
54424         }
54425         function checkTypeParameters(typeParameterDeclarations) {
54426             if (typeParameterDeclarations) {
54427                 var seenDefault = false;
54428                 for (var i = 0; i < typeParameterDeclarations.length; i++) {
54429                     var node = typeParameterDeclarations[i];
54430                     checkTypeParameter(node);
54431                     if (produceDiagnostics) {
54432                         if (node.default) {
54433                             seenDefault = true;
54434                             checkTypeParametersNotReferenced(node.default, typeParameterDeclarations, i);
54435                         }
54436                         else if (seenDefault) {
54437                             error(node, ts.Diagnostics.Required_type_parameters_may_not_follow_optional_type_parameters);
54438                         }
54439                         for (var j = 0; j < i; j++) {
54440                             if (typeParameterDeclarations[j].symbol === node.symbol) {
54441                                 error(node.name, ts.Diagnostics.Duplicate_identifier_0, ts.declarationNameToString(node.name));
54442                             }
54443                         }
54444                     }
54445                 }
54446             }
54447         }
54448         function checkTypeParametersNotReferenced(root, typeParameters, index) {
54449             visit(root);
54450             function visit(node) {
54451                 if (node.kind === 169) {
54452                     var type = getTypeFromTypeReference(node);
54453                     if (type.flags & 262144) {
54454                         for (var i = index; i < typeParameters.length; i++) {
54455                             if (type.symbol === getSymbolOfNode(typeParameters[i])) {
54456                                 error(node, ts.Diagnostics.Type_parameter_defaults_can_only_reference_previously_declared_type_parameters);
54457                             }
54458                         }
54459                     }
54460                 }
54461                 ts.forEachChild(node, visit);
54462             }
54463         }
54464         function checkTypeParameterListsIdentical(symbol) {
54465             if (symbol.declarations.length === 1) {
54466                 return;
54467             }
54468             var links = getSymbolLinks(symbol);
54469             if (!links.typeParametersChecked) {
54470                 links.typeParametersChecked = true;
54471                 var declarations = getClassOrInterfaceDeclarationsOfSymbol(symbol);
54472                 if (declarations.length <= 1) {
54473                     return;
54474                 }
54475                 var type = getDeclaredTypeOfSymbol(symbol);
54476                 if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) {
54477                     var name = symbolToString(symbol);
54478                     for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
54479                         var declaration = declarations_6[_i];
54480                         error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name);
54481                     }
54482                 }
54483             }
54484         }
54485         function areTypeParametersIdentical(declarations, targetParameters) {
54486             var maxTypeArgumentCount = ts.length(targetParameters);
54487             var minTypeArgumentCount = getMinTypeArgumentCount(targetParameters);
54488             for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
54489                 var declaration = declarations_7[_i];
54490                 var sourceParameters = ts.getEffectiveTypeParameterDeclarations(declaration);
54491                 var numTypeParameters = sourceParameters.length;
54492                 if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) {
54493                     return false;
54494                 }
54495                 for (var i = 0; i < numTypeParameters; i++) {
54496                     var source = sourceParameters[i];
54497                     var target = targetParameters[i];
54498                     if (source.name.escapedText !== target.symbol.escapedName) {
54499                         return false;
54500                     }
54501                     var constraint = ts.getEffectiveConstraintOfTypeParameter(source);
54502                     var sourceConstraint = constraint && getTypeFromTypeNode(constraint);
54503                     var targetConstraint = getConstraintOfTypeParameter(target);
54504                     if (sourceConstraint && targetConstraint && !isTypeIdenticalTo(sourceConstraint, targetConstraint)) {
54505                         return false;
54506                     }
54507                     var sourceDefault = source.default && getTypeFromTypeNode(source.default);
54508                     var targetDefault = getDefaultFromTypeParameter(target);
54509                     if (sourceDefault && targetDefault && !isTypeIdenticalTo(sourceDefault, targetDefault)) {
54510                         return false;
54511                     }
54512                 }
54513             }
54514             return true;
54515         }
54516         function checkClassExpression(node) {
54517             checkClassLikeDeclaration(node);
54518             checkNodeDeferred(node);
54519             return getTypeOfSymbol(getSymbolOfNode(node));
54520         }
54521         function checkClassExpressionDeferred(node) {
54522             ts.forEach(node.members, checkSourceElement);
54523             registerForUnusedIdentifiersCheck(node);
54524         }
54525         function checkClassDeclaration(node) {
54526             if (!node.name && !ts.hasModifier(node, 512)) {
54527                 grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name);
54528             }
54529             checkClassLikeDeclaration(node);
54530             ts.forEach(node.members, checkSourceElement);
54531             registerForUnusedIdentifiersCheck(node);
54532         }
54533         function checkClassLikeDeclaration(node) {
54534             checkGrammarClassLikeDeclaration(node);
54535             checkDecorators(node);
54536             if (node.name) {
54537                 checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0);
54538                 checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
54539                 checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
54540                 if (!(node.flags & 8388608)) {
54541                     checkClassNameCollisionWithObject(node.name);
54542                 }
54543             }
54544             checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node));
54545             checkExportsOnMergedDeclarations(node);
54546             var symbol = getSymbolOfNode(node);
54547             var type = getDeclaredTypeOfSymbol(symbol);
54548             var typeWithThis = getTypeWithThisArgument(type);
54549             var staticType = getTypeOfSymbol(symbol);
54550             checkTypeParameterListsIdentical(symbol);
54551             checkClassForDuplicateDeclarations(node);
54552             if (!(node.flags & 8388608)) {
54553                 checkClassForStaticPropertyNameConflicts(node);
54554             }
54555             var baseTypeNode = ts.getEffectiveBaseTypeNode(node);
54556             if (baseTypeNode) {
54557                 ts.forEach(baseTypeNode.typeArguments, checkSourceElement);
54558                 if (languageVersion < 2) {
54559                     checkExternalEmitHelpers(baseTypeNode.parent, 1);
54560                 }
54561                 var extendsNode = ts.getClassExtendsHeritageElement(node);
54562                 if (extendsNode && extendsNode !== baseTypeNode) {
54563                     checkExpression(extendsNode.expression);
54564                 }
54565                 var baseTypes = getBaseTypes(type);
54566                 if (baseTypes.length && produceDiagnostics) {
54567                     var baseType_1 = baseTypes[0];
54568                     var baseConstructorType = getBaseConstructorTypeOfClass(type);
54569                     var staticBaseType = getApparentType(baseConstructorType);
54570                     checkBaseTypeAccessibility(staticBaseType, baseTypeNode);
54571                     checkSourceElement(baseTypeNode.expression);
54572                     if (ts.some(baseTypeNode.typeArguments)) {
54573                         ts.forEach(baseTypeNode.typeArguments, checkSourceElement);
54574                         for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); _i < _a.length; _i++) {
54575                             var constructor = _a[_i];
54576                             if (!checkTypeArgumentConstraints(baseTypeNode, constructor.typeParameters)) {
54577                                 break;
54578                             }
54579                         }
54580                     }
54581                     var baseWithThis = getTypeWithThisArgument(baseType_1, type.thisType);
54582                     if (!checkTypeAssignableTo(typeWithThis, baseWithThis, undefined)) {
54583                         issueMemberSpecificError(node, typeWithThis, baseWithThis, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1);
54584                     }
54585                     else {
54586                         checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1);
54587                     }
54588                     if (baseConstructorType.flags & 8650752 && !isMixinConstructorType(staticType)) {
54589                         error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any);
54590                     }
54591                     if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32) && !(baseConstructorType.flags & 8650752)) {
54592                         var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode);
54593                         if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && !isTypeIdenticalTo(getReturnTypeOfSignature(sig), baseType_1); })) {
54594                             error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type);
54595                         }
54596                     }
54597                     checkKindsOfPropertyMemberOverrides(type, baseType_1);
54598                 }
54599             }
54600             var implementedTypeNodes = ts.getEffectiveImplementsTypeNodes(node);
54601             if (implementedTypeNodes) {
54602                 for (var _b = 0, implementedTypeNodes_1 = implementedTypeNodes; _b < implementedTypeNodes_1.length; _b++) {
54603                     var typeRefNode = implementedTypeNodes_1[_b];
54604                     if (!ts.isEntityNameExpression(typeRefNode.expression)) {
54605                         error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments);
54606                     }
54607                     checkTypeReferenceNode(typeRefNode);
54608                     if (produceDiagnostics) {
54609                         var t = getReducedType(getTypeFromTypeNode(typeRefNode));
54610                         if (t !== errorType) {
54611                             if (isValidBaseType(t)) {
54612                                 var genericDiag = t.symbol && t.symbol.flags & 32 ?
54613                                     ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass :
54614                                     ts.Diagnostics.Class_0_incorrectly_implements_interface_1;
54615                                 var baseWithThis = getTypeWithThisArgument(t, type.thisType);
54616                                 if (!checkTypeAssignableTo(typeWithThis, baseWithThis, undefined)) {
54617                                     issueMemberSpecificError(node, typeWithThis, baseWithThis, genericDiag);
54618                                 }
54619                             }
54620                             else {
54621                                 error(typeRefNode, ts.Diagnostics.A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_members);
54622                             }
54623                         }
54624                     }
54625                 }
54626             }
54627             if (produceDiagnostics) {
54628                 checkIndexConstraints(type);
54629                 checkTypeForDuplicateIndexSignatures(node);
54630                 checkPropertyInitialization(node);
54631             }
54632         }
54633         function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
54634             var issuedMemberError = false;
54635             var _loop_19 = function (member) {
54636                 if (ts.hasStaticModifier(member)) {
54637                     return "continue";
54638                 }
54639                 var declaredProp = member.name && getSymbolAtLocation(member.name) || getSymbolAtLocation(member);
54640                 if (declaredProp) {
54641                     var prop = getPropertyOfType(typeWithThis, declaredProp.escapedName);
54642                     var baseProp = getPropertyOfType(baseWithThis, declaredProp.escapedName);
54643                     if (prop && baseProp) {
54644                         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)); };
54645                         if (!checkTypeAssignableTo(getTypeOfSymbol(prop), getTypeOfSymbol(baseProp), member.name || member, undefined, rootChain)) {
54646                             issuedMemberError = true;
54647                         }
54648                     }
54649                 }
54650             };
54651             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
54652                 var member = _a[_i];
54653                 _loop_19(member);
54654             }
54655             if (!issuedMemberError) {
54656                 checkTypeAssignableTo(typeWithThis, baseWithThis, node.name || node, broadDiag);
54657             }
54658         }
54659         function checkBaseTypeAccessibility(type, node) {
54660             var signatures = getSignaturesOfType(type, 1);
54661             if (signatures.length) {
54662                 var declaration = signatures[0].declaration;
54663                 if (declaration && ts.hasModifier(declaration, 8)) {
54664                     var typeClassDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol);
54665                     if (!isNodeWithinClass(node, typeClassDeclaration)) {
54666                         error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, getFullyQualifiedName(type.symbol));
54667                     }
54668                 }
54669             }
54670         }
54671         function getTargetSymbol(s) {
54672             return ts.getCheckFlags(s) & 1 ? s.target : s;
54673         }
54674         function getClassOrInterfaceDeclarationsOfSymbol(symbol) {
54675             return ts.filter(symbol.declarations, function (d) {
54676                 return d.kind === 245 || d.kind === 246;
54677             });
54678         }
54679         function checkKindsOfPropertyMemberOverrides(type, baseType) {
54680             var baseProperties = getPropertiesOfType(baseType);
54681             basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) {
54682                 var baseProperty = baseProperties_1[_i];
54683                 var base = getTargetSymbol(baseProperty);
54684                 if (base.flags & 4194304) {
54685                     continue;
54686                 }
54687                 var baseSymbol = getPropertyOfObjectType(type, base.escapedName);
54688                 if (!baseSymbol) {
54689                     continue;
54690                 }
54691                 var derived = getTargetSymbol(baseSymbol);
54692                 var baseDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(base);
54693                 ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration.");
54694                 if (derived === base) {
54695                     var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol);
54696                     if (baseDeclarationFlags & 128 && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128))) {
54697                         for (var _a = 0, _b = getBaseTypes(type); _a < _b.length; _a++) {
54698                             var otherBaseType = _b[_a];
54699                             if (otherBaseType === baseType)
54700                                 continue;
54701                             var baseSymbol_1 = getPropertyOfObjectType(otherBaseType, base.escapedName);
54702                             var derivedElsewhere = baseSymbol_1 && getTargetSymbol(baseSymbol_1);
54703                             if (derivedElsewhere && derivedElsewhere !== base) {
54704                                 continue basePropertyCheck;
54705                             }
54706                         }
54707                         if (derivedClassDecl.kind === 214) {
54708                             error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType));
54709                         }
54710                         else {
54711                             error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType));
54712                         }
54713                     }
54714                 }
54715                 else {
54716                     var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived);
54717                     if (baseDeclarationFlags & 8 || derivedDeclarationFlags & 8) {
54718                         continue;
54719                     }
54720                     var errorMessage = void 0;
54721                     var basePropertyFlags = base.flags & 98308;
54722                     var derivedPropertyFlags = derived.flags & 98308;
54723                     if (basePropertyFlags && derivedPropertyFlags) {
54724                         if (!compilerOptions.useDefineForClassFields
54725                             || baseDeclarationFlags & 128 && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer)
54726                             || base.valueDeclaration && base.valueDeclaration.parent.kind === 246
54727                             || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) {
54728                             continue;
54729                         }
54730                         var overriddenInstanceProperty = basePropertyFlags !== 4 && derivedPropertyFlags === 4;
54731                         var overriddenInstanceAccessor = basePropertyFlags === 4 && derivedPropertyFlags !== 4;
54732                         if (overriddenInstanceProperty || overriddenInstanceAccessor) {
54733                             var errorMessage_1 = overriddenInstanceProperty ?
54734                                 ts.Diagnostics._0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property :
54735                                 ts.Diagnostics._0_is_defined_as_a_property_in_class_1_but_is_overridden_here_in_2_as_an_accessor;
54736                             error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType), typeToString(type));
54737                         }
54738                         else {
54739                             var uninitialized = ts.find(derived.declarations, function (d) { return d.kind === 159 && !d.initializer; });
54740                             if (uninitialized
54741                                 && !(derived.flags & 33554432)
54742                                 && !(baseDeclarationFlags & 128)
54743                                 && !(derivedDeclarationFlags & 128)
54744                                 && !derived.declarations.some(function (d) { return !!(d.flags & 8388608); })) {
54745                                 var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol));
54746                                 var propName = uninitialized.name;
54747                                 if (uninitialized.exclamationToken
54748                                     || !constructor
54749                                     || !ts.isIdentifier(propName)
54750                                     || !strictNullChecks
54751                                     || !isPropertyInitializedInConstructor(propName, type, constructor)) {
54752                                     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;
54753                                     error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_2, symbolToString(base), typeToString(baseType));
54754                                 }
54755                             }
54756                         }
54757                         continue;
54758                     }
54759                     else if (isPrototypeProperty(base)) {
54760                         if (isPrototypeProperty(derived) || derived.flags & 4) {
54761                             continue;
54762                         }
54763                         else {
54764                             ts.Debug.assert(!!(derived.flags & 98304));
54765                             errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor;
54766                         }
54767                     }
54768                     else if (base.flags & 98304) {
54769                         errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function;
54770                     }
54771                     else {
54772                         errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function;
54773                     }
54774                     error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type));
54775                 }
54776             }
54777         }
54778         function getNonInterhitedProperties(type, baseTypes, properties) {
54779             if (!ts.length(baseTypes)) {
54780                 return properties;
54781             }
54782             var seen = ts.createUnderscoreEscapedMap();
54783             ts.forEach(properties, function (p) { seen.set(p.escapedName, p); });
54784             for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) {
54785                 var base = baseTypes_2[_i];
54786                 var properties_5 = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
54787                 for (var _a = 0, properties_4 = properties_5; _a < properties_4.length; _a++) {
54788                     var prop = properties_4[_a];
54789                     var existing = seen.get(prop.escapedName);
54790                     if (existing && !isPropertyIdenticalTo(existing, prop)) {
54791                         seen.delete(prop.escapedName);
54792                     }
54793                 }
54794             }
54795             return ts.arrayFrom(seen.values());
54796         }
54797         function checkInheritedPropertiesAreIdentical(type, typeNode) {
54798             var baseTypes = getBaseTypes(type);
54799             if (baseTypes.length < 2) {
54800                 return true;
54801             }
54802             var seen = ts.createUnderscoreEscapedMap();
54803             ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen.set(p.escapedName, { prop: p, containingType: type }); });
54804             var ok = true;
54805             for (var _i = 0, baseTypes_3 = baseTypes; _i < baseTypes_3.length; _i++) {
54806                 var base = baseTypes_3[_i];
54807                 var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
54808                 for (var _a = 0, properties_6 = properties; _a < properties_6.length; _a++) {
54809                     var prop = properties_6[_a];
54810                     var existing = seen.get(prop.escapedName);
54811                     if (!existing) {
54812                         seen.set(prop.escapedName, { prop: prop, containingType: base });
54813                     }
54814                     else {
54815                         var isInheritedProperty = existing.containingType !== type;
54816                         if (isInheritedProperty && !isPropertyIdenticalTo(existing.prop, prop)) {
54817                             ok = false;
54818                             var typeName1 = typeToString(existing.containingType);
54819                             var typeName2 = typeToString(base);
54820                             var errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Named_property_0_of_types_1_and_2_are_not_identical, symbolToString(prop), typeName1, typeName2);
54821                             errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Interface_0_cannot_simultaneously_extend_types_1_and_2, typeToString(type), typeName1, typeName2);
54822                             diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(typeNode, errorInfo));
54823                         }
54824                     }
54825                 }
54826             }
54827             return ok;
54828         }
54829         function checkPropertyInitialization(node) {
54830             if (!strictNullChecks || !strictPropertyInitialization || node.flags & 8388608) {
54831                 return;
54832             }
54833             var constructor = findConstructorDeclaration(node);
54834             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
54835                 var member = _a[_i];
54836                 if (ts.getModifierFlags(member) & 2) {
54837                     continue;
54838                 }
54839                 if (isInstancePropertyWithoutInitializer(member)) {
54840                     var propName = member.name;
54841                     if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName)) {
54842                         var type = getTypeOfSymbol(getSymbolOfNode(member));
54843                         if (!(type.flags & 3 || getFalsyFlags(type) & 32768)) {
54844                             if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) {
54845                                 error(member.name, ts.Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor, ts.declarationNameToString(propName));
54846                             }
54847                         }
54848                     }
54849                 }
54850             }
54851         }
54852         function isInstancePropertyWithoutInitializer(node) {
54853             return node.kind === 159 &&
54854                 !ts.hasModifier(node, 32 | 128) &&
54855                 !node.exclamationToken &&
54856                 !node.initializer;
54857         }
54858         function isPropertyInitializedInConstructor(propName, propType, constructor) {
54859             var reference = ts.createPropertyAccess(ts.createThis(), propName);
54860             reference.expression.parent = reference;
54861             reference.parent = constructor;
54862             reference.flowNode = constructor.returnFlowNode;
54863             var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType));
54864             return !(getFalsyFlags(flowType) & 32768);
54865         }
54866         function checkInterfaceDeclaration(node) {
54867             if (!checkGrammarDecoratorsAndModifiers(node))
54868                 checkGrammarInterfaceDeclaration(node);
54869             checkTypeParameters(node.typeParameters);
54870             if (produceDiagnostics) {
54871                 checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0);
54872                 checkExportsOnMergedDeclarations(node);
54873                 var symbol = getSymbolOfNode(node);
54874                 checkTypeParameterListsIdentical(symbol);
54875                 var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 246);
54876                 if (node === firstInterfaceDecl) {
54877                     var type = getDeclaredTypeOfSymbol(symbol);
54878                     var typeWithThis = getTypeWithThisArgument(type);
54879                     if (checkInheritedPropertiesAreIdentical(type, node.name)) {
54880                         for (var _i = 0, _a = getBaseTypes(type); _i < _a.length; _i++) {
54881                             var baseType = _a[_i];
54882                             checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1);
54883                         }
54884                         checkIndexConstraints(type);
54885                     }
54886                 }
54887                 checkObjectTypeForDuplicateDeclarations(node);
54888             }
54889             ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) {
54890                 if (!ts.isEntityNameExpression(heritageElement.expression)) {
54891                     error(heritageElement.expression, ts.Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments);
54892                 }
54893                 checkTypeReferenceNode(heritageElement);
54894             });
54895             ts.forEach(node.members, checkSourceElement);
54896             if (produceDiagnostics) {
54897                 checkTypeForDuplicateIndexSignatures(node);
54898                 registerForUnusedIdentifiersCheck(node);
54899             }
54900         }
54901         function checkTypeAliasDeclaration(node) {
54902             checkGrammarDecoratorsAndModifiers(node);
54903             checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0);
54904             checkExportsOnMergedDeclarations(node);
54905             checkTypeParameters(node.typeParameters);
54906             checkSourceElement(node.type);
54907             registerForUnusedIdentifiersCheck(node);
54908         }
54909         function computeEnumMemberValues(node) {
54910             var nodeLinks = getNodeLinks(node);
54911             if (!(nodeLinks.flags & 16384)) {
54912                 nodeLinks.flags |= 16384;
54913                 var autoValue = 0;
54914                 for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
54915                     var member = _a[_i];
54916                     var value = computeMemberValue(member, autoValue);
54917                     getNodeLinks(member).enumMemberValue = value;
54918                     autoValue = typeof value === "number" ? value + 1 : undefined;
54919                 }
54920             }
54921         }
54922         function computeMemberValue(member, autoValue) {
54923             if (ts.isComputedNonLiteralName(member.name)) {
54924                 error(member.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums);
54925             }
54926             else {
54927                 var text = ts.getTextOfPropertyName(member.name);
54928                 if (isNumericLiteralName(text) && !isInfinityOrNaNString(text)) {
54929                     error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name);
54930                 }
54931             }
54932             if (member.initializer) {
54933                 return computeConstantValue(member);
54934             }
54935             if (member.parent.flags & 8388608 && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0) {
54936                 return undefined;
54937             }
54938             if (autoValue !== undefined) {
54939                 return autoValue;
54940             }
54941             error(member.name, ts.Diagnostics.Enum_member_must_have_initializer);
54942             return undefined;
54943         }
54944         function computeConstantValue(member) {
54945             var enumKind = getEnumKind(getSymbolOfNode(member.parent));
54946             var isConstEnum = ts.isEnumConst(member.parent);
54947             var initializer = member.initializer;
54948             var value = enumKind === 1 && !isLiteralEnumMember(member) ? undefined : evaluate(initializer);
54949             if (value !== undefined) {
54950                 if (isConstEnum && typeof value === "number" && !isFinite(value)) {
54951                     error(initializer, isNaN(value) ?
54952                         ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN :
54953                         ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value);
54954                 }
54955             }
54956             else if (enumKind === 1) {
54957                 error(initializer, ts.Diagnostics.Computed_values_are_not_permitted_in_an_enum_with_string_valued_members);
54958                 return 0;
54959             }
54960             else if (isConstEnum) {
54961                 error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values);
54962             }
54963             else if (member.parent.flags & 8388608) {
54964                 error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression);
54965             }
54966             else {
54967                 var source = checkExpression(initializer);
54968                 if (!isTypeAssignableToKind(source, 296)) {
54969                     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));
54970                 }
54971                 else {
54972                     checkTypeAssignableTo(source, getDeclaredTypeOfSymbol(getSymbolOfNode(member.parent)), initializer, undefined);
54973                 }
54974             }
54975             return value;
54976             function evaluate(expr) {
54977                 switch (expr.kind) {
54978                     case 207:
54979                         var value_2 = evaluate(expr.operand);
54980                         if (typeof value_2 === "number") {
54981                             switch (expr.operator) {
54982                                 case 39: return value_2;
54983                                 case 40: return -value_2;
54984                                 case 54: return ~value_2;
54985                             }
54986                         }
54987                         break;
54988                     case 209:
54989                         var left = evaluate(expr.left);
54990                         var right = evaluate(expr.right);
54991                         if (typeof left === "number" && typeof right === "number") {
54992                             switch (expr.operatorToken.kind) {
54993                                 case 51: return left | right;
54994                                 case 50: return left & right;
54995                                 case 48: return left >> right;
54996                                 case 49: return left >>> right;
54997                                 case 47: return left << right;
54998                                 case 52: return left ^ right;
54999                                 case 41: return left * right;
55000                                 case 43: return left / right;
55001                                 case 39: return left + right;
55002                                 case 40: return left - right;
55003                                 case 44: return left % right;
55004                                 case 42: return Math.pow(left, right);
55005                             }
55006                         }
55007                         else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39) {
55008                             return left + right;
55009                         }
55010                         break;
55011                     case 10:
55012                     case 14:
55013                         return expr.text;
55014                     case 8:
55015                         checkGrammarNumericLiteral(expr);
55016                         return +expr.text;
55017                     case 200:
55018                         return evaluate(expr.expression);
55019                     case 75:
55020                         var identifier = expr;
55021                         if (isInfinityOrNaNString(identifier.escapedText)) {
55022                             return +(identifier.escapedText);
55023                         }
55024                         return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText);
55025                     case 195:
55026                     case 194:
55027                         var ex = expr;
55028                         if (isConstantMemberAccess(ex)) {
55029                             var type = getTypeOfExpression(ex.expression);
55030                             if (type.symbol && type.symbol.flags & 384) {
55031                                 var name = void 0;
55032                                 if (ex.kind === 194) {
55033                                     name = ex.name.escapedText;
55034                                 }
55035                                 else {
55036                                     name = ts.escapeLeadingUnderscores(ts.cast(ex.argumentExpression, ts.isLiteralExpression).text);
55037                                 }
55038                                 return evaluateEnumMember(expr, type.symbol, name);
55039                             }
55040                         }
55041                         break;
55042                 }
55043                 return undefined;
55044             }
55045             function evaluateEnumMember(expr, enumSymbol, name) {
55046                 var memberSymbol = enumSymbol.exports.get(name);
55047                 if (memberSymbol) {
55048                     var declaration = memberSymbol.valueDeclaration;
55049                     if (declaration !== member) {
55050                         if (isBlockScopedNameDeclaredBeforeUse(declaration, member)) {
55051                             return getEnumMemberValue(declaration);
55052                         }
55053                         error(expr, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums);
55054                         return 0;
55055                     }
55056                     else {
55057                         error(expr, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(memberSymbol));
55058                     }
55059                 }
55060                 return undefined;
55061             }
55062         }
55063         function isConstantMemberAccess(node) {
55064             return node.kind === 75 ||
55065                 node.kind === 194 && isConstantMemberAccess(node.expression) ||
55066                 node.kind === 195 && isConstantMemberAccess(node.expression) &&
55067                     ts.isStringLiteralLike(node.argumentExpression);
55068         }
55069         function checkEnumDeclaration(node) {
55070             if (!produceDiagnostics) {
55071                 return;
55072             }
55073             checkGrammarDecoratorsAndModifiers(node);
55074             checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0);
55075             checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
55076             checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
55077             checkExportsOnMergedDeclarations(node);
55078             node.members.forEach(checkEnumMember);
55079             computeEnumMemberValues(node);
55080             var enumSymbol = getSymbolOfNode(node);
55081             var firstDeclaration = ts.getDeclarationOfKind(enumSymbol, node.kind);
55082             if (node === firstDeclaration) {
55083                 if (enumSymbol.declarations.length > 1) {
55084                     var enumIsConst_1 = ts.isEnumConst(node);
55085                     ts.forEach(enumSymbol.declarations, function (decl) {
55086                         if (ts.isEnumDeclaration(decl) && ts.isEnumConst(decl) !== enumIsConst_1) {
55087                             error(ts.getNameOfDeclaration(decl), ts.Diagnostics.Enum_declarations_must_all_be_const_or_non_const);
55088                         }
55089                     });
55090                 }
55091                 var seenEnumMissingInitialInitializer_1 = false;
55092                 ts.forEach(enumSymbol.declarations, function (declaration) {
55093                     if (declaration.kind !== 248) {
55094                         return false;
55095                     }
55096                     var enumDeclaration = declaration;
55097                     if (!enumDeclaration.members.length) {
55098                         return false;
55099                     }
55100                     var firstEnumMember = enumDeclaration.members[0];
55101                     if (!firstEnumMember.initializer) {
55102                         if (seenEnumMissingInitialInitializer_1) {
55103                             error(firstEnumMember.name, ts.Diagnostics.In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element);
55104                         }
55105                         else {
55106                             seenEnumMissingInitialInitializer_1 = true;
55107                         }
55108                     }
55109                 });
55110             }
55111         }
55112         function checkEnumMember(node) {
55113             if (ts.isPrivateIdentifier(node.name)) {
55114                 error(node, ts.Diagnostics.An_enum_member_cannot_be_named_with_a_private_identifier);
55115             }
55116         }
55117         function getFirstNonAmbientClassOrFunctionDeclaration(symbol) {
55118             var declarations = symbol.declarations;
55119             for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
55120                 var declaration = declarations_8[_i];
55121                 if ((declaration.kind === 245 ||
55122                     (declaration.kind === 244 && ts.nodeIsPresent(declaration.body))) &&
55123                     !(declaration.flags & 8388608)) {
55124                     return declaration;
55125                 }
55126             }
55127             return undefined;
55128         }
55129         function inSameLexicalScope(node1, node2) {
55130             var container1 = ts.getEnclosingBlockScopeContainer(node1);
55131             var container2 = ts.getEnclosingBlockScopeContainer(node2);
55132             if (isGlobalSourceFile(container1)) {
55133                 return isGlobalSourceFile(container2);
55134             }
55135             else if (isGlobalSourceFile(container2)) {
55136                 return false;
55137             }
55138             else {
55139                 return container1 === container2;
55140             }
55141         }
55142         function checkModuleDeclaration(node) {
55143             if (produceDiagnostics) {
55144                 var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node);
55145                 var inAmbientContext = node.flags & 8388608;
55146                 if (isGlobalAugmentation && !inAmbientContext) {
55147                     error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context);
55148                 }
55149                 var isAmbientExternalModule = ts.isAmbientModule(node);
55150                 var contextErrorMessage = isAmbientExternalModule
55151                     ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file
55152                     : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module;
55153                 if (checkGrammarModuleElementContext(node, contextErrorMessage)) {
55154                     return;
55155                 }
55156                 if (!checkGrammarDecoratorsAndModifiers(node)) {
55157                     if (!inAmbientContext && node.name.kind === 10) {
55158                         grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names);
55159                     }
55160                 }
55161                 if (ts.isIdentifier(node.name)) {
55162                     checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
55163                     checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
55164                 }
55165                 checkExportsOnMergedDeclarations(node);
55166                 var symbol = getSymbolOfNode(node);
55167                 if (symbol.flags & 512
55168                     && !inAmbientContext
55169                     && symbol.declarations.length > 1
55170                     && isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules)) {
55171                     var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol);
55172                     if (firstNonAmbientClassOrFunc) {
55173                         if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(firstNonAmbientClassOrFunc)) {
55174                             error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged);
55175                         }
55176                         else if (node.pos < firstNonAmbientClassOrFunc.pos) {
55177                             error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged);
55178                         }
55179                     }
55180                     var mergedClass = ts.getDeclarationOfKind(symbol, 245);
55181                     if (mergedClass &&
55182                         inSameLexicalScope(node, mergedClass)) {
55183                         getNodeLinks(node).flags |= 32768;
55184                     }
55185                 }
55186                 if (isAmbientExternalModule) {
55187                     if (ts.isExternalModuleAugmentation(node)) {
55188                         var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432);
55189                         if (checkBody && node.body) {
55190                             for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) {
55191                                 var statement = _a[_i];
55192                                 checkModuleAugmentationElement(statement, isGlobalAugmentation);
55193                             }
55194                         }
55195                     }
55196                     else if (isGlobalSourceFile(node.parent)) {
55197                         if (isGlobalAugmentation) {
55198                             error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations);
55199                         }
55200                         else if (ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(node.name))) {
55201                             error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name);
55202                         }
55203                     }
55204                     else {
55205                         if (isGlobalAugmentation) {
55206                             error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations);
55207                         }
55208                         else {
55209                             error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces);
55210                         }
55211                     }
55212                 }
55213             }
55214             if (node.body) {
55215                 checkSourceElement(node.body);
55216                 if (!ts.isGlobalScopeAugmentation(node)) {
55217                     registerForUnusedIdentifiersCheck(node);
55218                 }
55219             }
55220         }
55221         function checkModuleAugmentationElement(node, isGlobalAugmentation) {
55222             switch (node.kind) {
55223                 case 225:
55224                     for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
55225                         var decl = _a[_i];
55226                         checkModuleAugmentationElement(decl, isGlobalAugmentation);
55227                     }
55228                     break;
55229                 case 259:
55230                 case 260:
55231                     grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations);
55232                     break;
55233                 case 253:
55234                 case 254:
55235                     grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module);
55236                     break;
55237                 case 191:
55238                 case 242:
55239                     var name = node.name;
55240                     if (ts.isBindingPattern(name)) {
55241                         for (var _b = 0, _c = name.elements; _b < _c.length; _b++) {
55242                             var el = _c[_b];
55243                             checkModuleAugmentationElement(el, isGlobalAugmentation);
55244                         }
55245                         break;
55246                     }
55247                 case 245:
55248                 case 248:
55249                 case 244:
55250                 case 246:
55251                 case 249:
55252                 case 247:
55253                     if (isGlobalAugmentation) {
55254                         return;
55255                     }
55256                     var symbol = getSymbolOfNode(node);
55257                     if (symbol) {
55258                         var reportError = !(symbol.flags & 33554432);
55259                         if (!reportError) {
55260                             reportError = !!symbol.parent && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]);
55261                         }
55262                     }
55263                     break;
55264             }
55265         }
55266         function getFirstNonModuleExportsIdentifier(node) {
55267             switch (node.kind) {
55268                 case 75:
55269                     return node;
55270                 case 153:
55271                     do {
55272                         node = node.left;
55273                     } while (node.kind !== 75);
55274                     return node;
55275                 case 194:
55276                     do {
55277                         if (ts.isModuleExportsAccessExpression(node.expression) && !ts.isPrivateIdentifier(node.name)) {
55278                             return node.name;
55279                         }
55280                         node = node.expression;
55281                     } while (node.kind !== 75);
55282                     return node;
55283             }
55284         }
55285         function checkExternalImportOrExportDeclaration(node) {
55286             var moduleName = ts.getExternalModuleName(node);
55287             if (!moduleName || ts.nodeIsMissing(moduleName)) {
55288                 return false;
55289             }
55290             if (!ts.isStringLiteral(moduleName)) {
55291                 error(moduleName, ts.Diagnostics.String_literal_expected);
55292                 return false;
55293             }
55294             var inAmbientExternalModule = node.parent.kind === 250 && ts.isAmbientModule(node.parent.parent);
55295             if (node.parent.kind !== 290 && !inAmbientExternalModule) {
55296                 error(moduleName, node.kind === 260 ?
55297                     ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace :
55298                     ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module);
55299                 return false;
55300             }
55301             if (inAmbientExternalModule && ts.isExternalModuleNameRelative(moduleName.text)) {
55302                 if (!isTopLevelInExternalModuleAugmentation(node)) {
55303                     error(node, ts.Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name);
55304                     return false;
55305                 }
55306             }
55307             return true;
55308         }
55309         function checkAliasSymbol(node) {
55310             var symbol = getSymbolOfNode(node);
55311             var target = resolveAlias(symbol);
55312             var shouldSkipWithJSExpandoTargets = symbol.flags & 67108864;
55313             if (!shouldSkipWithJSExpandoTargets && target !== unknownSymbol) {
55314                 symbol = getMergedSymbol(symbol.exportSymbol || symbol);
55315                 var excludedMeanings = (symbol.flags & (111551 | 1048576) ? 111551 : 0) |
55316                     (symbol.flags & 788968 ? 788968 : 0) |
55317                     (symbol.flags & 1920 ? 1920 : 0);
55318                 if (target.flags & excludedMeanings) {
55319                     var message = node.kind === 263 ?
55320                         ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 :
55321                         ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0;
55322                     error(node, message, symbolToString(symbol));
55323                 }
55324                 if (compilerOptions.isolatedModules
55325                     && node.kind === 263
55326                     && !node.parent.parent.isTypeOnly
55327                     && !(target.flags & 111551)
55328                     && !(node.flags & 8388608)) {
55329                     error(node, ts.Diagnostics.Re_exporting_a_type_when_the_isolatedModules_flag_is_provided_requires_using_export_type);
55330                 }
55331             }
55332         }
55333         function checkImportBinding(node) {
55334             checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
55335             checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
55336             checkAliasSymbol(node);
55337         }
55338         function checkImportDeclaration(node) {
55339             if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) {
55340                 return;
55341             }
55342             if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) {
55343                 grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers);
55344             }
55345             if (checkExternalImportOrExportDeclaration(node)) {
55346                 var importClause = node.importClause;
55347                 if (importClause && !checkGrammarImportClause(importClause)) {
55348                     if (importClause.name) {
55349                         checkImportBinding(importClause);
55350                     }
55351                     if (importClause.namedBindings) {
55352                         if (importClause.namedBindings.kind === 256) {
55353                             checkImportBinding(importClause.namedBindings);
55354                         }
55355                         else {
55356                             var moduleExisted = resolveExternalModuleName(node, node.moduleSpecifier);
55357                             if (moduleExisted) {
55358                                 ts.forEach(importClause.namedBindings.elements, checkImportBinding);
55359                             }
55360                         }
55361                     }
55362                 }
55363             }
55364         }
55365         function checkImportEqualsDeclaration(node) {
55366             if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) {
55367                 return;
55368             }
55369             checkGrammarDecoratorsAndModifiers(node);
55370             if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) {
55371                 checkImportBinding(node);
55372                 if (ts.hasModifier(node, 1)) {
55373                     markExportAsReferenced(node);
55374                 }
55375                 if (node.moduleReference.kind !== 265) {
55376                     var target = resolveAlias(getSymbolOfNode(node));
55377                     if (target !== unknownSymbol) {
55378                         if (target.flags & 111551) {
55379                             var moduleName = ts.getFirstIdentifier(node.moduleReference);
55380                             if (!(resolveEntityName(moduleName, 111551 | 1920).flags & 1920)) {
55381                                 error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName));
55382                             }
55383                         }
55384                         if (target.flags & 788968) {
55385                             checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0);
55386                         }
55387                     }
55388                 }
55389                 else {
55390                     if (moduleKind >= ts.ModuleKind.ES2015 && !(node.flags & 8388608)) {
55391                         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);
55392                     }
55393                 }
55394             }
55395         }
55396         function checkExportDeclaration(node) {
55397             if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) {
55398                 return;
55399             }
55400             if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) {
55401                 grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers);
55402             }
55403             if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0) {
55404                 checkExternalEmitHelpers(node, 1048576);
55405             }
55406             checkGrammarExportDeclaration(node);
55407             if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) {
55408                 if (node.exportClause && !ts.isNamespaceExport(node.exportClause)) {
55409                     ts.forEach(node.exportClause.elements, checkExportSpecifier);
55410                     var inAmbientExternalModule = node.parent.kind === 250 && ts.isAmbientModule(node.parent.parent);
55411                     var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 250 &&
55412                         !node.moduleSpecifier && node.flags & 8388608;
55413                     if (node.parent.kind !== 290 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) {
55414                         error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace);
55415                     }
55416                 }
55417                 else {
55418                     var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier);
55419                     if (moduleSymbol && hasExportAssignmentSymbol(moduleSymbol)) {
55420                         error(node.moduleSpecifier, ts.Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol));
55421                     }
55422                     else if (node.exportClause) {
55423                         checkAliasSymbol(node.exportClause);
55424                     }
55425                     if (moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015) {
55426                         checkExternalEmitHelpers(node, 65536);
55427                     }
55428                 }
55429             }
55430         }
55431         function checkGrammarExportDeclaration(node) {
55432             var _a;
55433             var isTypeOnlyExportStar = node.isTypeOnly && ((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) !== 261;
55434             if (isTypeOnlyExportStar) {
55435                 grammarErrorOnNode(node, ts.Diagnostics.Only_named_exports_may_use_export_type);
55436             }
55437             return !isTypeOnlyExportStar;
55438         }
55439         function checkGrammarModuleElementContext(node, errorMessage) {
55440             var isInAppropriateContext = node.parent.kind === 290 || node.parent.kind === 250 || node.parent.kind === 249;
55441             if (!isInAppropriateContext) {
55442                 grammarErrorOnFirstToken(node, errorMessage);
55443             }
55444             return !isInAppropriateContext;
55445         }
55446         function importClauseContainsReferencedImport(importClause) {
55447             return ts.forEachImportClauseDeclaration(importClause, function (declaration) {
55448                 return !!getSymbolOfNode(declaration).isReferenced;
55449             });
55450         }
55451         function importClauseContainsConstEnumUsedAsValue(importClause) {
55452             return ts.forEachImportClauseDeclaration(importClause, function (declaration) {
55453                 return !!getSymbolLinks(getSymbolOfNode(declaration)).constEnumReferenced;
55454             });
55455         }
55456         function checkImportsForTypeOnlyConversion(sourceFile) {
55457             for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) {
55458                 var statement = _a[_i];
55459                 if (ts.isImportDeclaration(statement) &&
55460                     statement.importClause &&
55461                     !statement.importClause.isTypeOnly &&
55462                     importClauseContainsReferencedImport(statement.importClause) &&
55463                     !isReferencedAliasDeclaration(statement.importClause, true) &&
55464                     !importClauseContainsConstEnumUsedAsValue(statement.importClause)) {
55465                     error(statement, ts.Diagnostics.This_import_is_never_used_as_a_value_and_must_use_import_type_because_the_importsNotUsedAsValues_is_set_to_error);
55466                 }
55467             }
55468         }
55469         function checkExportSpecifier(node) {
55470             checkAliasSymbol(node);
55471             if (ts.getEmitDeclarations(compilerOptions)) {
55472                 collectLinkedAliases(node.propertyName || node.name, true);
55473             }
55474             if (!node.parent.parent.moduleSpecifier) {
55475                 var exportedName = node.propertyName || node.name;
55476                 var symbol = resolveName(exportedName, exportedName.escapedText, 111551 | 788968 | 1920 | 2097152, undefined, undefined, true);
55477                 if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) {
55478                     error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName));
55479                 }
55480                 else {
55481                     markExportAsReferenced(node);
55482                     var target = symbol && (symbol.flags & 2097152 ? resolveAlias(symbol) : symbol);
55483                     if (!target || target === unknownSymbol || target.flags & 111551) {
55484                         checkExpressionCached(node.propertyName || node.name);
55485                     }
55486                 }
55487             }
55488         }
55489         function checkExportAssignment(node) {
55490             if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) {
55491                 return;
55492             }
55493             var container = node.parent.kind === 290 ? node.parent : node.parent.parent;
55494             if (container.kind === 249 && !ts.isAmbientModule(container)) {
55495                 if (node.isExportEquals) {
55496                     error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace);
55497                 }
55498                 else {
55499                     error(node, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module);
55500                 }
55501                 return;
55502             }
55503             if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) {
55504                 grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers);
55505             }
55506             if (node.expression.kind === 75) {
55507                 var id = node.expression;
55508                 var sym = resolveEntityName(id, 67108863, true, true, node);
55509                 if (sym) {
55510                     markAliasReferenced(sym, id);
55511                     var target = sym.flags & 2097152 ? resolveAlias(sym) : sym;
55512                     if (target === unknownSymbol || target.flags & 111551) {
55513                         checkExpressionCached(node.expression);
55514                     }
55515                 }
55516                 if (ts.getEmitDeclarations(compilerOptions)) {
55517                     collectLinkedAliases(node.expression, true);
55518                 }
55519             }
55520             else {
55521                 checkExpressionCached(node.expression);
55522             }
55523             checkExternalModuleExports(container);
55524             if ((node.flags & 8388608) && !ts.isEntityNameExpression(node.expression)) {
55525                 grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context);
55526             }
55527             if (node.isExportEquals && !(node.flags & 8388608)) {
55528                 if (moduleKind >= ts.ModuleKind.ES2015) {
55529                     grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
55530                 }
55531                 else if (moduleKind === ts.ModuleKind.System) {
55532                     grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system);
55533                 }
55534             }
55535         }
55536         function hasExportedMembers(moduleSymbol) {
55537             return ts.forEachEntry(moduleSymbol.exports, function (_, id) { return id !== "export="; });
55538         }
55539         function checkExternalModuleExports(node) {
55540             var moduleSymbol = getSymbolOfNode(node);
55541             var links = getSymbolLinks(moduleSymbol);
55542             if (!links.exportsChecked) {
55543                 var exportEqualsSymbol = moduleSymbol.exports.get("export=");
55544                 if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) {
55545                     var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration;
55546                     if (!isTopLevelInExternalModuleAugmentation(declaration) && !ts.isInJSFile(declaration)) {
55547                         error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements);
55548                     }
55549                 }
55550                 var exports_2 = getExportsOfModule(moduleSymbol);
55551                 if (exports_2) {
55552                     exports_2.forEach(function (_a, id) {
55553                         var declarations = _a.declarations, flags = _a.flags;
55554                         if (id === "__export") {
55555                             return;
55556                         }
55557                         if (flags & (1920 | 64 | 384)) {
55558                             return;
55559                         }
55560                         var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverloadAndNotAccessor);
55561                         if (flags & 524288 && exportedDeclarationsCount <= 2) {
55562                             return;
55563                         }
55564                         if (exportedDeclarationsCount > 1) {
55565                             for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) {
55566                                 var declaration = declarations_9[_i];
55567                                 if (isNotOverload(declaration)) {
55568                                     diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, ts.unescapeLeadingUnderscores(id)));
55569                                 }
55570                             }
55571                         }
55572                     });
55573                 }
55574                 links.exportsChecked = true;
55575             }
55576         }
55577         function checkSourceElement(node) {
55578             if (node) {
55579                 var saveCurrentNode = currentNode;
55580                 currentNode = node;
55581                 instantiationCount = 0;
55582                 checkSourceElementWorker(node);
55583                 currentNode = saveCurrentNode;
55584             }
55585         }
55586         function checkSourceElementWorker(node) {
55587             if (ts.isInJSFile(node)) {
55588                 ts.forEach(node.jsDoc, function (_a) {
55589                     var tags = _a.tags;
55590                     return ts.forEach(tags, checkSourceElement);
55591                 });
55592             }
55593             var kind = node.kind;
55594             if (cancellationToken) {
55595                 switch (kind) {
55596                     case 249:
55597                     case 245:
55598                     case 246:
55599                     case 244:
55600                         cancellationToken.throwIfCancellationRequested();
55601                 }
55602             }
55603             if (kind >= 225 && kind <= 241 && node.flowNode && !isReachableFlowNode(node.flowNode)) {
55604                 errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected);
55605             }
55606             switch (kind) {
55607                 case 155:
55608                     return checkTypeParameter(node);
55609                 case 156:
55610                     return checkParameter(node);
55611                 case 159:
55612                     return checkPropertyDeclaration(node);
55613                 case 158:
55614                     return checkPropertySignature(node);
55615                 case 170:
55616                 case 171:
55617                 case 165:
55618                 case 166:
55619                 case 167:
55620                     return checkSignatureDeclaration(node);
55621                 case 161:
55622                 case 160:
55623                     return checkMethodDeclaration(node);
55624                 case 162:
55625                     return checkConstructorDeclaration(node);
55626                 case 163:
55627                 case 164:
55628                     return checkAccessorDeclaration(node);
55629                 case 169:
55630                     return checkTypeReferenceNode(node);
55631                 case 168:
55632                     return checkTypePredicate(node);
55633                 case 172:
55634                     return checkTypeQuery(node);
55635                 case 173:
55636                     return checkTypeLiteral(node);
55637                 case 174:
55638                     return checkArrayType(node);
55639                 case 175:
55640                     return checkTupleType(node);
55641                 case 178:
55642                 case 179:
55643                     return checkUnionOrIntersectionType(node);
55644                 case 182:
55645                 case 176:
55646                 case 177:
55647                     return checkSourceElement(node.type);
55648                 case 183:
55649                     return checkThisType(node);
55650                 case 184:
55651                     return checkTypeOperator(node);
55652                 case 180:
55653                     return checkConditionalType(node);
55654                 case 181:
55655                     return checkInferType(node);
55656                 case 188:
55657                     return checkImportType(node);
55658                 case 307:
55659                     return checkJSDocAugmentsTag(node);
55660                 case 308:
55661                     return checkJSDocImplementsTag(node);
55662                 case 322:
55663                 case 315:
55664                 case 316:
55665                     return checkJSDocTypeAliasTag(node);
55666                 case 321:
55667                     return checkJSDocTemplateTag(node);
55668                 case 320:
55669                     return checkJSDocTypeTag(node);
55670                 case 317:
55671                     return checkJSDocParameterTag(node);
55672                 case 323:
55673                     return checkJSDocPropertyTag(node);
55674                 case 300:
55675                     checkJSDocFunctionType(node);
55676                 case 298:
55677                 case 297:
55678                 case 295:
55679                 case 296:
55680                 case 304:
55681                     checkJSDocTypeIsInJsFile(node);
55682                     ts.forEachChild(node, checkSourceElement);
55683                     return;
55684                 case 301:
55685                     checkJSDocVariadicType(node);
55686                     return;
55687                 case 294:
55688                     return checkSourceElement(node.type);
55689                 case 185:
55690                     return checkIndexedAccessType(node);
55691                 case 186:
55692                     return checkMappedType(node);
55693                 case 244:
55694                     return checkFunctionDeclaration(node);
55695                 case 223:
55696                 case 250:
55697                     return checkBlock(node);
55698                 case 225:
55699                     return checkVariableStatement(node);
55700                 case 226:
55701                     return checkExpressionStatement(node);
55702                 case 227:
55703                     return checkIfStatement(node);
55704                 case 228:
55705                     return checkDoStatement(node);
55706                 case 229:
55707                     return checkWhileStatement(node);
55708                 case 230:
55709                     return checkForStatement(node);
55710                 case 231:
55711                     return checkForInStatement(node);
55712                 case 232:
55713                     return checkForOfStatement(node);
55714                 case 233:
55715                 case 234:
55716                     return checkBreakOrContinueStatement(node);
55717                 case 235:
55718                     return checkReturnStatement(node);
55719                 case 236:
55720                     return checkWithStatement(node);
55721                 case 237:
55722                     return checkSwitchStatement(node);
55723                 case 238:
55724                     return checkLabeledStatement(node);
55725                 case 239:
55726                     return checkThrowStatement(node);
55727                 case 240:
55728                     return checkTryStatement(node);
55729                 case 242:
55730                     return checkVariableDeclaration(node);
55731                 case 191:
55732                     return checkBindingElement(node);
55733                 case 245:
55734                     return checkClassDeclaration(node);
55735                 case 246:
55736                     return checkInterfaceDeclaration(node);
55737                 case 247:
55738                     return checkTypeAliasDeclaration(node);
55739                 case 248:
55740                     return checkEnumDeclaration(node);
55741                 case 249:
55742                     return checkModuleDeclaration(node);
55743                 case 254:
55744                     return checkImportDeclaration(node);
55745                 case 253:
55746                     return checkImportEqualsDeclaration(node);
55747                 case 260:
55748                     return checkExportDeclaration(node);
55749                 case 259:
55750                     return checkExportAssignment(node);
55751                 case 224:
55752                 case 241:
55753                     checkGrammarStatementInAmbientContext(node);
55754                     return;
55755                 case 264:
55756                     return checkMissingDeclaration(node);
55757             }
55758         }
55759         function checkJSDocTypeIsInJsFile(node) {
55760             if (!ts.isInJSFile(node)) {
55761                 grammarErrorOnNode(node, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments);
55762             }
55763         }
55764         function checkJSDocVariadicType(node) {
55765             checkJSDocTypeIsInJsFile(node);
55766             checkSourceElement(node.type);
55767             var parent = node.parent;
55768             if (ts.isParameter(parent) && ts.isJSDocFunctionType(parent.parent)) {
55769                 if (ts.last(parent.parent.parameters) !== parent) {
55770                     error(node, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
55771                 }
55772                 return;
55773             }
55774             if (!ts.isJSDocTypeExpression(parent)) {
55775                 error(node, ts.Diagnostics.JSDoc_may_only_appear_in_the_last_parameter_of_a_signature);
55776             }
55777             var paramTag = node.parent.parent;
55778             if (!ts.isJSDocParameterTag(paramTag)) {
55779                 error(node, ts.Diagnostics.JSDoc_may_only_appear_in_the_last_parameter_of_a_signature);
55780                 return;
55781             }
55782             var param = ts.getParameterSymbolFromJSDoc(paramTag);
55783             if (!param) {
55784                 return;
55785             }
55786             var host = ts.getHostSignatureFromJSDoc(paramTag);
55787             if (!host || ts.last(host.parameters).symbol !== param) {
55788                 error(node, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
55789             }
55790         }
55791         function getTypeFromJSDocVariadicType(node) {
55792             var type = getTypeFromTypeNode(node.type);
55793             var parent = node.parent;
55794             var paramTag = node.parent.parent;
55795             if (ts.isJSDocTypeExpression(node.parent) && ts.isJSDocParameterTag(paramTag)) {
55796                 var host_1 = ts.getHostSignatureFromJSDoc(paramTag);
55797                 if (host_1) {
55798                     var lastParamDeclaration = ts.lastOrUndefined(host_1.parameters);
55799                     var symbol = ts.getParameterSymbolFromJSDoc(paramTag);
55800                     if (!lastParamDeclaration ||
55801                         symbol && lastParamDeclaration.symbol === symbol && ts.isRestParameter(lastParamDeclaration)) {
55802                         return createArrayType(type);
55803                     }
55804                 }
55805             }
55806             if (ts.isParameter(parent) && ts.isJSDocFunctionType(parent.parent)) {
55807                 return createArrayType(type);
55808             }
55809             return addOptionality(type);
55810         }
55811         function checkNodeDeferred(node) {
55812             var enclosingFile = ts.getSourceFileOfNode(node);
55813             var links = getNodeLinks(enclosingFile);
55814             if (!(links.flags & 1)) {
55815                 links.deferredNodes = links.deferredNodes || ts.createMap();
55816                 var id = "" + getNodeId(node);
55817                 links.deferredNodes.set(id, node);
55818             }
55819         }
55820         function checkDeferredNodes(context) {
55821             var links = getNodeLinks(context);
55822             if (links.deferredNodes) {
55823                 links.deferredNodes.forEach(checkDeferredNode);
55824             }
55825         }
55826         function checkDeferredNode(node) {
55827             var saveCurrentNode = currentNode;
55828             currentNode = node;
55829             instantiationCount = 0;
55830             switch (node.kind) {
55831                 case 196:
55832                 case 197:
55833                 case 198:
55834                 case 157:
55835                 case 268:
55836                     resolveUntypedCall(node);
55837                     break;
55838                 case 201:
55839                 case 202:
55840                 case 161:
55841                 case 160:
55842                     checkFunctionExpressionOrObjectLiteralMethodDeferred(node);
55843                     break;
55844                 case 163:
55845                 case 164:
55846                     checkAccessorDeclaration(node);
55847                     break;
55848                 case 214:
55849                     checkClassExpressionDeferred(node);
55850                     break;
55851                 case 267:
55852                     checkJsxSelfClosingElementDeferred(node);
55853                     break;
55854                 case 266:
55855                     checkJsxElementDeferred(node);
55856                     break;
55857             }
55858             currentNode = saveCurrentNode;
55859         }
55860         function checkSourceFile(node) {
55861             ts.performance.mark("beforeCheck");
55862             checkSourceFileWorker(node);
55863             ts.performance.mark("afterCheck");
55864             ts.performance.measure("Check", "beforeCheck", "afterCheck");
55865         }
55866         function unusedIsError(kind, isAmbient) {
55867             if (isAmbient) {
55868                 return false;
55869             }
55870             switch (kind) {
55871                 case 0:
55872                     return !!compilerOptions.noUnusedLocals;
55873                 case 1:
55874                     return !!compilerOptions.noUnusedParameters;
55875                 default:
55876                     return ts.Debug.assertNever(kind);
55877             }
55878         }
55879         function getPotentiallyUnusedIdentifiers(sourceFile) {
55880             return allPotentiallyUnusedIdentifiers.get(sourceFile.path) || ts.emptyArray;
55881         }
55882         function checkSourceFileWorker(node) {
55883             var links = getNodeLinks(node);
55884             if (!(links.flags & 1)) {
55885                 if (ts.skipTypeChecking(node, compilerOptions, host)) {
55886                     return;
55887                 }
55888                 checkGrammarSourceFile(node);
55889                 ts.clear(potentialThisCollisions);
55890                 ts.clear(potentialNewTargetCollisions);
55891                 ts.clear(potentialWeakMapCollisions);
55892                 ts.forEach(node.statements, checkSourceElement);
55893                 checkSourceElement(node.endOfFileToken);
55894                 checkDeferredNodes(node);
55895                 if (ts.isExternalOrCommonJsModule(node)) {
55896                     registerForUnusedIdentifiersCheck(node);
55897                 }
55898                 if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) {
55899                     checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), function (containingNode, kind, diag) {
55900                         if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 8388608))) {
55901                             diagnostics.add(diag);
55902                         }
55903                     });
55904                 }
55905                 if (compilerOptions.importsNotUsedAsValues === 2 &&
55906                     !node.isDeclarationFile &&
55907                     ts.isExternalModule(node)) {
55908                     checkImportsForTypeOnlyConversion(node);
55909                 }
55910                 if (ts.isExternalOrCommonJsModule(node)) {
55911                     checkExternalModuleExports(node);
55912                 }
55913                 if (potentialThisCollisions.length) {
55914                     ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope);
55915                     ts.clear(potentialThisCollisions);
55916                 }
55917                 if (potentialNewTargetCollisions.length) {
55918                     ts.forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope);
55919                     ts.clear(potentialNewTargetCollisions);
55920                 }
55921                 if (potentialWeakMapCollisions.length) {
55922                     ts.forEach(potentialWeakMapCollisions, checkWeakMapCollision);
55923                     ts.clear(potentialWeakMapCollisions);
55924                 }
55925                 links.flags |= 1;
55926             }
55927         }
55928         function getDiagnostics(sourceFile, ct) {
55929             try {
55930                 cancellationToken = ct;
55931                 return getDiagnosticsWorker(sourceFile);
55932             }
55933             finally {
55934                 cancellationToken = undefined;
55935             }
55936         }
55937         function getDiagnosticsWorker(sourceFile) {
55938             throwIfNonDiagnosticsProducing();
55939             if (sourceFile) {
55940                 var previousGlobalDiagnostics = diagnostics.getGlobalDiagnostics();
55941                 var previousGlobalDiagnosticsSize = previousGlobalDiagnostics.length;
55942                 checkSourceFile(sourceFile);
55943                 var semanticDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName);
55944                 var currentGlobalDiagnostics = diagnostics.getGlobalDiagnostics();
55945                 if (currentGlobalDiagnostics !== previousGlobalDiagnostics) {
55946                     var deferredGlobalDiagnostics = ts.relativeComplement(previousGlobalDiagnostics, currentGlobalDiagnostics, ts.compareDiagnostics);
55947                     return ts.concatenate(deferredGlobalDiagnostics, semanticDiagnostics);
55948                 }
55949                 else if (previousGlobalDiagnosticsSize === 0 && currentGlobalDiagnostics.length > 0) {
55950                     return ts.concatenate(currentGlobalDiagnostics, semanticDiagnostics);
55951                 }
55952                 return semanticDiagnostics;
55953             }
55954             ts.forEach(host.getSourceFiles(), checkSourceFile);
55955             return diagnostics.getDiagnostics();
55956         }
55957         function getGlobalDiagnostics() {
55958             throwIfNonDiagnosticsProducing();
55959             return diagnostics.getGlobalDiagnostics();
55960         }
55961         function throwIfNonDiagnosticsProducing() {
55962             if (!produceDiagnostics) {
55963                 throw new Error("Trying to get diagnostics from a type checker that does not produce them.");
55964             }
55965         }
55966         function getSymbolsInScope(location, meaning) {
55967             if (location.flags & 16777216) {
55968                 return [];
55969             }
55970             var symbols = ts.createSymbolTable();
55971             var isStatic = false;
55972             populateSymbols();
55973             symbols.delete("this");
55974             return symbolsToArray(symbols);
55975             function populateSymbols() {
55976                 while (location) {
55977                     if (location.locals && !isGlobalSourceFile(location)) {
55978                         copySymbols(location.locals, meaning);
55979                     }
55980                     switch (location.kind) {
55981                         case 290:
55982                             if (!ts.isExternalOrCommonJsModule(location))
55983                                 break;
55984                         case 249:
55985                             copySymbols(getSymbolOfNode(location).exports, meaning & 2623475);
55986                             break;
55987                         case 248:
55988                             copySymbols(getSymbolOfNode(location).exports, meaning & 8);
55989                             break;
55990                         case 214:
55991                             var className = location.name;
55992                             if (className) {
55993                                 copySymbol(location.symbol, meaning);
55994                             }
55995                         case 245:
55996                         case 246:
55997                             if (!isStatic) {
55998                                 copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968);
55999                             }
56000                             break;
56001                         case 201:
56002                             var funcName = location.name;
56003                             if (funcName) {
56004                                 copySymbol(location.symbol, meaning);
56005                             }
56006                             break;
56007                     }
56008                     if (ts.introducesArgumentsExoticObject(location)) {
56009                         copySymbol(argumentsSymbol, meaning);
56010                     }
56011                     isStatic = ts.hasModifier(location, 32);
56012                     location = location.parent;
56013                 }
56014                 copySymbols(globals, meaning);
56015             }
56016             function copySymbol(symbol, meaning) {
56017                 if (ts.getCombinedLocalAndExportSymbolFlags(symbol) & meaning) {
56018                     var id = symbol.escapedName;
56019                     if (!symbols.has(id)) {
56020                         symbols.set(id, symbol);
56021                     }
56022                 }
56023             }
56024             function copySymbols(source, meaning) {
56025                 if (meaning) {
56026                     source.forEach(function (symbol) {
56027                         copySymbol(symbol, meaning);
56028                     });
56029                 }
56030             }
56031         }
56032         function isTypeDeclarationName(name) {
56033             return name.kind === 75 &&
56034                 isTypeDeclaration(name.parent) &&
56035                 name.parent.name === name;
56036         }
56037         function isTypeDeclaration(node) {
56038             switch (node.kind) {
56039                 case 155:
56040                 case 245:
56041                 case 246:
56042                 case 247:
56043                 case 248:
56044                     return true;
56045                 case 255:
56046                     return node.isTypeOnly;
56047                 case 258:
56048                 case 263:
56049                     return node.parent.parent.isTypeOnly;
56050                 default:
56051                     return false;
56052             }
56053         }
56054         function isTypeReferenceIdentifier(node) {
56055             while (node.parent.kind === 153) {
56056                 node = node.parent;
56057             }
56058             return node.parent.kind === 169;
56059         }
56060         function isHeritageClauseElementIdentifier(node) {
56061             while (node.parent.kind === 194) {
56062                 node = node.parent;
56063             }
56064             return node.parent.kind === 216;
56065         }
56066         function forEachEnclosingClass(node, callback) {
56067             var result;
56068             while (true) {
56069                 node = ts.getContainingClass(node);
56070                 if (!node)
56071                     break;
56072                 if (result = callback(node))
56073                     break;
56074             }
56075             return result;
56076         }
56077         function isNodeUsedDuringClassInitialization(node) {
56078             return !!ts.findAncestor(node, function (element) {
56079                 if (ts.isConstructorDeclaration(element) && ts.nodeIsPresent(element.body) || ts.isPropertyDeclaration(element)) {
56080                     return true;
56081                 }
56082                 else if (ts.isClassLike(element) || ts.isFunctionLikeDeclaration(element)) {
56083                     return "quit";
56084                 }
56085                 return false;
56086             });
56087         }
56088         function isNodeWithinClass(node, classDeclaration) {
56089             return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; });
56090         }
56091         function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) {
56092             while (nodeOnRightSide.parent.kind === 153) {
56093                 nodeOnRightSide = nodeOnRightSide.parent;
56094             }
56095             if (nodeOnRightSide.parent.kind === 253) {
56096                 return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined;
56097             }
56098             if (nodeOnRightSide.parent.kind === 259) {
56099                 return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined;
56100             }
56101             return undefined;
56102         }
56103         function isInRightSideOfImportOrExportAssignment(node) {
56104             return getLeftSideOfImportEqualsOrExportAssignment(node) !== undefined;
56105         }
56106         function getSpecialPropertyAssignmentSymbolFromEntityName(entityName) {
56107             var specialPropertyAssignmentKind = ts.getAssignmentDeclarationKind(entityName.parent.parent);
56108             switch (specialPropertyAssignmentKind) {
56109                 case 1:
56110                 case 3:
56111                     return getSymbolOfNode(entityName.parent);
56112                 case 4:
56113                 case 2:
56114                 case 5:
56115                     return getSymbolOfNode(entityName.parent.parent);
56116             }
56117         }
56118         function isImportTypeQualifierPart(node) {
56119             var parent = node.parent;
56120             while (ts.isQualifiedName(parent)) {
56121                 node = parent;
56122                 parent = parent.parent;
56123             }
56124             if (parent && parent.kind === 188 && parent.qualifier === node) {
56125                 return parent;
56126             }
56127             return undefined;
56128         }
56129         function getSymbolOfNameOrPropertyAccessExpression(name) {
56130             if (ts.isDeclarationName(name)) {
56131                 return getSymbolOfNode(name.parent);
56132             }
56133             if (ts.isInJSFile(name) &&
56134                 name.parent.kind === 194 &&
56135                 name.parent === name.parent.parent.left) {
56136                 if (!ts.isPrivateIdentifier(name)) {
56137                     var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(name);
56138                     if (specialPropertyAssignmentSymbol) {
56139                         return specialPropertyAssignmentSymbol;
56140                     }
56141                 }
56142             }
56143             if (name.parent.kind === 259 && ts.isEntityNameExpression(name)) {
56144                 var success = resolveEntityName(name, 111551 | 788968 | 1920 | 2097152, true);
56145                 if (success && success !== unknownSymbol) {
56146                     return success;
56147                 }
56148             }
56149             else if (!ts.isPropertyAccessExpression(name) && !ts.isPrivateIdentifier(name) && isInRightSideOfImportOrExportAssignment(name)) {
56150                 var importEqualsDeclaration = ts.getAncestor(name, 253);
56151                 ts.Debug.assert(importEqualsDeclaration !== undefined);
56152                 return getSymbolOfPartOfRightHandSideOfImportEquals(name, true);
56153             }
56154             if (!ts.isPropertyAccessExpression(name) && !ts.isPrivateIdentifier(name)) {
56155                 var possibleImportNode = isImportTypeQualifierPart(name);
56156                 if (possibleImportNode) {
56157                     getTypeFromTypeNode(possibleImportNode);
56158                     var sym = getNodeLinks(name).resolvedSymbol;
56159                     return sym === unknownSymbol ? undefined : sym;
56160                 }
56161             }
56162             while (ts.isRightSideOfQualifiedNameOrPropertyAccess(name)) {
56163                 name = name.parent;
56164             }
56165             if (isHeritageClauseElementIdentifier(name)) {
56166                 var meaning = 0;
56167                 if (name.parent.kind === 216) {
56168                     meaning = 788968;
56169                     if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(name.parent)) {
56170                         meaning |= 111551;
56171                     }
56172                 }
56173                 else {
56174                     meaning = 1920;
56175                 }
56176                 meaning |= 2097152;
56177                 var entityNameSymbol = ts.isEntityNameExpression(name) ? resolveEntityName(name, meaning) : undefined;
56178                 if (entityNameSymbol) {
56179                     return entityNameSymbol;
56180                 }
56181             }
56182             if (name.parent.kind === 317) {
56183                 return ts.getParameterSymbolFromJSDoc(name.parent);
56184             }
56185             if (name.parent.kind === 155 && name.parent.parent.kind === 321) {
56186                 ts.Debug.assert(!ts.isInJSFile(name));
56187                 var typeParameter = ts.getTypeParameterFromJsDoc(name.parent);
56188                 return typeParameter && typeParameter.symbol;
56189             }
56190             if (ts.isExpressionNode(name)) {
56191                 if (ts.nodeIsMissing(name)) {
56192                     return undefined;
56193                 }
56194                 if (name.kind === 75) {
56195                     if (ts.isJSXTagName(name) && isJsxIntrinsicIdentifier(name)) {
56196                         var symbol = getIntrinsicTagSymbol(name.parent);
56197                         return symbol === unknownSymbol ? undefined : symbol;
56198                     }
56199                     return resolveEntityName(name, 111551, false, true);
56200                 }
56201                 else if (name.kind === 194 || name.kind === 153) {
56202                     var links = getNodeLinks(name);
56203                     if (links.resolvedSymbol) {
56204                         return links.resolvedSymbol;
56205                     }
56206                     if (name.kind === 194) {
56207                         checkPropertyAccessExpression(name);
56208                     }
56209                     else {
56210                         checkQualifiedName(name);
56211                     }
56212                     return links.resolvedSymbol;
56213                 }
56214             }
56215             else if (isTypeReferenceIdentifier(name)) {
56216                 var meaning = name.parent.kind === 169 ? 788968 : 1920;
56217                 return resolveEntityName(name, meaning, false, true);
56218             }
56219             if (name.parent.kind === 168) {
56220                 return resolveEntityName(name, 1);
56221             }
56222             return undefined;
56223         }
56224         function getSymbolAtLocation(node, ignoreErrors) {
56225             if (node.kind === 290) {
56226                 return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined;
56227             }
56228             var parent = node.parent;
56229             var grandParent = parent.parent;
56230             if (node.flags & 16777216) {
56231                 return undefined;
56232             }
56233             if (isDeclarationNameOrImportPropertyName(node)) {
56234                 var parentSymbol = getSymbolOfNode(parent);
56235                 return ts.isImportOrExportSpecifier(node.parent) && node.parent.propertyName === node
56236                     ? getImmediateAliasedSymbol(parentSymbol)
56237                     : parentSymbol;
56238             }
56239             else if (ts.isLiteralComputedPropertyDeclarationName(node)) {
56240                 return getSymbolOfNode(parent.parent);
56241             }
56242             if (node.kind === 75) {
56243                 if (isInRightSideOfImportOrExportAssignment(node)) {
56244                     return getSymbolOfNameOrPropertyAccessExpression(node);
56245                 }
56246                 else if (parent.kind === 191 &&
56247                     grandParent.kind === 189 &&
56248                     node === parent.propertyName) {
56249                     var typeOfPattern = getTypeOfNode(grandParent);
56250                     var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText);
56251                     if (propertyDeclaration) {
56252                         return propertyDeclaration;
56253                     }
56254                 }
56255             }
56256             switch (node.kind) {
56257                 case 75:
56258                 case 76:
56259                 case 194:
56260                 case 153:
56261                     return getSymbolOfNameOrPropertyAccessExpression(node);
56262                 case 104:
56263                     var container = ts.getThisContainer(node, false);
56264                     if (ts.isFunctionLike(container)) {
56265                         var sig = getSignatureFromDeclaration(container);
56266                         if (sig.thisParameter) {
56267                             return sig.thisParameter;
56268                         }
56269                     }
56270                     if (ts.isInExpressionContext(node)) {
56271                         return checkExpression(node).symbol;
56272                     }
56273                 case 183:
56274                     return getTypeFromThisTypeNode(node).symbol;
56275                 case 102:
56276                     return checkExpression(node).symbol;
56277                 case 129:
56278                     var constructorDeclaration = node.parent;
56279                     if (constructorDeclaration && constructorDeclaration.kind === 162) {
56280                         return constructorDeclaration.parent.symbol;
56281                     }
56282                     return undefined;
56283                 case 10:
56284                 case 14:
56285                     if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) ||
56286                         ((node.parent.kind === 254 || node.parent.kind === 260) && node.parent.moduleSpecifier === node) ||
56287                         ((ts.isInJSFile(node) && ts.isRequireCall(node.parent, false)) || ts.isImportCall(node.parent)) ||
56288                         (ts.isLiteralTypeNode(node.parent) && ts.isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent)) {
56289                         return resolveExternalModuleName(node, node, ignoreErrors);
56290                     }
56291                     if (ts.isCallExpression(parent) && ts.isBindableObjectDefinePropertyCall(parent) && parent.arguments[1] === node) {
56292                         return getSymbolOfNode(parent);
56293                     }
56294                 case 8:
56295                     var objectType = ts.isElementAccessExpression(parent)
56296                         ? parent.argumentExpression === node ? getTypeOfExpression(parent.expression) : undefined
56297                         : ts.isLiteralTypeNode(parent) && ts.isIndexedAccessTypeNode(grandParent)
56298                             ? getTypeFromTypeNode(grandParent.objectType)
56299                             : undefined;
56300                     return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text));
56301                 case 84:
56302                 case 94:
56303                 case 38:
56304                 case 80:
56305                     return getSymbolOfNode(node.parent);
56306                 case 188:
56307                     return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal, ignoreErrors) : undefined;
56308                 case 89:
56309                     return ts.isExportAssignment(node.parent) ? ts.Debug.checkDefined(node.parent.symbol) : undefined;
56310                 default:
56311                     return undefined;
56312             }
56313         }
56314         function getShorthandAssignmentValueSymbol(location) {
56315             if (location && location.kind === 282) {
56316                 return resolveEntityName(location.name, 111551 | 2097152);
56317             }
56318             return undefined;
56319         }
56320         function getExportSpecifierLocalTargetSymbol(node) {
56321             return node.parent.parent.moduleSpecifier ?
56322                 getExternalModuleMember(node.parent.parent, node) :
56323                 resolveEntityName(node.propertyName || node.name, 111551 | 788968 | 1920 | 2097152);
56324         }
56325         function getTypeOfNode(node) {
56326             if (node.flags & 16777216) {
56327                 return errorType;
56328             }
56329             var classDecl = ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments(node);
56330             var classType = classDecl && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(classDecl.class));
56331             if (ts.isPartOfTypeNode(node)) {
56332                 var typeFromTypeNode = getTypeFromTypeNode(node);
56333                 return classType ? getTypeWithThisArgument(typeFromTypeNode, classType.thisType) : typeFromTypeNode;
56334             }
56335             if (ts.isExpressionNode(node)) {
56336                 return getRegularTypeOfExpression(node);
56337             }
56338             if (classType && !classDecl.isImplements) {
56339                 var baseType = ts.firstOrUndefined(getBaseTypes(classType));
56340                 return baseType ? getTypeWithThisArgument(baseType, classType.thisType) : errorType;
56341             }
56342             if (isTypeDeclaration(node)) {
56343                 var symbol = getSymbolOfNode(node);
56344                 return getDeclaredTypeOfSymbol(symbol);
56345             }
56346             if (isTypeDeclarationName(node)) {
56347                 var symbol = getSymbolAtLocation(node);
56348                 return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType;
56349             }
56350             if (ts.isDeclaration(node)) {
56351                 var symbol = getSymbolOfNode(node);
56352                 return getTypeOfSymbol(symbol);
56353             }
56354             if (isDeclarationNameOrImportPropertyName(node)) {
56355                 var symbol = getSymbolAtLocation(node);
56356                 if (symbol) {
56357                     return getTypeOfSymbol(symbol);
56358                 }
56359                 return errorType;
56360             }
56361             if (ts.isBindingPattern(node)) {
56362                 return getTypeForVariableLikeDeclaration(node.parent, true) || errorType;
56363             }
56364             if (isInRightSideOfImportOrExportAssignment(node)) {
56365                 var symbol = getSymbolAtLocation(node);
56366                 if (symbol) {
56367                     var declaredType = getDeclaredTypeOfSymbol(symbol);
56368                     return declaredType !== errorType ? declaredType : getTypeOfSymbol(symbol);
56369                 }
56370             }
56371             return errorType;
56372         }
56373         function getTypeOfAssignmentPattern(expr) {
56374             ts.Debug.assert(expr.kind === 193 || expr.kind === 192);
56375             if (expr.parent.kind === 232) {
56376                 var iteratedType = checkRightHandSideOfForOf(expr.parent);
56377                 return checkDestructuringAssignment(expr, iteratedType || errorType);
56378             }
56379             if (expr.parent.kind === 209) {
56380                 var iteratedType = getTypeOfExpression(expr.parent.right);
56381                 return checkDestructuringAssignment(expr, iteratedType || errorType);
56382             }
56383             if (expr.parent.kind === 281) {
56384                 var node_4 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression);
56385                 var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_4) || errorType;
56386                 var propertyIndex = ts.indexOfNode(node_4.properties, expr.parent);
56387                 return checkObjectLiteralDestructuringPropertyAssignment(node_4, typeOfParentObjectLiteral, propertyIndex);
56388             }
56389             var node = ts.cast(expr.parent, ts.isArrayLiteralExpression);
56390             var typeOfArrayLiteral = getTypeOfAssignmentPattern(node) || errorType;
56391             var elementType = checkIteratedTypeOrElementType(65, typeOfArrayLiteral, undefinedType, expr.parent) || errorType;
56392             return checkArrayLiteralDestructuringElementAssignment(node, typeOfArrayLiteral, node.elements.indexOf(expr), elementType);
56393         }
56394         function getPropertySymbolOfDestructuringAssignment(location) {
56395             var typeOfObjectLiteral = getTypeOfAssignmentPattern(ts.cast(location.parent.parent, ts.isAssignmentPattern));
56396             return typeOfObjectLiteral && getPropertyOfType(typeOfObjectLiteral, location.escapedText);
56397         }
56398         function getRegularTypeOfExpression(expr) {
56399             if (ts.isRightSideOfQualifiedNameOrPropertyAccess(expr)) {
56400                 expr = expr.parent;
56401             }
56402             return getRegularTypeOfLiteralType(getTypeOfExpression(expr));
56403         }
56404         function getParentTypeOfClassElement(node) {
56405             var classSymbol = getSymbolOfNode(node.parent);
56406             return ts.hasModifier(node, 32)
56407                 ? getTypeOfSymbol(classSymbol)
56408                 : getDeclaredTypeOfSymbol(classSymbol);
56409         }
56410         function getClassElementPropertyKeyType(element) {
56411             var name = element.name;
56412             switch (name.kind) {
56413                 case 75:
56414                     return getLiteralType(ts.idText(name));
56415                 case 8:
56416                 case 10:
56417                     return getLiteralType(name.text);
56418                 case 154:
56419                     var nameType = checkComputedPropertyName(name);
56420                     return isTypeAssignableToKind(nameType, 12288) ? nameType : stringType;
56421                 default:
56422                     return ts.Debug.fail("Unsupported property name.");
56423             }
56424         }
56425         function getAugmentedPropertiesOfType(type) {
56426             type = getApparentType(type);
56427             var propsByName = ts.createSymbolTable(getPropertiesOfType(type));
56428             var functionType = getSignaturesOfType(type, 0).length ? globalCallableFunctionType :
56429                 getSignaturesOfType(type, 1).length ? globalNewableFunctionType :
56430                     undefined;
56431             if (functionType) {
56432                 ts.forEach(getPropertiesOfType(functionType), function (p) {
56433                     if (!propsByName.has(p.escapedName)) {
56434                         propsByName.set(p.escapedName, p);
56435                     }
56436                 });
56437             }
56438             return getNamedMembers(propsByName);
56439         }
56440         function typeHasCallOrConstructSignatures(type) {
56441             return ts.typeHasCallOrConstructSignatures(type, checker);
56442         }
56443         function getRootSymbols(symbol) {
56444             var roots = getImmediateRootSymbols(symbol);
56445             return roots ? ts.flatMap(roots, getRootSymbols) : [symbol];
56446         }
56447         function getImmediateRootSymbols(symbol) {
56448             if (ts.getCheckFlags(symbol) & 6) {
56449                 return ts.mapDefined(getSymbolLinks(symbol).containingType.types, function (type) { return getPropertyOfType(type, symbol.escapedName); });
56450             }
56451             else if (symbol.flags & 33554432) {
56452                 var _a = symbol, leftSpread = _a.leftSpread, rightSpread = _a.rightSpread, syntheticOrigin = _a.syntheticOrigin;
56453                 return leftSpread ? [leftSpread, rightSpread]
56454                     : syntheticOrigin ? [syntheticOrigin]
56455                         : ts.singleElementArray(tryGetAliasTarget(symbol));
56456             }
56457             return undefined;
56458         }
56459         function tryGetAliasTarget(symbol) {
56460             var target;
56461             var next = symbol;
56462             while (next = getSymbolLinks(next).target) {
56463                 target = next;
56464             }
56465             return target;
56466         }
56467         function isArgumentsLocalBinding(nodeIn) {
56468             if (!ts.isGeneratedIdentifier(nodeIn)) {
56469                 var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier);
56470                 if (node) {
56471                     var isPropertyName_1 = node.parent.kind === 194 && node.parent.name === node;
56472                     return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol;
56473                 }
56474             }
56475             return false;
56476         }
56477         function moduleExportsSomeValue(moduleReferenceExpression) {
56478             var moduleSymbol = resolveExternalModuleName(moduleReferenceExpression.parent, moduleReferenceExpression);
56479             if (!moduleSymbol || ts.isShorthandAmbientModuleSymbol(moduleSymbol)) {
56480                 return true;
56481             }
56482             var hasExportAssignment = hasExportAssignmentSymbol(moduleSymbol);
56483             moduleSymbol = resolveExternalModuleSymbol(moduleSymbol);
56484             var symbolLinks = getSymbolLinks(moduleSymbol);
56485             if (symbolLinks.exportsSomeValue === undefined) {
56486                 symbolLinks.exportsSomeValue = hasExportAssignment
56487                     ? !!(moduleSymbol.flags & 111551)
56488                     : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue);
56489             }
56490             return symbolLinks.exportsSomeValue;
56491             function isValue(s) {
56492                 s = resolveSymbol(s);
56493                 return s && !!(s.flags & 111551);
56494             }
56495         }
56496         function isNameOfModuleOrEnumDeclaration(node) {
56497             return ts.isModuleOrEnumDeclaration(node.parent) && node === node.parent.name;
56498         }
56499         function getReferencedExportContainer(nodeIn, prefixLocals) {
56500             var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier);
56501             if (node) {
56502                 var symbol = getReferencedValueSymbol(node, isNameOfModuleOrEnumDeclaration(node));
56503                 if (symbol) {
56504                     if (symbol.flags & 1048576) {
56505                         var exportSymbol = getMergedSymbol(symbol.exportSymbol);
56506                         if (!prefixLocals && exportSymbol.flags & 944 && !(exportSymbol.flags & 3)) {
56507                             return undefined;
56508                         }
56509                         symbol = exportSymbol;
56510                     }
56511                     var parentSymbol_1 = getParentOfSymbol(symbol);
56512                     if (parentSymbol_1) {
56513                         if (parentSymbol_1.flags & 512 && parentSymbol_1.valueDeclaration.kind === 290) {
56514                             var symbolFile = parentSymbol_1.valueDeclaration;
56515                             var referenceFile = ts.getSourceFileOfNode(node);
56516                             var symbolIsUmdExport = symbolFile !== referenceFile;
56517                             return symbolIsUmdExport ? undefined : symbolFile;
56518                         }
56519                         return ts.findAncestor(node.parent, function (n) { return ts.isModuleOrEnumDeclaration(n) && getSymbolOfNode(n) === parentSymbol_1; });
56520                     }
56521                 }
56522             }
56523         }
56524         function getReferencedImportDeclaration(nodeIn) {
56525             var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier);
56526             if (node) {
56527                 var symbol = getReferencedValueSymbol(node);
56528                 if (isNonLocalAlias(symbol, 111551) && !getTypeOnlyAliasDeclaration(symbol)) {
56529                     return getDeclarationOfAliasSymbol(symbol);
56530                 }
56531             }
56532             return undefined;
56533         }
56534         function isSymbolOfDestructuredElementOfCatchBinding(symbol) {
56535             return ts.isBindingElement(symbol.valueDeclaration)
56536                 && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 280;
56537         }
56538         function isSymbolOfDeclarationWithCollidingName(symbol) {
56539             if (symbol.flags & 418 && !ts.isSourceFile(symbol.valueDeclaration)) {
56540                 var links = getSymbolLinks(symbol);
56541                 if (links.isDeclarationWithCollidingName === undefined) {
56542                     var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration);
56543                     if (ts.isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) {
56544                         var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration);
56545                         if (resolveName(container.parent, symbol.escapedName, 111551, undefined, undefined, false)) {
56546                             links.isDeclarationWithCollidingName = true;
56547                         }
56548                         else if (nodeLinks_1.flags & 262144) {
56549                             var isDeclaredInLoop = nodeLinks_1.flags & 524288;
56550                             var inLoopInitializer = ts.isIterationStatement(container, false);
56551                             var inLoopBodyBlock = container.kind === 223 && ts.isIterationStatement(container.parent, false);
56552                             links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock));
56553                         }
56554                         else {
56555                             links.isDeclarationWithCollidingName = false;
56556                         }
56557                     }
56558                 }
56559                 return links.isDeclarationWithCollidingName;
56560             }
56561             return false;
56562         }
56563         function getReferencedDeclarationWithCollidingName(nodeIn) {
56564             if (!ts.isGeneratedIdentifier(nodeIn)) {
56565                 var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier);
56566                 if (node) {
56567                     var symbol = getReferencedValueSymbol(node);
56568                     if (symbol && isSymbolOfDeclarationWithCollidingName(symbol)) {
56569                         return symbol.valueDeclaration;
56570                     }
56571                 }
56572             }
56573             return undefined;
56574         }
56575         function isDeclarationWithCollidingName(nodeIn) {
56576             var node = ts.getParseTreeNode(nodeIn, ts.isDeclaration);
56577             if (node) {
56578                 var symbol = getSymbolOfNode(node);
56579                 if (symbol) {
56580                     return isSymbolOfDeclarationWithCollidingName(symbol);
56581                 }
56582             }
56583             return false;
56584         }
56585         function isValueAliasDeclaration(node) {
56586             switch (node.kind) {
56587                 case 253:
56588                     return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol);
56589                 case 255:
56590                 case 256:
56591                 case 258:
56592                 case 263:
56593                     var symbol = getSymbolOfNode(node) || unknownSymbol;
56594                     return isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol);
56595                 case 260:
56596                     var exportClause = node.exportClause;
56597                     return !!exportClause && (ts.isNamespaceExport(exportClause) ||
56598                         ts.some(exportClause.elements, isValueAliasDeclaration));
56599                 case 259:
56600                     return node.expression && node.expression.kind === 75 ?
56601                         isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) :
56602                         true;
56603             }
56604             return false;
56605         }
56606         function isTopLevelValueImportEqualsWithEntityName(nodeIn) {
56607             var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration);
56608             if (node === undefined || node.parent.kind !== 290 || !ts.isInternalModuleImportEqualsDeclaration(node)) {
56609                 return false;
56610             }
56611             var isValue = isAliasResolvedToValue(getSymbolOfNode(node));
56612             return isValue && node.moduleReference && !ts.nodeIsMissing(node.moduleReference);
56613         }
56614         function isAliasResolvedToValue(symbol) {
56615             var target = resolveAlias(symbol);
56616             if (target === unknownSymbol) {
56617                 return true;
56618             }
56619             return !!(target.flags & 111551) &&
56620                 (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target));
56621         }
56622         function isConstEnumOrConstEnumOnlyModule(s) {
56623             return isConstEnumSymbol(s) || !!s.constEnumOnlyModule;
56624         }
56625         function isReferencedAliasDeclaration(node, checkChildren) {
56626             if (isAliasSymbolDeclaration(node)) {
56627                 var symbol = getSymbolOfNode(node);
56628                 if (symbol && getSymbolLinks(symbol).referenced) {
56629                     return true;
56630                 }
56631                 var target = getSymbolLinks(symbol).target;
56632                 if (target && ts.getModifierFlags(node) & 1 &&
56633                     target.flags & 111551 &&
56634                     (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) {
56635                     return true;
56636                 }
56637             }
56638             if (checkChildren) {
56639                 return !!ts.forEachChild(node, function (node) { return isReferencedAliasDeclaration(node, checkChildren); });
56640             }
56641             return false;
56642         }
56643         function isImplementationOfOverload(node) {
56644             if (ts.nodeIsPresent(node.body)) {
56645                 if (ts.isGetAccessor(node) || ts.isSetAccessor(node))
56646                     return false;
56647                 var symbol = getSymbolOfNode(node);
56648                 var signaturesOfSymbol = getSignaturesOfSymbol(symbol);
56649                 return signaturesOfSymbol.length > 1 ||
56650                     (signaturesOfSymbol.length === 1 && signaturesOfSymbol[0].declaration !== node);
56651             }
56652             return false;
56653         }
56654         function isRequiredInitializedParameter(parameter) {
56655             return !!strictNullChecks &&
56656                 !isOptionalParameter(parameter) &&
56657                 !ts.isJSDocParameterTag(parameter) &&
56658                 !!parameter.initializer &&
56659                 !ts.hasModifier(parameter, 92);
56660         }
56661         function isOptionalUninitializedParameterProperty(parameter) {
56662             return strictNullChecks &&
56663                 isOptionalParameter(parameter) &&
56664                 !parameter.initializer &&
56665                 ts.hasModifier(parameter, 92);
56666         }
56667         function isExpandoFunctionDeclaration(node) {
56668             var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration);
56669             if (!declaration) {
56670                 return false;
56671             }
56672             var symbol = getSymbolOfNode(declaration);
56673             if (!symbol || !(symbol.flags & 16)) {
56674                 return false;
56675             }
56676             return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); });
56677         }
56678         function getPropertiesOfContainerFunction(node) {
56679             var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration);
56680             if (!declaration) {
56681                 return ts.emptyArray;
56682             }
56683             var symbol = getSymbolOfNode(declaration);
56684             return symbol && getPropertiesOfType(getTypeOfSymbol(symbol)) || ts.emptyArray;
56685         }
56686         function getNodeCheckFlags(node) {
56687             return getNodeLinks(node).flags || 0;
56688         }
56689         function getEnumMemberValue(node) {
56690             computeEnumMemberValues(node.parent);
56691             return getNodeLinks(node).enumMemberValue;
56692         }
56693         function canHaveConstantValue(node) {
56694             switch (node.kind) {
56695                 case 284:
56696                 case 194:
56697                 case 195:
56698                     return true;
56699             }
56700             return false;
56701         }
56702         function getConstantValue(node) {
56703             if (node.kind === 284) {
56704                 return getEnumMemberValue(node);
56705             }
56706             var symbol = getNodeLinks(node).resolvedSymbol;
56707             if (symbol && (symbol.flags & 8)) {
56708                 var member = symbol.valueDeclaration;
56709                 if (ts.isEnumConst(member.parent)) {
56710                     return getEnumMemberValue(member);
56711                 }
56712             }
56713             return undefined;
56714         }
56715         function isFunctionType(type) {
56716             return !!(type.flags & 524288) && getSignaturesOfType(type, 0).length > 0;
56717         }
56718         function getTypeReferenceSerializationKind(typeNameIn, location) {
56719             var typeName = ts.getParseTreeNode(typeNameIn, ts.isEntityName);
56720             if (!typeName)
56721                 return ts.TypeReferenceSerializationKind.Unknown;
56722             if (location) {
56723                 location = ts.getParseTreeNode(location);
56724                 if (!location)
56725                     return ts.TypeReferenceSerializationKind.Unknown;
56726             }
56727             var valueSymbol = resolveEntityName(typeName, 111551, true, false, location);
56728             var typeSymbol = resolveEntityName(typeName, 788968, true, false, location);
56729             if (valueSymbol && valueSymbol === typeSymbol) {
56730                 var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(false);
56731                 if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) {
56732                     return ts.TypeReferenceSerializationKind.Promise;
56733                 }
56734                 var constructorType = getTypeOfSymbol(valueSymbol);
56735                 if (constructorType && isConstructorType(constructorType)) {
56736                     return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue;
56737                 }
56738             }
56739             if (!typeSymbol) {
56740                 return ts.TypeReferenceSerializationKind.Unknown;
56741             }
56742             var type = getDeclaredTypeOfSymbol(typeSymbol);
56743             if (type === errorType) {
56744                 return ts.TypeReferenceSerializationKind.Unknown;
56745             }
56746             else if (type.flags & 3) {
56747                 return ts.TypeReferenceSerializationKind.ObjectType;
56748             }
56749             else if (isTypeAssignableToKind(type, 16384 | 98304 | 131072)) {
56750                 return ts.TypeReferenceSerializationKind.VoidNullableOrNeverType;
56751             }
56752             else if (isTypeAssignableToKind(type, 528)) {
56753                 return ts.TypeReferenceSerializationKind.BooleanType;
56754             }
56755             else if (isTypeAssignableToKind(type, 296)) {
56756                 return ts.TypeReferenceSerializationKind.NumberLikeType;
56757             }
56758             else if (isTypeAssignableToKind(type, 2112)) {
56759                 return ts.TypeReferenceSerializationKind.BigIntLikeType;
56760             }
56761             else if (isTypeAssignableToKind(type, 132)) {
56762                 return ts.TypeReferenceSerializationKind.StringLikeType;
56763             }
56764             else if (isTupleType(type)) {
56765                 return ts.TypeReferenceSerializationKind.ArrayLikeType;
56766             }
56767             else if (isTypeAssignableToKind(type, 12288)) {
56768                 return ts.TypeReferenceSerializationKind.ESSymbolType;
56769             }
56770             else if (isFunctionType(type)) {
56771                 return ts.TypeReferenceSerializationKind.TypeWithCallSignature;
56772             }
56773             else if (isArrayType(type)) {
56774                 return ts.TypeReferenceSerializationKind.ArrayLikeType;
56775             }
56776             else {
56777                 return ts.TypeReferenceSerializationKind.ObjectType;
56778             }
56779         }
56780         function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) {
56781             var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor);
56782             if (!declaration) {
56783                 return ts.createToken(125);
56784             }
56785             var symbol = getSymbolOfNode(declaration);
56786             var type = symbol && !(symbol.flags & (2048 | 131072))
56787                 ? getWidenedLiteralType(getTypeOfSymbol(symbol))
56788                 : errorType;
56789             if (type.flags & 8192 &&
56790                 type.symbol === symbol) {
56791                 flags |= 1048576;
56792             }
56793             if (addUndefined) {
56794                 type = getOptionalType(type);
56795             }
56796             return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024, tracker);
56797         }
56798         function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) {
56799             var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike);
56800             if (!signatureDeclaration) {
56801                 return ts.createToken(125);
56802             }
56803             var signature = getSignatureFromDeclaration(signatureDeclaration);
56804             return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024, tracker);
56805         }
56806         function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) {
56807             var expr = ts.getParseTreeNode(exprIn, ts.isExpression);
56808             if (!expr) {
56809                 return ts.createToken(125);
56810             }
56811             var type = getWidenedType(getRegularTypeOfExpression(expr));
56812             return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024, tracker);
56813         }
56814         function hasGlobalName(name) {
56815             return globals.has(ts.escapeLeadingUnderscores(name));
56816         }
56817         function getReferencedValueSymbol(reference, startInDeclarationContainer) {
56818             var resolvedSymbol = getNodeLinks(reference).resolvedSymbol;
56819             if (resolvedSymbol) {
56820                 return resolvedSymbol;
56821             }
56822             var location = reference;
56823             if (startInDeclarationContainer) {
56824                 var parent = reference.parent;
56825                 if (ts.isDeclaration(parent) && reference === parent.name) {
56826                     location = getDeclarationContainer(parent);
56827                 }
56828             }
56829             return resolveName(location, reference.escapedText, 111551 | 1048576 | 2097152, undefined, undefined, true);
56830         }
56831         function getReferencedValueDeclaration(referenceIn) {
56832             if (!ts.isGeneratedIdentifier(referenceIn)) {
56833                 var reference = ts.getParseTreeNode(referenceIn, ts.isIdentifier);
56834                 if (reference) {
56835                     var symbol = getReferencedValueSymbol(reference);
56836                     if (symbol) {
56837                         return getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration;
56838                     }
56839                 }
56840             }
56841             return undefined;
56842         }
56843         function isLiteralConstDeclaration(node) {
56844             if (ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node)) {
56845                 return isFreshLiteralType(getTypeOfSymbol(getSymbolOfNode(node)));
56846             }
56847             return false;
56848         }
56849         function literalTypeToNode(type, enclosing, tracker) {
56850             var enumResult = type.flags & 1024 ? nodeBuilder.symbolToExpression(type.symbol, 111551, enclosing, undefined, tracker)
56851                 : type === trueType ? ts.createTrue() : type === falseType && ts.createFalse();
56852             return enumResult || ts.createLiteral(type.value);
56853         }
56854         function createLiteralConstValue(node, tracker) {
56855             var type = getTypeOfSymbol(getSymbolOfNode(node));
56856             return literalTypeToNode(type, node, tracker);
56857         }
56858         function getJsxFactoryEntity(location) {
56859             return location ? (getJsxNamespace(location), (ts.getSourceFileOfNode(location).localJsxFactory || _jsxFactoryEntity)) : _jsxFactoryEntity;
56860         }
56861         function createResolver() {
56862             var resolvedTypeReferenceDirectives = host.getResolvedTypeReferenceDirectives();
56863             var fileToDirective;
56864             if (resolvedTypeReferenceDirectives) {
56865                 fileToDirective = ts.createMap();
56866                 resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key) {
56867                     if (!resolvedDirective || !resolvedDirective.resolvedFileName) {
56868                         return;
56869                     }
56870                     var file = host.getSourceFile(resolvedDirective.resolvedFileName);
56871                     if (file) {
56872                         addReferencedFilesToTypeDirective(file, key);
56873                     }
56874                 });
56875             }
56876             return {
56877                 getReferencedExportContainer: getReferencedExportContainer,
56878                 getReferencedImportDeclaration: getReferencedImportDeclaration,
56879                 getReferencedDeclarationWithCollidingName: getReferencedDeclarationWithCollidingName,
56880                 isDeclarationWithCollidingName: isDeclarationWithCollidingName,
56881                 isValueAliasDeclaration: function (node) {
56882                     node = ts.getParseTreeNode(node);
56883                     return node ? isValueAliasDeclaration(node) : true;
56884                 },
56885                 hasGlobalName: hasGlobalName,
56886                 isReferencedAliasDeclaration: function (node, checkChildren) {
56887                     node = ts.getParseTreeNode(node);
56888                     return node ? isReferencedAliasDeclaration(node, checkChildren) : true;
56889                 },
56890                 getNodeCheckFlags: function (node) {
56891                     node = ts.getParseTreeNode(node);
56892                     return node ? getNodeCheckFlags(node) : 0;
56893                 },
56894                 isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName,
56895                 isDeclarationVisible: isDeclarationVisible,
56896                 isImplementationOfOverload: isImplementationOfOverload,
56897                 isRequiredInitializedParameter: isRequiredInitializedParameter,
56898                 isOptionalUninitializedParameterProperty: isOptionalUninitializedParameterProperty,
56899                 isExpandoFunctionDeclaration: isExpandoFunctionDeclaration,
56900                 getPropertiesOfContainerFunction: getPropertiesOfContainerFunction,
56901                 createTypeOfDeclaration: createTypeOfDeclaration,
56902                 createReturnTypeOfSignatureDeclaration: createReturnTypeOfSignatureDeclaration,
56903                 createTypeOfExpression: createTypeOfExpression,
56904                 createLiteralConstValue: createLiteralConstValue,
56905                 isSymbolAccessible: isSymbolAccessible,
56906                 isEntityNameVisible: isEntityNameVisible,
56907                 getConstantValue: function (nodeIn) {
56908                     var node = ts.getParseTreeNode(nodeIn, canHaveConstantValue);
56909                     return node ? getConstantValue(node) : undefined;
56910                 },
56911                 collectLinkedAliases: collectLinkedAliases,
56912                 getReferencedValueDeclaration: getReferencedValueDeclaration,
56913                 getTypeReferenceSerializationKind: getTypeReferenceSerializationKind,
56914                 isOptionalParameter: isOptionalParameter,
56915                 moduleExportsSomeValue: moduleExportsSomeValue,
56916                 isArgumentsLocalBinding: isArgumentsLocalBinding,
56917                 getExternalModuleFileFromDeclaration: getExternalModuleFileFromDeclaration,
56918                 getTypeReferenceDirectivesForEntityName: getTypeReferenceDirectivesForEntityName,
56919                 getTypeReferenceDirectivesForSymbol: getTypeReferenceDirectivesForSymbol,
56920                 isLiteralConstDeclaration: isLiteralConstDeclaration,
56921                 isLateBound: function (nodeIn) {
56922                     var node = ts.getParseTreeNode(nodeIn, ts.isDeclaration);
56923                     var symbol = node && getSymbolOfNode(node);
56924                     return !!(symbol && ts.getCheckFlags(symbol) & 4096);
56925                 },
56926                 getJsxFactoryEntity: getJsxFactoryEntity,
56927                 getAllAccessorDeclarations: function (accessor) {
56928                     accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration);
56929                     var otherKind = accessor.kind === 164 ? 163 : 164;
56930                     var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(accessor), otherKind);
56931                     var firstAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? otherAccessor : accessor;
56932                     var secondAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? accessor : otherAccessor;
56933                     var setAccessor = accessor.kind === 164 ? accessor : otherAccessor;
56934                     var getAccessor = accessor.kind === 163 ? accessor : otherAccessor;
56935                     return {
56936                         firstAccessor: firstAccessor,
56937                         secondAccessor: secondAccessor,
56938                         setAccessor: setAccessor,
56939                         getAccessor: getAccessor
56940                     };
56941                 },
56942                 getSymbolOfExternalModuleSpecifier: function (moduleName) { return resolveExternalModuleNameWorker(moduleName, moduleName, undefined); },
56943                 isBindingCapturedByNode: function (node, decl) {
56944                     var parseNode = ts.getParseTreeNode(node);
56945                     var parseDecl = ts.getParseTreeNode(decl);
56946                     return !!parseNode && !!parseDecl && (ts.isVariableDeclaration(parseDecl) || ts.isBindingElement(parseDecl)) && isBindingCapturedByNode(parseNode, parseDecl);
56947                 },
56948                 getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) {
56949                     var n = ts.getParseTreeNode(node);
56950                     ts.Debug.assert(n && n.kind === 290, "Non-sourcefile node passed into getDeclarationsForSourceFile");
56951                     var sym = getSymbolOfNode(node);
56952                     if (!sym) {
56953                         return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled);
56954                     }
56955                     return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker, bundled);
56956                 },
56957                 isImportRequiredByAugmentation: isImportRequiredByAugmentation,
56958             };
56959             function isImportRequiredByAugmentation(node) {
56960                 var file = ts.getSourceFileOfNode(node);
56961                 if (!file.symbol)
56962                     return false;
56963                 var importTarget = getExternalModuleFileFromDeclaration(node);
56964                 if (!importTarget)
56965                     return false;
56966                 if (importTarget === file)
56967                     return false;
56968                 var exports = getExportsOfModule(file.symbol);
56969                 for (var _i = 0, _a = ts.arrayFrom(exports.values()); _i < _a.length; _i++) {
56970                     var s = _a[_i];
56971                     if (s.mergeId) {
56972                         var merged = getMergedSymbol(s);
56973                         for (var _b = 0, _c = merged.declarations; _b < _c.length; _b++) {
56974                             var d = _c[_b];
56975                             var declFile = ts.getSourceFileOfNode(d);
56976                             if (declFile === importTarget) {
56977                                 return true;
56978                             }
56979                         }
56980                     }
56981                 }
56982                 return false;
56983             }
56984             function isInHeritageClause(node) {
56985                 return node.parent && node.parent.kind === 216 && node.parent.parent && node.parent.parent.kind === 279;
56986             }
56987             function getTypeReferenceDirectivesForEntityName(node) {
56988                 if (!fileToDirective) {
56989                     return undefined;
56990                 }
56991                 var meaning = 788968 | 1920;
56992                 if ((node.kind === 75 && isInTypeQuery(node)) || (node.kind === 194 && !isInHeritageClause(node))) {
56993                     meaning = 111551 | 1048576;
56994                 }
56995                 var symbol = resolveEntityName(node, meaning, true);
56996                 return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined;
56997             }
56998             function getTypeReferenceDirectivesForSymbol(symbol, meaning) {
56999                 if (!fileToDirective) {
57000                     return undefined;
57001                 }
57002                 if (!isSymbolFromTypeDeclarationFile(symbol)) {
57003                     return undefined;
57004                 }
57005                 var typeReferenceDirectives;
57006                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
57007                     var decl = _a[_i];
57008                     if (decl.symbol && decl.symbol.flags & meaning) {
57009                         var file = ts.getSourceFileOfNode(decl);
57010                         var typeReferenceDirective = fileToDirective.get(file.path);
57011                         if (typeReferenceDirective) {
57012                             (typeReferenceDirectives || (typeReferenceDirectives = [])).push(typeReferenceDirective);
57013                         }
57014                         else {
57015                             return undefined;
57016                         }
57017                     }
57018                 }
57019                 return typeReferenceDirectives;
57020             }
57021             function isSymbolFromTypeDeclarationFile(symbol) {
57022                 if (!symbol.declarations) {
57023                     return false;
57024                 }
57025                 var current = symbol;
57026                 while (true) {
57027                     var parent = getParentOfSymbol(current);
57028                     if (parent) {
57029                         current = parent;
57030                     }
57031                     else {
57032                         break;
57033                     }
57034                 }
57035                 if (current.valueDeclaration && current.valueDeclaration.kind === 290 && current.flags & 512) {
57036                     return false;
57037                 }
57038                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
57039                     var decl = _a[_i];
57040                     var file = ts.getSourceFileOfNode(decl);
57041                     if (fileToDirective.has(file.path)) {
57042                         return true;
57043                     }
57044                 }
57045                 return false;
57046             }
57047             function addReferencedFilesToTypeDirective(file, key) {
57048                 if (fileToDirective.has(file.path))
57049                     return;
57050                 fileToDirective.set(file.path, key);
57051                 for (var _i = 0, _a = file.referencedFiles; _i < _a.length; _i++) {
57052                     var fileName = _a[_i].fileName;
57053                     var resolvedFile = ts.resolveTripleslashReference(fileName, file.originalFileName);
57054                     var referencedFile = host.getSourceFile(resolvedFile);
57055                     if (referencedFile) {
57056                         addReferencedFilesToTypeDirective(referencedFile, key);
57057                     }
57058                 }
57059             }
57060         }
57061         function getExternalModuleFileFromDeclaration(declaration) {
57062             var specifier = declaration.kind === 249 ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration);
57063             var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, undefined);
57064             if (!moduleSymbol) {
57065                 return undefined;
57066             }
57067             return ts.getDeclarationOfKind(moduleSymbol, 290);
57068         }
57069         function initializeTypeChecker() {
57070             for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) {
57071                 var file = _a[_i];
57072                 ts.bindSourceFile(file, compilerOptions);
57073             }
57074             amalgamatedDuplicates = ts.createMap();
57075             var augmentations;
57076             for (var _b = 0, _c = host.getSourceFiles(); _b < _c.length; _b++) {
57077                 var file = _c[_b];
57078                 if (file.redirectInfo) {
57079                     continue;
57080                 }
57081                 if (!ts.isExternalOrCommonJsModule(file)) {
57082                     var fileGlobalThisSymbol = file.locals.get("globalThis");
57083                     if (fileGlobalThisSymbol) {
57084                         for (var _d = 0, _e = fileGlobalThisSymbol.declarations; _d < _e.length; _d++) {
57085                             var declaration = _e[_d];
57086                             diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0, "globalThis"));
57087                         }
57088                     }
57089                     mergeSymbolTable(globals, file.locals);
57090                 }
57091                 if (file.jsGlobalAugmentations) {
57092                     mergeSymbolTable(globals, file.jsGlobalAugmentations);
57093                 }
57094                 if (file.patternAmbientModules && file.patternAmbientModules.length) {
57095                     patternAmbientModules = ts.concatenate(patternAmbientModules, file.patternAmbientModules);
57096                 }
57097                 if (file.moduleAugmentations.length) {
57098                     (augmentations || (augmentations = [])).push(file.moduleAugmentations);
57099                 }
57100                 if (file.symbol && file.symbol.globalExports) {
57101                     var source = file.symbol.globalExports;
57102                     source.forEach(function (sourceSymbol, id) {
57103                         if (!globals.has(id)) {
57104                             globals.set(id, sourceSymbol);
57105                         }
57106                     });
57107                 }
57108             }
57109             if (augmentations) {
57110                 for (var _f = 0, augmentations_1 = augmentations; _f < augmentations_1.length; _f++) {
57111                     var list = augmentations_1[_f];
57112                     for (var _g = 0, list_1 = list; _g < list_1.length; _g++) {
57113                         var augmentation = list_1[_g];
57114                         if (!ts.isGlobalScopeAugmentation(augmentation.parent))
57115                             continue;
57116                         mergeModuleAugmentation(augmentation);
57117                     }
57118                 }
57119             }
57120             addToSymbolTable(globals, builtinGlobals, ts.Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0);
57121             getSymbolLinks(undefinedSymbol).type = undefinedWideningType;
57122             getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments", 0, true);
57123             getSymbolLinks(unknownSymbol).type = errorType;
57124             getSymbolLinks(globalThisSymbol).type = createObjectType(16, globalThisSymbol);
57125             globalArrayType = getGlobalType("Array", 1, true);
57126             globalObjectType = getGlobalType("Object", 0, true);
57127             globalFunctionType = getGlobalType("Function", 0, true);
57128             globalCallableFunctionType = strictBindCallApply && getGlobalType("CallableFunction", 0, true) || globalFunctionType;
57129             globalNewableFunctionType = strictBindCallApply && getGlobalType("NewableFunction", 0, true) || globalFunctionType;
57130             globalStringType = getGlobalType("String", 0, true);
57131             globalNumberType = getGlobalType("Number", 0, true);
57132             globalBooleanType = getGlobalType("Boolean", 0, true);
57133             globalRegExpType = getGlobalType("RegExp", 0, true);
57134             anyArrayType = createArrayType(anyType);
57135             autoArrayType = createArrayType(autoType);
57136             if (autoArrayType === emptyObjectType) {
57137                 autoArrayType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
57138             }
57139             globalReadonlyArrayType = getGlobalTypeOrUndefined("ReadonlyArray", 1) || globalArrayType;
57140             anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType;
57141             globalThisType = getGlobalTypeOrUndefined("ThisType", 1);
57142             if (augmentations) {
57143                 for (var _h = 0, augmentations_2 = augmentations; _h < augmentations_2.length; _h++) {
57144                     var list = augmentations_2[_h];
57145                     for (var _j = 0, list_2 = list; _j < list_2.length; _j++) {
57146                         var augmentation = list_2[_j];
57147                         if (ts.isGlobalScopeAugmentation(augmentation.parent))
57148                             continue;
57149                         mergeModuleAugmentation(augmentation);
57150                     }
57151                 }
57152             }
57153             amalgamatedDuplicates.forEach(function (_a) {
57154                 var firstFile = _a.firstFile, secondFile = _a.secondFile, conflictingSymbols = _a.conflictingSymbols;
57155                 if (conflictingSymbols.size < 8) {
57156                     conflictingSymbols.forEach(function (_a, symbolName) {
57157                         var isBlockScoped = _a.isBlockScoped, firstFileLocations = _a.firstFileLocations, secondFileLocations = _a.secondFileLocations;
57158                         var message = isBlockScoped ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0;
57159                         for (var _i = 0, firstFileLocations_1 = firstFileLocations; _i < firstFileLocations_1.length; _i++) {
57160                             var node = firstFileLocations_1[_i];
57161                             addDuplicateDeclarationError(node, message, symbolName, secondFileLocations);
57162                         }
57163                         for (var _b = 0, secondFileLocations_1 = secondFileLocations; _b < secondFileLocations_1.length; _b++) {
57164                             var node = secondFileLocations_1[_b];
57165                             addDuplicateDeclarationError(node, message, symbolName, firstFileLocations);
57166                         }
57167                     });
57168                 }
57169                 else {
57170                     var list = ts.arrayFrom(conflictingSymbols.keys()).join(", ");
57171                     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)));
57172                     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)));
57173                 }
57174             });
57175             amalgamatedDuplicates = undefined;
57176         }
57177         function checkExternalEmitHelpers(location, helpers) {
57178             if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) {
57179                 var sourceFile = ts.getSourceFileOfNode(location);
57180                 if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 8388608)) {
57181                     var helpersModule = resolveHelpersModule(sourceFile, location);
57182                     if (helpersModule !== unknownSymbol) {
57183                         var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers;
57184                         for (var helper = 1; helper <= 1048576; helper <<= 1) {
57185                             if (uncheckedHelpers & helper) {
57186                                 var name = getHelperName(helper);
57187                                 var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551);
57188                                 if (!symbol) {
57189                                     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);
57190                                 }
57191                             }
57192                         }
57193                     }
57194                     requestedExternalEmitHelpers |= helpers;
57195                 }
57196             }
57197         }
57198         function getHelperName(helper) {
57199             switch (helper) {
57200                 case 1: return "__extends";
57201                 case 2: return "__assign";
57202                 case 4: return "__rest";
57203                 case 8: return "__decorate";
57204                 case 16: return "__metadata";
57205                 case 32: return "__param";
57206                 case 64: return "__awaiter";
57207                 case 128: return "__generator";
57208                 case 256: return "__values";
57209                 case 512: return "__read";
57210                 case 1024: return "__spread";
57211                 case 2048: return "__spreadArrays";
57212                 case 4096: return "__await";
57213                 case 8192: return "__asyncGenerator";
57214                 case 16384: return "__asyncDelegator";
57215                 case 32768: return "__asyncValues";
57216                 case 65536: return "__exportStar";
57217                 case 131072: return "__makeTemplateObject";
57218                 case 262144: return "__classPrivateFieldGet";
57219                 case 524288: return "__classPrivateFieldSet";
57220                 case 1048576: return "__createBinding";
57221                 default: return ts.Debug.fail("Unrecognized helper");
57222             }
57223         }
57224         function resolveHelpersModule(node, errorNode) {
57225             if (!externalHelpersModule) {
57226                 externalHelpersModule = resolveExternalModule(node, ts.externalHelpersModuleNameText, ts.Diagnostics.This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found, errorNode) || unknownSymbol;
57227             }
57228             return externalHelpersModule;
57229         }
57230         function checkGrammarDecoratorsAndModifiers(node) {
57231             return checkGrammarDecorators(node) || checkGrammarModifiers(node);
57232         }
57233         function checkGrammarDecorators(node) {
57234             if (!node.decorators) {
57235                 return false;
57236             }
57237             if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) {
57238                 if (node.kind === 161 && !ts.nodeIsPresent(node.body)) {
57239                     return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload);
57240                 }
57241                 else {
57242                     return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here);
57243                 }
57244             }
57245             else if (node.kind === 163 || node.kind === 164) {
57246                 var accessors = ts.getAllAccessorDeclarations(node.parent.members, node);
57247                 if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) {
57248                     return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name);
57249                 }
57250             }
57251             return false;
57252         }
57253         function checkGrammarModifiers(node) {
57254             var quickResult = reportObviousModifierErrors(node);
57255             if (quickResult !== undefined) {
57256                 return quickResult;
57257             }
57258             var lastStatic, lastDeclare, lastAsync, lastReadonly;
57259             var flags = 0;
57260             for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) {
57261                 var modifier = _a[_i];
57262                 if (modifier.kind !== 138) {
57263                     if (node.kind === 158 || node.kind === 160) {
57264                         return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind));
57265                     }
57266                     if (node.kind === 167) {
57267                         return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind));
57268                     }
57269                 }
57270                 switch (modifier.kind) {
57271                     case 81:
57272                         if (node.kind !== 248) {
57273                             return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(81));
57274                         }
57275                         break;
57276                     case 119:
57277                     case 118:
57278                     case 117:
57279                         var text = visibilityToString(ts.modifierToFlag(modifier.kind));
57280                         if (flags & 28) {
57281                             return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen);
57282                         }
57283                         else if (flags & 32) {
57284                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static");
57285                         }
57286                         else if (flags & 64) {
57287                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "readonly");
57288                         }
57289                         else if (flags & 256) {
57290                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async");
57291                         }
57292                         else if (node.parent.kind === 250 || node.parent.kind === 290) {
57293                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text);
57294                         }
57295                         else if (flags & 128) {
57296                             if (modifier.kind === 117) {
57297                                 return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract");
57298                             }
57299                             else {
57300                                 return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract");
57301                             }
57302                         }
57303                         else if (ts.isPrivateIdentifierPropertyDeclaration(node)) {
57304                             return grammarErrorOnNode(modifier, ts.Diagnostics.An_accessibility_modifier_cannot_be_used_with_a_private_identifier);
57305                         }
57306                         flags |= ts.modifierToFlag(modifier.kind);
57307                         break;
57308                     case 120:
57309                         if (flags & 32) {
57310                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static");
57311                         }
57312                         else if (flags & 64) {
57313                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "readonly");
57314                         }
57315                         else if (flags & 256) {
57316                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async");
57317                         }
57318                         else if (node.parent.kind === 250 || node.parent.kind === 290) {
57319                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static");
57320                         }
57321                         else if (node.kind === 156) {
57322                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static");
57323                         }
57324                         else if (flags & 128) {
57325                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract");
57326                         }
57327                         else if (ts.isPrivateIdentifierPropertyDeclaration(node)) {
57328                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "static");
57329                         }
57330                         flags |= 32;
57331                         lastStatic = modifier;
57332                         break;
57333                     case 138:
57334                         if (flags & 64) {
57335                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly");
57336                         }
57337                         else if (node.kind !== 159 && node.kind !== 158 && node.kind !== 167 && node.kind !== 156) {
57338                             return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature);
57339                         }
57340                         flags |= 64;
57341                         lastReadonly = modifier;
57342                         break;
57343                     case 89:
57344                         if (flags & 1) {
57345                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export");
57346                         }
57347                         else if (flags & 2) {
57348                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare");
57349                         }
57350                         else if (flags & 128) {
57351                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract");
57352                         }
57353                         else if (flags & 256) {
57354                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async");
57355                         }
57356                         else if (ts.isClassLike(node.parent)) {
57357                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export");
57358                         }
57359                         else if (node.kind === 156) {
57360                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export");
57361                         }
57362                         flags |= 1;
57363                         break;
57364                     case 84:
57365                         var container = node.parent.kind === 290 ? node.parent : node.parent.parent;
57366                         if (container.kind === 249 && !ts.isAmbientModule(container)) {
57367                             return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module);
57368                         }
57369                         flags |= 512;
57370                         break;
57371                     case 130:
57372                         if (flags & 2) {
57373                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare");
57374                         }
57375                         else if (flags & 256) {
57376                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async");
57377                         }
57378                         else if (ts.isClassLike(node.parent) && !ts.isPropertyDeclaration(node)) {
57379                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare");
57380                         }
57381                         else if (node.kind === 156) {
57382                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare");
57383                         }
57384                         else if ((node.parent.flags & 8388608) && node.parent.kind === 250) {
57385                             return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context);
57386                         }
57387                         else if (ts.isPrivateIdentifierPropertyDeclaration(node)) {
57388                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "declare");
57389                         }
57390                         flags |= 2;
57391                         lastDeclare = modifier;
57392                         break;
57393                     case 122:
57394                         if (flags & 128) {
57395                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract");
57396                         }
57397                         if (node.kind !== 245) {
57398                             if (node.kind !== 161 &&
57399                                 node.kind !== 159 &&
57400                                 node.kind !== 163 &&
57401                                 node.kind !== 164) {
57402                                 return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration);
57403                             }
57404                             if (!(node.parent.kind === 245 && ts.hasModifier(node.parent, 128))) {
57405                                 return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class);
57406                             }
57407                             if (flags & 32) {
57408                                 return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract");
57409                             }
57410                             if (flags & 8) {
57411                                 return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract");
57412                             }
57413                         }
57414                         if (ts.isNamedDeclaration(node) && node.name.kind === 76) {
57415                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "abstract");
57416                         }
57417                         flags |= 128;
57418                         break;
57419                     case 126:
57420                         if (flags & 256) {
57421                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async");
57422                         }
57423                         else if (flags & 2 || node.parent.flags & 8388608) {
57424                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async");
57425                         }
57426                         else if (node.kind === 156) {
57427                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async");
57428                         }
57429                         flags |= 256;
57430                         lastAsync = modifier;
57431                         break;
57432                 }
57433             }
57434             if (node.kind === 162) {
57435                 if (flags & 32) {
57436                     return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static");
57437                 }
57438                 if (flags & 128) {
57439                     return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract");
57440                 }
57441                 else if (flags & 256) {
57442                     return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async");
57443                 }
57444                 else if (flags & 64) {
57445                     return grammarErrorOnNode(lastReadonly, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "readonly");
57446                 }
57447                 return false;
57448             }
57449             else if ((node.kind === 254 || node.kind === 253) && flags & 2) {
57450                 return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare");
57451             }
57452             else if (node.kind === 156 && (flags & 92) && ts.isBindingPattern(node.name)) {
57453                 return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern);
57454             }
57455             else if (node.kind === 156 && (flags & 92) && node.dotDotDotToken) {
57456                 return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter);
57457             }
57458             if (flags & 256) {
57459                 return checkGrammarAsyncModifier(node, lastAsync);
57460             }
57461             return false;
57462         }
57463         function reportObviousModifierErrors(node) {
57464             return !node.modifiers
57465                 ? false
57466                 : shouldReportBadModifier(node)
57467                     ? grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here)
57468                     : undefined;
57469         }
57470         function shouldReportBadModifier(node) {
57471             switch (node.kind) {
57472                 case 163:
57473                 case 164:
57474                 case 162:
57475                 case 159:
57476                 case 158:
57477                 case 161:
57478                 case 160:
57479                 case 167:
57480                 case 249:
57481                 case 254:
57482                 case 253:
57483                 case 260:
57484                 case 259:
57485                 case 201:
57486                 case 202:
57487                 case 156:
57488                     return false;
57489                 default:
57490                     if (node.parent.kind === 250 || node.parent.kind === 290) {
57491                         return false;
57492                     }
57493                     switch (node.kind) {
57494                         case 244:
57495                             return nodeHasAnyModifiersExcept(node, 126);
57496                         case 245:
57497                             return nodeHasAnyModifiersExcept(node, 122);
57498                         case 246:
57499                         case 225:
57500                         case 247:
57501                             return true;
57502                         case 248:
57503                             return nodeHasAnyModifiersExcept(node, 81);
57504                         default:
57505                             ts.Debug.fail();
57506                             return false;
57507                     }
57508             }
57509         }
57510         function nodeHasAnyModifiersExcept(node, allowedModifier) {
57511             return node.modifiers.length > 1 || node.modifiers[0].kind !== allowedModifier;
57512         }
57513         function checkGrammarAsyncModifier(node, asyncModifier) {
57514             switch (node.kind) {
57515                 case 161:
57516                 case 244:
57517                 case 201:
57518                 case 202:
57519                     return false;
57520             }
57521             return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async");
57522         }
57523         function checkGrammarForDisallowedTrailingComma(list, diag) {
57524             if (diag === void 0) { diag = ts.Diagnostics.Trailing_comma_not_allowed; }
57525             if (list && list.hasTrailingComma) {
57526                 return grammarErrorAtPos(list[0], list.end - ",".length, ",".length, diag);
57527             }
57528             return false;
57529         }
57530         function checkGrammarTypeParameterList(typeParameters, file) {
57531             if (typeParameters && typeParameters.length === 0) {
57532                 var start = typeParameters.pos - "<".length;
57533                 var end = ts.skipTrivia(file.text, typeParameters.end) + ">".length;
57534                 return grammarErrorAtPos(file, start, end - start, ts.Diagnostics.Type_parameter_list_cannot_be_empty);
57535             }
57536             return false;
57537         }
57538         function checkGrammarParameterList(parameters) {
57539             var seenOptionalParameter = false;
57540             var parameterCount = parameters.length;
57541             for (var i = 0; i < parameterCount; i++) {
57542                 var parameter = parameters[i];
57543                 if (parameter.dotDotDotToken) {
57544                     if (i !== (parameterCount - 1)) {
57545                         return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
57546                     }
57547                     if (!(parameter.flags & 8388608)) {
57548                         checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
57549                     }
57550                     if (parameter.questionToken) {
57551                         return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_rest_parameter_cannot_be_optional);
57552                     }
57553                     if (parameter.initializer) {
57554                         return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer);
57555                     }
57556                 }
57557                 else if (parameter.questionToken) {
57558                     seenOptionalParameter = true;
57559                     if (parameter.initializer) {
57560                         return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer);
57561                     }
57562                 }
57563                 else if (seenOptionalParameter && !parameter.initializer) {
57564                     return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter);
57565                 }
57566             }
57567         }
57568         function getNonSimpleParameters(parameters) {
57569             return ts.filter(parameters, function (parameter) { return !!parameter.initializer || ts.isBindingPattern(parameter.name) || ts.isRestParameter(parameter); });
57570         }
57571         function checkGrammarForUseStrictSimpleParameterList(node) {
57572             if (languageVersion >= 3) {
57573                 var useStrictDirective_1 = node.body && ts.isBlock(node.body) && ts.findUseStrictPrologue(node.body.statements);
57574                 if (useStrictDirective_1) {
57575                     var nonSimpleParameters = getNonSimpleParameters(node.parameters);
57576                     if (ts.length(nonSimpleParameters)) {
57577                         ts.forEach(nonSimpleParameters, function (parameter) {
57578                             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));
57579                         });
57580                         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)); });
57581                         ts.addRelatedInfo.apply(void 0, __spreadArrays([error(useStrictDirective_1, ts.Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list)], diagnostics_1));
57582                         return true;
57583                     }
57584                 }
57585             }
57586             return false;
57587         }
57588         function checkGrammarFunctionLikeDeclaration(node) {
57589             var file = ts.getSourceFileOfNode(node);
57590             return checkGrammarDecoratorsAndModifiers(node) || checkGrammarTypeParameterList(node.typeParameters, file) ||
57591                 checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file) ||
57592                 (ts.isFunctionLikeDeclaration(node) && checkGrammarForUseStrictSimpleParameterList(node));
57593         }
57594         function checkGrammarClassLikeDeclaration(node) {
57595             var file = ts.getSourceFileOfNode(node);
57596             return checkGrammarClassDeclarationHeritageClauses(node) || checkGrammarTypeParameterList(node.typeParameters, file);
57597         }
57598         function checkGrammarArrowFunction(node, file) {
57599             if (!ts.isArrowFunction(node)) {
57600                 return false;
57601             }
57602             var equalsGreaterThanToken = node.equalsGreaterThanToken;
57603             var startLine = ts.getLineAndCharacterOfPosition(file, equalsGreaterThanToken.pos).line;
57604             var endLine = ts.getLineAndCharacterOfPosition(file, equalsGreaterThanToken.end).line;
57605             return startLine !== endLine && grammarErrorOnNode(equalsGreaterThanToken, ts.Diagnostics.Line_terminator_not_permitted_before_arrow);
57606         }
57607         function checkGrammarIndexSignatureParameters(node) {
57608             var parameter = node.parameters[0];
57609             if (node.parameters.length !== 1) {
57610                 if (parameter) {
57611                     return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter);
57612                 }
57613                 else {
57614                     return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter);
57615                 }
57616             }
57617             checkGrammarForDisallowedTrailingComma(node.parameters, ts.Diagnostics.An_index_signature_cannot_have_a_trailing_comma);
57618             if (parameter.dotDotDotToken) {
57619                 return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter);
57620             }
57621             if (ts.hasModifiers(parameter)) {
57622                 return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier);
57623             }
57624             if (parameter.questionToken) {
57625                 return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.An_index_signature_parameter_cannot_have_a_question_mark);
57626             }
57627             if (parameter.initializer) {
57628                 return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_initializer);
57629             }
57630             if (!parameter.type) {
57631                 return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation);
57632             }
57633             if (parameter.type.kind !== 143 && parameter.type.kind !== 140) {
57634                 var type = getTypeFromTypeNode(parameter.type);
57635                 if (type.flags & 4 || type.flags & 8) {
57636                     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));
57637                 }
57638                 if (type.flags & 1048576 && allTypesAssignableToKind(type, 384, true)) {
57639                     return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead);
57640                 }
57641                 return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_either_string_or_number);
57642             }
57643             if (!node.type) {
57644                 return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_a_type_annotation);
57645             }
57646             return false;
57647         }
57648         function checkGrammarIndexSignature(node) {
57649             return checkGrammarDecoratorsAndModifiers(node) || checkGrammarIndexSignatureParameters(node);
57650         }
57651         function checkGrammarForAtLeastOneTypeArgument(node, typeArguments) {
57652             if (typeArguments && typeArguments.length === 0) {
57653                 var sourceFile = ts.getSourceFileOfNode(node);
57654                 var start = typeArguments.pos - "<".length;
57655                 var end = ts.skipTrivia(sourceFile.text, typeArguments.end) + ">".length;
57656                 return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Type_argument_list_cannot_be_empty);
57657             }
57658             return false;
57659         }
57660         function checkGrammarTypeArguments(node, typeArguments) {
57661             return checkGrammarForDisallowedTrailingComma(typeArguments) ||
57662                 checkGrammarForAtLeastOneTypeArgument(node, typeArguments);
57663         }
57664         function checkGrammarTaggedTemplateChain(node) {
57665             if (node.questionDotToken || node.flags & 32) {
57666                 return grammarErrorOnNode(node.template, ts.Diagnostics.Tagged_template_expressions_are_not_permitted_in_an_optional_chain);
57667             }
57668             return false;
57669         }
57670         function checkGrammarForOmittedArgument(args) {
57671             if (args) {
57672                 for (var _i = 0, args_4 = args; _i < args_4.length; _i++) {
57673                     var arg = args_4[_i];
57674                     if (arg.kind === 215) {
57675                         return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected);
57676                     }
57677                 }
57678             }
57679             return false;
57680         }
57681         function checkGrammarArguments(args) {
57682             return checkGrammarForOmittedArgument(args);
57683         }
57684         function checkGrammarHeritageClause(node) {
57685             var types = node.types;
57686             if (checkGrammarForDisallowedTrailingComma(types)) {
57687                 return true;
57688             }
57689             if (types && types.length === 0) {
57690                 var listType = ts.tokenToString(node.token);
57691                 return grammarErrorAtPos(node, types.pos, 0, ts.Diagnostics._0_list_cannot_be_empty, listType);
57692             }
57693             return ts.some(types, checkGrammarExpressionWithTypeArguments);
57694         }
57695         function checkGrammarExpressionWithTypeArguments(node) {
57696             return checkGrammarTypeArguments(node, node.typeArguments);
57697         }
57698         function checkGrammarClassDeclarationHeritageClauses(node) {
57699             var seenExtendsClause = false;
57700             var seenImplementsClause = false;
57701             if (!checkGrammarDecoratorsAndModifiers(node) && node.heritageClauses) {
57702                 for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) {
57703                     var heritageClause = _a[_i];
57704                     if (heritageClause.token === 90) {
57705                         if (seenExtendsClause) {
57706                             return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen);
57707                         }
57708                         if (seenImplementsClause) {
57709                             return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_must_precede_implements_clause);
57710                         }
57711                         if (heritageClause.types.length > 1) {
57712                             return grammarErrorOnFirstToken(heritageClause.types[1], ts.Diagnostics.Classes_can_only_extend_a_single_class);
57713                         }
57714                         seenExtendsClause = true;
57715                     }
57716                     else {
57717                         ts.Debug.assert(heritageClause.token === 113);
57718                         if (seenImplementsClause) {
57719                             return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen);
57720                         }
57721                         seenImplementsClause = true;
57722                     }
57723                     checkGrammarHeritageClause(heritageClause);
57724                 }
57725             }
57726         }
57727         function checkGrammarInterfaceDeclaration(node) {
57728             var seenExtendsClause = false;
57729             if (node.heritageClauses) {
57730                 for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) {
57731                     var heritageClause = _a[_i];
57732                     if (heritageClause.token === 90) {
57733                         if (seenExtendsClause) {
57734                             return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen);
57735                         }
57736                         seenExtendsClause = true;
57737                     }
57738                     else {
57739                         ts.Debug.assert(heritageClause.token === 113);
57740                         return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause);
57741                     }
57742                     checkGrammarHeritageClause(heritageClause);
57743                 }
57744             }
57745             return false;
57746         }
57747         function checkGrammarComputedPropertyName(node) {
57748             if (node.kind !== 154) {
57749                 return false;
57750             }
57751             var computedPropertyName = node;
57752             if (computedPropertyName.expression.kind === 209 && computedPropertyName.expression.operatorToken.kind === 27) {
57753                 return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name);
57754             }
57755             return false;
57756         }
57757         function checkGrammarForGenerator(node) {
57758             if (node.asteriskToken) {
57759                 ts.Debug.assert(node.kind === 244 ||
57760                     node.kind === 201 ||
57761                     node.kind === 161);
57762                 if (node.flags & 8388608) {
57763                     return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context);
57764                 }
57765                 if (!node.body) {
57766                     return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.An_overload_signature_cannot_be_declared_as_a_generator);
57767                 }
57768             }
57769         }
57770         function checkGrammarForInvalidQuestionMark(questionToken, message) {
57771             return !!questionToken && grammarErrorOnNode(questionToken, message);
57772         }
57773         function checkGrammarForInvalidExclamationToken(exclamationToken, message) {
57774             return !!exclamationToken && grammarErrorOnNode(exclamationToken, message);
57775         }
57776         function checkGrammarObjectLiteralExpression(node, inDestructuring) {
57777             var seen = ts.createUnderscoreEscapedMap();
57778             for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
57779                 var prop = _a[_i];
57780                 if (prop.kind === 283) {
57781                     if (inDestructuring) {
57782                         var expression = ts.skipParentheses(prop.expression);
57783                         if (ts.isArrayLiteralExpression(expression) || ts.isObjectLiteralExpression(expression)) {
57784                             return grammarErrorOnNode(prop.expression, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern);
57785                         }
57786                     }
57787                     continue;
57788                 }
57789                 var name = prop.name;
57790                 if (name.kind === 154) {
57791                     checkGrammarComputedPropertyName(name);
57792                 }
57793                 if (prop.kind === 282 && !inDestructuring && prop.objectAssignmentInitializer) {
57794                     return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment);
57795                 }
57796                 if (name.kind === 76) {
57797                     return grammarErrorOnNode(name, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
57798                 }
57799                 if (prop.modifiers) {
57800                     for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) {
57801                         var mod = _c[_b];
57802                         if (mod.kind !== 126 || prop.kind !== 161) {
57803                             grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod));
57804                         }
57805                     }
57806                 }
57807                 var currentKind = void 0;
57808                 switch (prop.kind) {
57809                     case 282:
57810                         checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context);
57811                     case 281:
57812                         checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional);
57813                         if (name.kind === 8) {
57814                             checkGrammarNumericLiteral(name);
57815                         }
57816                         currentKind = 4;
57817                         break;
57818                     case 161:
57819                         currentKind = 8;
57820                         break;
57821                     case 163:
57822                         currentKind = 1;
57823                         break;
57824                     case 164:
57825                         currentKind = 2;
57826                         break;
57827                     default:
57828                         throw ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind);
57829                 }
57830                 if (!inDestructuring) {
57831                     var effectiveName = ts.getPropertyNameForPropertyNameNode(name);
57832                     if (effectiveName === undefined) {
57833                         continue;
57834                     }
57835                     var existingKind = seen.get(effectiveName);
57836                     if (!existingKind) {
57837                         seen.set(effectiveName, currentKind);
57838                     }
57839                     else {
57840                         if ((currentKind & 12) && (existingKind & 12)) {
57841                             grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name));
57842                         }
57843                         else if ((currentKind & 3) && (existingKind & 3)) {
57844                             if (existingKind !== 3 && currentKind !== existingKind) {
57845                                 seen.set(effectiveName, currentKind | existingKind);
57846                             }
57847                             else {
57848                                 return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name);
57849                             }
57850                         }
57851                         else {
57852                             return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name);
57853                         }
57854                     }
57855                 }
57856             }
57857         }
57858         function checkGrammarJsxElement(node) {
57859             checkGrammarTypeArguments(node, node.typeArguments);
57860             var seen = ts.createUnderscoreEscapedMap();
57861             for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) {
57862                 var attr = _a[_i];
57863                 if (attr.kind === 275) {
57864                     continue;
57865                 }
57866                 var name = attr.name, initializer = attr.initializer;
57867                 if (!seen.get(name.escapedText)) {
57868                     seen.set(name.escapedText, true);
57869                 }
57870                 else {
57871                     return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name);
57872                 }
57873                 if (initializer && initializer.kind === 276 && !initializer.expression) {
57874                     return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression);
57875                 }
57876             }
57877         }
57878         function checkGrammarJsxExpression(node) {
57879             if (node.expression && ts.isCommaSequence(node.expression)) {
57880                 return grammarErrorOnNode(node.expression, ts.Diagnostics.JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array);
57881             }
57882         }
57883         function checkGrammarForInOrForOfStatement(forInOrOfStatement) {
57884             if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) {
57885                 return true;
57886             }
57887             if (forInOrOfStatement.kind === 232 && forInOrOfStatement.awaitModifier) {
57888                 if ((forInOrOfStatement.flags & 32768) === 0) {
57889                     var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement);
57890                     if (!hasParseDiagnostics(sourceFile)) {
57891                         var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator);
57892                         var func = ts.getContainingFunction(forInOrOfStatement);
57893                         if (func && func.kind !== 162) {
57894                             ts.Debug.assert((ts.getFunctionFlags(func) & 2) === 0, "Enclosing function should never be an async function.");
57895                             var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async);
57896                             ts.addRelatedInfo(diagnostic, relatedInfo);
57897                         }
57898                         diagnostics.add(diagnostic);
57899                         return true;
57900                     }
57901                     return false;
57902                 }
57903             }
57904             if (forInOrOfStatement.initializer.kind === 243) {
57905                 var variableList = forInOrOfStatement.initializer;
57906                 if (!checkGrammarVariableDeclarationList(variableList)) {
57907                     var declarations = variableList.declarations;
57908                     if (!declarations.length) {
57909                         return false;
57910                     }
57911                     if (declarations.length > 1) {
57912                         var diagnostic = forInOrOfStatement.kind === 231
57913                             ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement
57914                             : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement;
57915                         return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic);
57916                     }
57917                     var firstDeclaration = declarations[0];
57918                     if (firstDeclaration.initializer) {
57919                         var diagnostic = forInOrOfStatement.kind === 231
57920                             ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer
57921                             : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer;
57922                         return grammarErrorOnNode(firstDeclaration.name, diagnostic);
57923                     }
57924                     if (firstDeclaration.type) {
57925                         var diagnostic = forInOrOfStatement.kind === 231
57926                             ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation
57927                             : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation;
57928                         return grammarErrorOnNode(firstDeclaration, diagnostic);
57929                     }
57930                 }
57931             }
57932             return false;
57933         }
57934         function checkGrammarAccessor(accessor) {
57935             if (!(accessor.flags & 8388608)) {
57936                 if (languageVersion < 1) {
57937                     return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher);
57938                 }
57939                 if (accessor.body === undefined && !ts.hasModifier(accessor, 128)) {
57940                     return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{");
57941                 }
57942             }
57943             if (accessor.body && ts.hasModifier(accessor, 128)) {
57944                 return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation);
57945             }
57946             if (accessor.typeParameters) {
57947                 return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters);
57948             }
57949             if (!doesAccessorHaveCorrectParameterCount(accessor)) {
57950                 return grammarErrorOnNode(accessor.name, accessor.kind === 163 ?
57951                     ts.Diagnostics.A_get_accessor_cannot_have_parameters :
57952                     ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter);
57953             }
57954             if (accessor.kind === 164) {
57955                 if (accessor.type) {
57956                     return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation);
57957                 }
57958                 var parameter = ts.Debug.checkDefined(ts.getSetAccessorValueParameter(accessor), "Return value does not match parameter count assertion.");
57959                 if (parameter.dotDotDotToken) {
57960                     return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter);
57961                 }
57962                 if (parameter.questionToken) {
57963                     return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter);
57964                 }
57965                 if (parameter.initializer) {
57966                     return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer);
57967                 }
57968             }
57969             return false;
57970         }
57971         function doesAccessorHaveCorrectParameterCount(accessor) {
57972             return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 163 ? 0 : 1);
57973         }
57974         function getAccessorThisParameter(accessor) {
57975             if (accessor.parameters.length === (accessor.kind === 163 ? 1 : 2)) {
57976                 return ts.getThisParameter(accessor);
57977             }
57978         }
57979         function checkGrammarTypeOperatorNode(node) {
57980             if (node.operator === 147) {
57981                 if (node.type.kind !== 144) {
57982                     return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(144));
57983                 }
57984                 var parent = ts.walkUpParenthesizedTypes(node.parent);
57985                 switch (parent.kind) {
57986                     case 242:
57987                         var decl = parent;
57988                         if (decl.name.kind !== 75) {
57989                             return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name);
57990                         }
57991                         if (!ts.isVariableDeclarationInVariableStatement(decl)) {
57992                             return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement);
57993                         }
57994                         if (!(decl.parent.flags & 2)) {
57995                             return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const);
57996                         }
57997                         break;
57998                     case 159:
57999                         if (!ts.hasModifier(parent, 32) ||
58000                             !ts.hasModifier(parent, 64)) {
58001                             return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly);
58002                         }
58003                         break;
58004                     case 158:
58005                         if (!ts.hasModifier(parent, 64)) {
58006                             return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly);
58007                         }
58008                         break;
58009                     default:
58010                         return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here);
58011                 }
58012             }
58013             else if (node.operator === 138) {
58014                 if (node.type.kind !== 174 && node.type.kind !== 175) {
58015                     return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(144));
58016                 }
58017             }
58018         }
58019         function checkGrammarForInvalidDynamicName(node, message) {
58020             if (isNonBindableDynamicName(node)) {
58021                 return grammarErrorOnNode(node, message);
58022             }
58023         }
58024         function checkGrammarMethod(node) {
58025             if (checkGrammarFunctionLikeDeclaration(node)) {
58026                 return true;
58027             }
58028             if (node.kind === 161) {
58029                 if (node.parent.kind === 193) {
58030                     if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 126)) {
58031                         return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here);
58032                     }
58033                     else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) {
58034                         return true;
58035                     }
58036                     else if (checkGrammarForInvalidExclamationToken(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context)) {
58037                         return true;
58038                     }
58039                     else if (node.body === undefined) {
58040                         return grammarErrorAtPos(node, node.end - 1, ";".length, ts.Diagnostics._0_expected, "{");
58041                     }
58042                 }
58043                 if (checkGrammarForGenerator(node)) {
58044                     return true;
58045                 }
58046             }
58047             if (ts.isClassLike(node.parent)) {
58048                 if (node.flags & 8388608) {
58049                     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);
58050                 }
58051                 else if (node.kind === 161 && !node.body) {
58052                     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);
58053                 }
58054             }
58055             else if (node.parent.kind === 246) {
58056                 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);
58057             }
58058             else if (node.parent.kind === 173) {
58059                 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);
58060             }
58061         }
58062         function checkGrammarBreakOrContinueStatement(node) {
58063             var current = node;
58064             while (current) {
58065                 if (ts.isFunctionLike(current)) {
58066                     return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary);
58067                 }
58068                 switch (current.kind) {
58069                     case 238:
58070                         if (node.label && current.label.escapedText === node.label.escapedText) {
58071                             var isMisplacedContinueLabel = node.kind === 233
58072                                 && !ts.isIterationStatement(current.statement, true);
58073                             if (isMisplacedContinueLabel) {
58074                                 return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement);
58075                             }
58076                             return false;
58077                         }
58078                         break;
58079                     case 237:
58080                         if (node.kind === 234 && !node.label) {
58081                             return false;
58082                         }
58083                         break;
58084                     default:
58085                         if (ts.isIterationStatement(current, false) && !node.label) {
58086                             return false;
58087                         }
58088                         break;
58089                 }
58090                 current = current.parent;
58091             }
58092             if (node.label) {
58093                 var message = node.kind === 234
58094                     ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement
58095                     : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement;
58096                 return grammarErrorOnNode(node, message);
58097             }
58098             else {
58099                 var message = node.kind === 234
58100                     ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement
58101                     : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement;
58102                 return grammarErrorOnNode(node, message);
58103             }
58104         }
58105         function checkGrammarBindingElement(node) {
58106             if (node.dotDotDotToken) {
58107                 var elements = node.parent.elements;
58108                 if (node !== ts.last(elements)) {
58109                     return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern);
58110                 }
58111                 checkGrammarForDisallowedTrailingComma(elements, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
58112                 if (node.propertyName) {
58113                     return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_have_a_property_name);
58114                 }
58115                 if (node.initializer) {
58116                     return grammarErrorAtPos(node, node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer);
58117                 }
58118             }
58119         }
58120         function isStringOrNumberLiteralExpression(expr) {
58121             return ts.isStringOrNumericLiteralLike(expr) ||
58122                 expr.kind === 207 && expr.operator === 40 &&
58123                     expr.operand.kind === 8;
58124         }
58125         function isBigIntLiteralExpression(expr) {
58126             return expr.kind === 9 ||
58127                 expr.kind === 207 && expr.operator === 40 &&
58128                     expr.operand.kind === 9;
58129         }
58130         function isSimpleLiteralEnumReference(expr) {
58131             if ((ts.isPropertyAccessExpression(expr) || (ts.isElementAccessExpression(expr) && isStringOrNumberLiteralExpression(expr.argumentExpression))) &&
58132                 ts.isEntityNameExpression(expr.expression)) {
58133                 return !!(checkExpressionCached(expr).flags & 1024);
58134             }
58135         }
58136         function checkAmbientInitializer(node) {
58137             var initializer = node.initializer;
58138             if (initializer) {
58139                 var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) ||
58140                     isSimpleLiteralEnumReference(initializer) ||
58141                     initializer.kind === 106 || initializer.kind === 91 ||
58142                     isBigIntLiteralExpression(initializer));
58143                 var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node);
58144                 if (isConstOrReadonly && !node.type) {
58145                     if (isInvalidInitializer) {
58146                         return grammarErrorOnNode(initializer, ts.Diagnostics.A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference);
58147                     }
58148                 }
58149                 else {
58150                     return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
58151                 }
58152                 if (!isConstOrReadonly || isInvalidInitializer) {
58153                     return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
58154                 }
58155             }
58156         }
58157         function checkGrammarVariableDeclaration(node) {
58158             if (node.parent.parent.kind !== 231 && node.parent.parent.kind !== 232) {
58159                 if (node.flags & 8388608) {
58160                     checkAmbientInitializer(node);
58161                 }
58162                 else if (!node.initializer) {
58163                     if (ts.isBindingPattern(node.name) && !ts.isBindingPattern(node.parent)) {
58164                         return grammarErrorOnNode(node, ts.Diagnostics.A_destructuring_declaration_must_have_an_initializer);
58165                     }
58166                     if (ts.isVarConst(node)) {
58167                         return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_must_be_initialized);
58168                     }
58169                 }
58170             }
58171             if (node.exclamationToken && (node.parent.parent.kind !== 225 || !node.type || node.initializer || node.flags & 8388608)) {
58172                 return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation);
58173             }
58174             var moduleKind = ts.getEmitModuleKind(compilerOptions);
58175             if (moduleKind < ts.ModuleKind.ES2015 && moduleKind !== ts.ModuleKind.System && !compilerOptions.noEmit &&
58176                 !(node.parent.parent.flags & 8388608) && ts.hasModifier(node.parent.parent, 1)) {
58177                 checkESModuleMarker(node.name);
58178             }
58179             var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node));
58180             return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name);
58181         }
58182         function checkESModuleMarker(name) {
58183             if (name.kind === 75) {
58184                 if (ts.idText(name) === "__esModule") {
58185                     return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules);
58186                 }
58187             }
58188             else {
58189                 var elements = name.elements;
58190                 for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) {
58191                     var element = elements_1[_i];
58192                     if (!ts.isOmittedExpression(element)) {
58193                         return checkESModuleMarker(element.name);
58194                     }
58195                 }
58196             }
58197             return false;
58198         }
58199         function checkGrammarNameInLetOrConstDeclarations(name) {
58200             if (name.kind === 75) {
58201                 if (name.originalKeywordKind === 115) {
58202                     return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations);
58203                 }
58204             }
58205             else {
58206                 var elements = name.elements;
58207                 for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) {
58208                     var element = elements_2[_i];
58209                     if (!ts.isOmittedExpression(element)) {
58210                         checkGrammarNameInLetOrConstDeclarations(element.name);
58211                     }
58212                 }
58213             }
58214             return false;
58215         }
58216         function checkGrammarVariableDeclarationList(declarationList) {
58217             var declarations = declarationList.declarations;
58218             if (checkGrammarForDisallowedTrailingComma(declarationList.declarations)) {
58219                 return true;
58220             }
58221             if (!declarationList.declarations.length) {
58222                 return grammarErrorAtPos(declarationList, declarations.pos, declarations.end - declarations.pos, ts.Diagnostics.Variable_declaration_list_cannot_be_empty);
58223             }
58224             return false;
58225         }
58226         function allowLetAndConstDeclarations(parent) {
58227             switch (parent.kind) {
58228                 case 227:
58229                 case 228:
58230                 case 229:
58231                 case 236:
58232                 case 230:
58233                 case 231:
58234                 case 232:
58235                     return false;
58236                 case 238:
58237                     return allowLetAndConstDeclarations(parent.parent);
58238             }
58239             return true;
58240         }
58241         function checkGrammarForDisallowedLetOrConstStatement(node) {
58242             if (!allowLetAndConstDeclarations(node.parent)) {
58243                 if (ts.isLet(node.declarationList)) {
58244                     return grammarErrorOnNode(node, ts.Diagnostics.let_declarations_can_only_be_declared_inside_a_block);
58245                 }
58246                 else if (ts.isVarConst(node.declarationList)) {
58247                     return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_can_only_be_declared_inside_a_block);
58248                 }
58249             }
58250         }
58251         function checkGrammarMetaProperty(node) {
58252             var escapedText = node.name.escapedText;
58253             switch (node.keywordToken) {
58254                 case 99:
58255                     if (escapedText !== "target") {
58256                         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");
58257                     }
58258                     break;
58259                 case 96:
58260                     if (escapedText !== "meta") {
58261                         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");
58262                     }
58263                     break;
58264             }
58265         }
58266         function hasParseDiagnostics(sourceFile) {
58267             return sourceFile.parseDiagnostics.length > 0;
58268         }
58269         function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) {
58270             var sourceFile = ts.getSourceFileOfNode(node);
58271             if (!hasParseDiagnostics(sourceFile)) {
58272                 var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
58273                 diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2));
58274                 return true;
58275             }
58276             return false;
58277         }
58278         function grammarErrorAtPos(nodeForSourceFile, start, length, message, arg0, arg1, arg2) {
58279             var sourceFile = ts.getSourceFileOfNode(nodeForSourceFile);
58280             if (!hasParseDiagnostics(sourceFile)) {
58281                 diagnostics.add(ts.createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2));
58282                 return true;
58283             }
58284             return false;
58285         }
58286         function grammarErrorOnNode(node, message, arg0, arg1, arg2) {
58287             var sourceFile = ts.getSourceFileOfNode(node);
58288             if (!hasParseDiagnostics(sourceFile)) {
58289                 diagnostics.add(ts.createDiagnosticForNode(node, message, arg0, arg1, arg2));
58290                 return true;
58291             }
58292             return false;
58293         }
58294         function checkGrammarConstructorTypeParameters(node) {
58295             var jsdocTypeParameters = ts.isInJSFile(node) ? ts.getJSDocTypeParameterDeclarations(node) : undefined;
58296             var range = node.typeParameters || jsdocTypeParameters && ts.firstOrUndefined(jsdocTypeParameters);
58297             if (range) {
58298                 var pos = range.pos === range.end ? range.pos : ts.skipTrivia(ts.getSourceFileOfNode(node).text, range.pos);
58299                 return grammarErrorAtPos(node, pos, range.end - pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration);
58300             }
58301         }
58302         function checkGrammarConstructorTypeAnnotation(node) {
58303             var type = ts.getEffectiveReturnTypeNode(node);
58304             if (type) {
58305                 return grammarErrorOnNode(type, ts.Diagnostics.Type_annotation_cannot_appear_on_a_constructor_declaration);
58306             }
58307         }
58308         function checkGrammarProperty(node) {
58309             if (ts.isClassLike(node.parent)) {
58310                 if (ts.isStringLiteral(node.name) && node.name.text === "constructor") {
58311                     return grammarErrorOnNode(node.name, ts.Diagnostics.Classes_may_not_have_a_field_named_constructor);
58312                 }
58313                 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)) {
58314                     return true;
58315                 }
58316                 if (languageVersion < 2 && ts.isPrivateIdentifier(node.name)) {
58317                     return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher);
58318                 }
58319             }
58320             else if (node.parent.kind === 246) {
58321                 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)) {
58322                     return true;
58323                 }
58324                 if (node.initializer) {
58325                     return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer);
58326                 }
58327             }
58328             else if (node.parent.kind === 173) {
58329                 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)) {
58330                     return true;
58331                 }
58332                 if (node.initializer) {
58333                     return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer);
58334                 }
58335             }
58336             if (node.flags & 8388608) {
58337                 checkAmbientInitializer(node);
58338             }
58339             if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer ||
58340                 node.flags & 8388608 || ts.hasModifier(node, 32 | 128))) {
58341                 return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context);
58342             }
58343         }
58344         function checkGrammarTopLevelElementForRequiredDeclareModifier(node) {
58345             if (node.kind === 246 ||
58346                 node.kind === 247 ||
58347                 node.kind === 254 ||
58348                 node.kind === 253 ||
58349                 node.kind === 260 ||
58350                 node.kind === 259 ||
58351                 node.kind === 252 ||
58352                 ts.hasModifier(node, 2 | 1 | 512)) {
58353                 return false;
58354             }
58355             return grammarErrorOnFirstToken(node, ts.Diagnostics.Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier);
58356         }
58357         function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) {
58358             for (var _i = 0, _a = file.statements; _i < _a.length; _i++) {
58359                 var decl = _a[_i];
58360                 if (ts.isDeclaration(decl) || decl.kind === 225) {
58361                     if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) {
58362                         return true;
58363                     }
58364                 }
58365             }
58366             return false;
58367         }
58368         function checkGrammarSourceFile(node) {
58369             return !!(node.flags & 8388608) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node);
58370         }
58371         function checkGrammarStatementInAmbientContext(node) {
58372             if (node.flags & 8388608) {
58373                 var links = getNodeLinks(node);
58374                 if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) {
58375                     return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts);
58376                 }
58377                 if (node.parent.kind === 223 || node.parent.kind === 250 || node.parent.kind === 290) {
58378                     var links_2 = getNodeLinks(node.parent);
58379                     if (!links_2.hasReportedStatementInAmbientContext) {
58380                         return links_2.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts);
58381                     }
58382                 }
58383                 else {
58384                 }
58385             }
58386             return false;
58387         }
58388         function checkGrammarNumericLiteral(node) {
58389             if (node.numericLiteralFlags & 32) {
58390                 var diagnosticMessage = void 0;
58391                 if (languageVersion >= 1) {
58392                     diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0;
58393                 }
58394                 else if (ts.isChildOfNodeWithKind(node, 187)) {
58395                     diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0;
58396                 }
58397                 else if (ts.isChildOfNodeWithKind(node, 284)) {
58398                     diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0;
58399                 }
58400                 if (diagnosticMessage) {
58401                     var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40;
58402                     var literal = (withMinus ? "-" : "") + "0o" + node.text;
58403                     return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal);
58404                 }
58405             }
58406             checkNumericLiteralValueSize(node);
58407             return false;
58408         }
58409         function checkNumericLiteralValueSize(node) {
58410             if (node.numericLiteralFlags & 16 || node.text.length <= 15 || node.text.indexOf(".") !== -1) {
58411                 return;
58412             }
58413             var apparentValue = +ts.getTextOfNode(node);
58414             if (apparentValue <= Math.pow(2, 53) - 1 && apparentValue + 1 > apparentValue) {
58415                 return;
58416             }
58417             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));
58418         }
58419         function checkGrammarBigIntLiteral(node) {
58420             var literalType = ts.isLiteralTypeNode(node.parent) ||
58421                 ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent);
58422             if (!literalType) {
58423                 if (languageVersion < 7) {
58424                     if (grammarErrorOnNode(node, ts.Diagnostics.BigInt_literals_are_not_available_when_targeting_lower_than_ES2020)) {
58425                         return true;
58426                     }
58427                 }
58428             }
58429             return false;
58430         }
58431         function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) {
58432             var sourceFile = ts.getSourceFileOfNode(node);
58433             if (!hasParseDiagnostics(sourceFile)) {
58434                 var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
58435                 diagnostics.add(ts.createFileDiagnostic(sourceFile, ts.textSpanEnd(span), 0, message, arg0, arg1, arg2));
58436                 return true;
58437             }
58438             return false;
58439         }
58440         function getAmbientModules() {
58441             if (!ambientModulesCache) {
58442                 ambientModulesCache = [];
58443                 globals.forEach(function (global, sym) {
58444                     if (ambientModuleSymbolRegex.test(sym)) {
58445                         ambientModulesCache.push(global);
58446                     }
58447                 });
58448             }
58449             return ambientModulesCache;
58450         }
58451         function checkGrammarImportClause(node) {
58452             if (node.isTypeOnly && node.name && node.namedBindings) {
58453                 return grammarErrorOnNode(node, ts.Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both);
58454             }
58455             return false;
58456         }
58457         function checkGrammarImportCallExpression(node) {
58458             if (moduleKind === ts.ModuleKind.ES2015) {
58459                 return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_esnext_commonjs_amd_system_or_umd);
58460             }
58461             if (node.typeArguments) {
58462                 return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments);
58463             }
58464             var nodeArguments = node.arguments;
58465             if (nodeArguments.length !== 1) {
58466                 return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_must_have_one_specifier_as_an_argument);
58467             }
58468             checkGrammarForDisallowedTrailingComma(nodeArguments);
58469             if (ts.isSpreadElement(nodeArguments[0])) {
58470                 return grammarErrorOnNode(nodeArguments[0], ts.Diagnostics.Specifier_of_dynamic_import_cannot_be_spread_element);
58471             }
58472             return false;
58473         }
58474         function findMatchingTypeReferenceOrTypeAliasReference(source, unionTarget) {
58475             var sourceObjectFlags = ts.getObjectFlags(source);
58476             if (sourceObjectFlags & (4 | 16) && unionTarget.flags & 1048576) {
58477                 return ts.find(unionTarget.types, function (target) {
58478                     if (target.flags & 524288) {
58479                         var overlapObjFlags = sourceObjectFlags & ts.getObjectFlags(target);
58480                         if (overlapObjFlags & 4) {
58481                             return source.target === target.target;
58482                         }
58483                         if (overlapObjFlags & 16) {
58484                             return !!source.aliasSymbol && source.aliasSymbol === target.aliasSymbol;
58485                         }
58486                     }
58487                     return false;
58488                 });
58489             }
58490         }
58491         function findBestTypeForObjectLiteral(source, unionTarget) {
58492             if (ts.getObjectFlags(source) & 128 && forEachType(unionTarget, isArrayLikeType)) {
58493                 return ts.find(unionTarget.types, function (t) { return !isArrayLikeType(t); });
58494             }
58495         }
58496         function findBestTypeForInvokable(source, unionTarget) {
58497             var signatureKind = 0;
58498             var hasSignatures = getSignaturesOfType(source, signatureKind).length > 0 ||
58499                 (signatureKind = 1, getSignaturesOfType(source, signatureKind).length > 0);
58500             if (hasSignatures) {
58501                 return ts.find(unionTarget.types, function (t) { return getSignaturesOfType(t, signatureKind).length > 0; });
58502             }
58503         }
58504         function findMostOverlappyType(source, unionTarget) {
58505             var bestMatch;
58506             var matchingCount = 0;
58507             for (var _i = 0, _a = unionTarget.types; _i < _a.length; _i++) {
58508                 var target = _a[_i];
58509                 var overlap = getIntersectionType([getIndexType(source), getIndexType(target)]);
58510                 if (overlap.flags & 4194304) {
58511                     bestMatch = target;
58512                     matchingCount = Infinity;
58513                 }
58514                 else if (overlap.flags & 1048576) {
58515                     var len = ts.length(ts.filter(overlap.types, isUnitType));
58516                     if (len >= matchingCount) {
58517                         bestMatch = target;
58518                         matchingCount = len;
58519                     }
58520                 }
58521                 else if (isUnitType(overlap) && 1 >= matchingCount) {
58522                     bestMatch = target;
58523                     matchingCount = 1;
58524                 }
58525             }
58526             return bestMatch;
58527         }
58528         function filterPrimitivesIfContainsNonPrimitive(type) {
58529             if (maybeTypeOfKind(type, 67108864)) {
58530                 var result = filterType(type, function (t) { return !(t.flags & 131068); });
58531                 if (!(result.flags & 131072)) {
58532                     return result;
58533                 }
58534             }
58535             return type;
58536         }
58537         function findMatchingDiscriminantType(source, target, isRelatedTo, skipPartial) {
58538             if (target.flags & 1048576 && source.flags & (2097152 | 524288)) {
58539                 var sourceProperties = getPropertiesOfType(source);
58540                 if (sourceProperties) {
58541                     var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target);
58542                     if (sourcePropertiesFiltered) {
58543                         return discriminateTypeByDiscriminableItems(target, ts.map(sourcePropertiesFiltered, function (p) { return [function () { return getTypeOfSymbol(p); }, p.escapedName]; }), isRelatedTo, undefined, skipPartial);
58544                     }
58545                 }
58546             }
58547             return undefined;
58548         }
58549     }
58550     ts.createTypeChecker = createTypeChecker;
58551     function isNotAccessor(declaration) {
58552         return !ts.isAccessor(declaration);
58553     }
58554     function isNotOverload(declaration) {
58555         return (declaration.kind !== 244 && declaration.kind !== 161) ||
58556             !!declaration.body;
58557     }
58558     function isDeclarationNameOrImportPropertyName(name) {
58559         switch (name.parent.kind) {
58560             case 258:
58561             case 263:
58562                 return ts.isIdentifier(name);
58563             default:
58564                 return ts.isDeclarationName(name);
58565         }
58566     }
58567     function isSomeImportDeclaration(decl) {
58568         switch (decl.kind) {
58569             case 255:
58570             case 253:
58571             case 256:
58572             case 258:
58573                 return true;
58574             case 75:
58575                 return decl.parent.kind === 258;
58576             default:
58577                 return false;
58578         }
58579     }
58580     var JsxNames;
58581     (function (JsxNames) {
58582         JsxNames.JSX = "JSX";
58583         JsxNames.IntrinsicElements = "IntrinsicElements";
58584         JsxNames.ElementClass = "ElementClass";
58585         JsxNames.ElementAttributesPropertyNameContainer = "ElementAttributesProperty";
58586         JsxNames.ElementChildrenAttributeNameContainer = "ElementChildrenAttribute";
58587         JsxNames.Element = "Element";
58588         JsxNames.IntrinsicAttributes = "IntrinsicAttributes";
58589         JsxNames.IntrinsicClassAttributes = "IntrinsicClassAttributes";
58590         JsxNames.LibraryManagedAttributes = "LibraryManagedAttributes";
58591     })(JsxNames || (JsxNames = {}));
58592     function getIterationTypesKeyFromIterationTypeKind(typeKind) {
58593         switch (typeKind) {
58594             case 0: return "yieldType";
58595             case 1: return "returnType";
58596             case 2: return "nextType";
58597         }
58598     }
58599     function signatureHasRestParameter(s) {
58600         return !!(s.flags & 1);
58601     }
58602     ts.signatureHasRestParameter = signatureHasRestParameter;
58603     function signatureHasLiteralTypes(s) {
58604         return !!(s.flags & 2);
58605     }
58606     ts.signatureHasLiteralTypes = signatureHasLiteralTypes;
58607 })(ts || (ts = {}));
58608 var ts;
58609 (function (ts) {
58610     function createSynthesizedNode(kind) {
58611         var node = ts.createNode(kind, -1, -1);
58612         node.flags |= 8;
58613         return node;
58614     }
58615     function updateNode(updated, original) {
58616         if (updated !== original) {
58617             setOriginalNode(updated, original);
58618             setTextRange(updated, original);
58619             ts.aggregateTransformFlags(updated);
58620         }
58621         return updated;
58622     }
58623     ts.updateNode = updateNode;
58624     function createNodeArray(elements, hasTrailingComma) {
58625         if (!elements || elements === ts.emptyArray) {
58626             elements = [];
58627         }
58628         else if (ts.isNodeArray(elements)) {
58629             return elements;
58630         }
58631         var array = elements;
58632         array.pos = -1;
58633         array.end = -1;
58634         array.hasTrailingComma = hasTrailingComma;
58635         return array;
58636     }
58637     ts.createNodeArray = createNodeArray;
58638     function getSynthesizedClone(node) {
58639         if (node === undefined) {
58640             return node;
58641         }
58642         var clone = createSynthesizedNode(node.kind);
58643         clone.flags |= node.flags;
58644         setOriginalNode(clone, node);
58645         for (var key in node) {
58646             if (clone.hasOwnProperty(key) || !node.hasOwnProperty(key)) {
58647                 continue;
58648             }
58649             clone[key] = node[key];
58650         }
58651         return clone;
58652     }
58653     ts.getSynthesizedClone = getSynthesizedClone;
58654     function createLiteral(value, isSingleQuote) {
58655         if (typeof value === "number") {
58656             return createNumericLiteral(value + "");
58657         }
58658         if (typeof value === "object" && "base10Value" in value) {
58659             return createBigIntLiteral(ts.pseudoBigIntToString(value) + "n");
58660         }
58661         if (typeof value === "boolean") {
58662             return value ? createTrue() : createFalse();
58663         }
58664         if (ts.isString(value)) {
58665             var res = createStringLiteral(value);
58666             if (isSingleQuote)
58667                 res.singleQuote = true;
58668             return res;
58669         }
58670         return createLiteralFromNode(value);
58671     }
58672     ts.createLiteral = createLiteral;
58673     function createNumericLiteral(value, numericLiteralFlags) {
58674         if (numericLiteralFlags === void 0) { numericLiteralFlags = 0; }
58675         var node = createSynthesizedNode(8);
58676         node.text = value;
58677         node.numericLiteralFlags = numericLiteralFlags;
58678         return node;
58679     }
58680     ts.createNumericLiteral = createNumericLiteral;
58681     function createBigIntLiteral(value) {
58682         var node = createSynthesizedNode(9);
58683         node.text = value;
58684         return node;
58685     }
58686     ts.createBigIntLiteral = createBigIntLiteral;
58687     function createStringLiteral(text) {
58688         var node = createSynthesizedNode(10);
58689         node.text = text;
58690         return node;
58691     }
58692     ts.createStringLiteral = createStringLiteral;
58693     function createRegularExpressionLiteral(text) {
58694         var node = createSynthesizedNode(13);
58695         node.text = text;
58696         return node;
58697     }
58698     ts.createRegularExpressionLiteral = createRegularExpressionLiteral;
58699     function createLiteralFromNode(sourceNode) {
58700         var node = createStringLiteral(ts.getTextOfIdentifierOrLiteral(sourceNode));
58701         node.textSourceNode = sourceNode;
58702         return node;
58703     }
58704     function createIdentifier(text, typeArguments) {
58705         var node = createSynthesizedNode(75);
58706         node.escapedText = ts.escapeLeadingUnderscores(text);
58707         node.originalKeywordKind = text ? ts.stringToToken(text) : 0;
58708         node.autoGenerateFlags = 0;
58709         node.autoGenerateId = 0;
58710         if (typeArguments) {
58711             node.typeArguments = createNodeArray(typeArguments);
58712         }
58713         return node;
58714     }
58715     ts.createIdentifier = createIdentifier;
58716     function updateIdentifier(node, typeArguments) {
58717         return node.typeArguments !== typeArguments
58718             ? updateNode(createIdentifier(ts.idText(node), typeArguments), node)
58719             : node;
58720     }
58721     ts.updateIdentifier = updateIdentifier;
58722     var nextAutoGenerateId = 0;
58723     function createTempVariable(recordTempVariable, reservedInNestedScopes) {
58724         var name = createIdentifier("");
58725         name.autoGenerateFlags = 1;
58726         name.autoGenerateId = nextAutoGenerateId;
58727         nextAutoGenerateId++;
58728         if (recordTempVariable) {
58729             recordTempVariable(name);
58730         }
58731         if (reservedInNestedScopes) {
58732             name.autoGenerateFlags |= 8;
58733         }
58734         return name;
58735     }
58736     ts.createTempVariable = createTempVariable;
58737     function createLoopVariable() {
58738         var name = createIdentifier("");
58739         name.autoGenerateFlags = 2;
58740         name.autoGenerateId = nextAutoGenerateId;
58741         nextAutoGenerateId++;
58742         return name;
58743     }
58744     ts.createLoopVariable = createLoopVariable;
58745     function createUniqueName(text) {
58746         var name = createIdentifier(text);
58747         name.autoGenerateFlags = 3;
58748         name.autoGenerateId = nextAutoGenerateId;
58749         nextAutoGenerateId++;
58750         return name;
58751     }
58752     ts.createUniqueName = createUniqueName;
58753     function createOptimisticUniqueName(text) {
58754         var name = createIdentifier(text);
58755         name.autoGenerateFlags = 3 | 16;
58756         name.autoGenerateId = nextAutoGenerateId;
58757         nextAutoGenerateId++;
58758         return name;
58759     }
58760     ts.createOptimisticUniqueName = createOptimisticUniqueName;
58761     function createFileLevelUniqueName(text) {
58762         var name = createOptimisticUniqueName(text);
58763         name.autoGenerateFlags |= 32;
58764         return name;
58765     }
58766     ts.createFileLevelUniqueName = createFileLevelUniqueName;
58767     function getGeneratedNameForNode(node, flags) {
58768         var name = createIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : "");
58769         name.autoGenerateFlags = 4 | flags;
58770         name.autoGenerateId = nextAutoGenerateId;
58771         name.original = node;
58772         nextAutoGenerateId++;
58773         return name;
58774     }
58775     ts.getGeneratedNameForNode = getGeneratedNameForNode;
58776     function createPrivateIdentifier(text) {
58777         if (text[0] !== "#") {
58778             ts.Debug.fail("First character of private identifier must be #: " + text);
58779         }
58780         var node = createSynthesizedNode(76);
58781         node.escapedText = ts.escapeLeadingUnderscores(text);
58782         return node;
58783     }
58784     ts.createPrivateIdentifier = createPrivateIdentifier;
58785     function createToken(token) {
58786         return createSynthesizedNode(token);
58787     }
58788     ts.createToken = createToken;
58789     function createSuper() {
58790         return createSynthesizedNode(102);
58791     }
58792     ts.createSuper = createSuper;
58793     function createThis() {
58794         return createSynthesizedNode(104);
58795     }
58796     ts.createThis = createThis;
58797     function createNull() {
58798         return createSynthesizedNode(100);
58799     }
58800     ts.createNull = createNull;
58801     function createTrue() {
58802         return createSynthesizedNode(106);
58803     }
58804     ts.createTrue = createTrue;
58805     function createFalse() {
58806         return createSynthesizedNode(91);
58807     }
58808     ts.createFalse = createFalse;
58809     function createModifier(kind) {
58810         return createToken(kind);
58811     }
58812     ts.createModifier = createModifier;
58813     function createModifiersFromModifierFlags(flags) {
58814         var result = [];
58815         if (flags & 1) {
58816             result.push(createModifier(89));
58817         }
58818         if (flags & 2) {
58819             result.push(createModifier(130));
58820         }
58821         if (flags & 512) {
58822             result.push(createModifier(84));
58823         }
58824         if (flags & 2048) {
58825             result.push(createModifier(81));
58826         }
58827         if (flags & 4) {
58828             result.push(createModifier(119));
58829         }
58830         if (flags & 8) {
58831             result.push(createModifier(117));
58832         }
58833         if (flags & 16) {
58834             result.push(createModifier(118));
58835         }
58836         if (flags & 128) {
58837             result.push(createModifier(122));
58838         }
58839         if (flags & 32) {
58840             result.push(createModifier(120));
58841         }
58842         if (flags & 64) {
58843             result.push(createModifier(138));
58844         }
58845         if (flags & 256) {
58846             result.push(createModifier(126));
58847         }
58848         return result;
58849     }
58850     ts.createModifiersFromModifierFlags = createModifiersFromModifierFlags;
58851     function createQualifiedName(left, right) {
58852         var node = createSynthesizedNode(153);
58853         node.left = left;
58854         node.right = asName(right);
58855         return node;
58856     }
58857     ts.createQualifiedName = createQualifiedName;
58858     function updateQualifiedName(node, left, right) {
58859         return node.left !== left
58860             || node.right !== right
58861             ? updateNode(createQualifiedName(left, right), node)
58862             : node;
58863     }
58864     ts.updateQualifiedName = updateQualifiedName;
58865     function parenthesizeForComputedName(expression) {
58866         return ts.isCommaSequence(expression)
58867             ? createParen(expression)
58868             : expression;
58869     }
58870     function createComputedPropertyName(expression) {
58871         var node = createSynthesizedNode(154);
58872         node.expression = parenthesizeForComputedName(expression);
58873         return node;
58874     }
58875     ts.createComputedPropertyName = createComputedPropertyName;
58876     function updateComputedPropertyName(node, expression) {
58877         return node.expression !== expression
58878             ? updateNode(createComputedPropertyName(expression), node)
58879             : node;
58880     }
58881     ts.updateComputedPropertyName = updateComputedPropertyName;
58882     function createTypeParameterDeclaration(name, constraint, defaultType) {
58883         var node = createSynthesizedNode(155);
58884         node.name = asName(name);
58885         node.constraint = constraint;
58886         node.default = defaultType;
58887         return node;
58888     }
58889     ts.createTypeParameterDeclaration = createTypeParameterDeclaration;
58890     function updateTypeParameterDeclaration(node, name, constraint, defaultType) {
58891         return node.name !== name
58892             || node.constraint !== constraint
58893             || node.default !== defaultType
58894             ? updateNode(createTypeParameterDeclaration(name, constraint, defaultType), node)
58895             : node;
58896     }
58897     ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration;
58898     function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) {
58899         var node = createSynthesizedNode(156);
58900         node.decorators = asNodeArray(decorators);
58901         node.modifiers = asNodeArray(modifiers);
58902         node.dotDotDotToken = dotDotDotToken;
58903         node.name = asName(name);
58904         node.questionToken = questionToken;
58905         node.type = type;
58906         node.initializer = initializer ? ts.parenthesizeExpressionForList(initializer) : undefined;
58907         return node;
58908     }
58909     ts.createParameter = createParameter;
58910     function updateParameter(node, decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) {
58911         return node.decorators !== decorators
58912             || node.modifiers !== modifiers
58913             || node.dotDotDotToken !== dotDotDotToken
58914             || node.name !== name
58915             || node.questionToken !== questionToken
58916             || node.type !== type
58917             || node.initializer !== initializer
58918             ? updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer), node)
58919             : node;
58920     }
58921     ts.updateParameter = updateParameter;
58922     function createDecorator(expression) {
58923         var node = createSynthesizedNode(157);
58924         node.expression = ts.parenthesizeForAccess(expression);
58925         return node;
58926     }
58927     ts.createDecorator = createDecorator;
58928     function updateDecorator(node, expression) {
58929         return node.expression !== expression
58930             ? updateNode(createDecorator(expression), node)
58931             : node;
58932     }
58933     ts.updateDecorator = updateDecorator;
58934     function createPropertySignature(modifiers, name, questionToken, type, initializer) {
58935         var node = createSynthesizedNode(158);
58936         node.modifiers = asNodeArray(modifiers);
58937         node.name = asName(name);
58938         node.questionToken = questionToken;
58939         node.type = type;
58940         node.initializer = initializer;
58941         return node;
58942     }
58943     ts.createPropertySignature = createPropertySignature;
58944     function updatePropertySignature(node, modifiers, name, questionToken, type, initializer) {
58945         return node.modifiers !== modifiers
58946             || node.name !== name
58947             || node.questionToken !== questionToken
58948             || node.type !== type
58949             || node.initializer !== initializer
58950             ? updateNode(createPropertySignature(modifiers, name, questionToken, type, initializer), node)
58951             : node;
58952     }
58953     ts.updatePropertySignature = updatePropertySignature;
58954     function createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer) {
58955         var node = createSynthesizedNode(159);
58956         node.decorators = asNodeArray(decorators);
58957         node.modifiers = asNodeArray(modifiers);
58958         node.name = asName(name);
58959         node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 57 ? questionOrExclamationToken : undefined;
58960         node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 53 ? questionOrExclamationToken : undefined;
58961         node.type = type;
58962         node.initializer = initializer;
58963         return node;
58964     }
58965     ts.createProperty = createProperty;
58966     function updateProperty(node, decorators, modifiers, name, questionOrExclamationToken, type, initializer) {
58967         return node.decorators !== decorators
58968             || node.modifiers !== modifiers
58969             || node.name !== name
58970             || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 57 ? questionOrExclamationToken : undefined)
58971             || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 53 ? questionOrExclamationToken : undefined)
58972             || node.type !== type
58973             || node.initializer !== initializer
58974             ? updateNode(createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer), node)
58975             : node;
58976     }
58977     ts.updateProperty = updateProperty;
58978     function createMethodSignature(typeParameters, parameters, type, name, questionToken) {
58979         var node = createSignatureDeclaration(160, typeParameters, parameters, type);
58980         node.name = asName(name);
58981         node.questionToken = questionToken;
58982         return node;
58983     }
58984     ts.createMethodSignature = createMethodSignature;
58985     function updateMethodSignature(node, typeParameters, parameters, type, name, questionToken) {
58986         return node.typeParameters !== typeParameters
58987             || node.parameters !== parameters
58988             || node.type !== type
58989             || node.name !== name
58990             || node.questionToken !== questionToken
58991             ? updateNode(createMethodSignature(typeParameters, parameters, type, name, questionToken), node)
58992             : node;
58993     }
58994     ts.updateMethodSignature = updateMethodSignature;
58995     function createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) {
58996         var node = createSynthesizedNode(161);
58997         node.decorators = asNodeArray(decorators);
58998         node.modifiers = asNodeArray(modifiers);
58999         node.asteriskToken = asteriskToken;
59000         node.name = asName(name);
59001         node.questionToken = questionToken;
59002         node.typeParameters = asNodeArray(typeParameters);
59003         node.parameters = createNodeArray(parameters);
59004         node.type = type;
59005         node.body = body;
59006         return node;
59007     }
59008     ts.createMethod = createMethod;
59009     function createMethodCall(object, methodName, argumentsList) {
59010         return createCall(createPropertyAccess(object, asName(methodName)), undefined, argumentsList);
59011     }
59012     function createGlobalMethodCall(globalObjectName, methodName, argumentsList) {
59013         return createMethodCall(createIdentifier(globalObjectName), methodName, argumentsList);
59014     }
59015     function createObjectDefinePropertyCall(target, propertyName, attributes) {
59016         return createGlobalMethodCall("Object", "defineProperty", [target, asExpression(propertyName), attributes]);
59017     }
59018     ts.createObjectDefinePropertyCall = createObjectDefinePropertyCall;
59019     function tryAddPropertyAssignment(properties, propertyName, expression) {
59020         if (expression) {
59021             properties.push(createPropertyAssignment(propertyName, expression));
59022             return true;
59023         }
59024         return false;
59025     }
59026     function createPropertyDescriptor(attributes, singleLine) {
59027         var properties = [];
59028         tryAddPropertyAssignment(properties, "enumerable", asExpression(attributes.enumerable));
59029         tryAddPropertyAssignment(properties, "configurable", asExpression(attributes.configurable));
59030         var isData = tryAddPropertyAssignment(properties, "writable", asExpression(attributes.writable));
59031         isData = tryAddPropertyAssignment(properties, "value", attributes.value) || isData;
59032         var isAccessor = tryAddPropertyAssignment(properties, "get", attributes.get);
59033         isAccessor = tryAddPropertyAssignment(properties, "set", attributes.set) || isAccessor;
59034         ts.Debug.assert(!(isData && isAccessor), "A PropertyDescriptor may not be both an accessor descriptor and a data descriptor.");
59035         return createObjectLiteral(properties, !singleLine);
59036     }
59037     ts.createPropertyDescriptor = createPropertyDescriptor;
59038     function updateMethod(node, decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) {
59039         return node.decorators !== decorators
59040             || node.modifiers !== modifiers
59041             || node.asteriskToken !== asteriskToken
59042             || node.name !== name
59043             || node.questionToken !== questionToken
59044             || node.typeParameters !== typeParameters
59045             || node.parameters !== parameters
59046             || node.type !== type
59047             || node.body !== body
59048             ? updateNode(createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body), node)
59049             : node;
59050     }
59051     ts.updateMethod = updateMethod;
59052     function createConstructor(decorators, modifiers, parameters, body) {
59053         var node = createSynthesizedNode(162);
59054         node.decorators = asNodeArray(decorators);
59055         node.modifiers = asNodeArray(modifiers);
59056         node.typeParameters = undefined;
59057         node.parameters = createNodeArray(parameters);
59058         node.type = undefined;
59059         node.body = body;
59060         return node;
59061     }
59062     ts.createConstructor = createConstructor;
59063     function updateConstructor(node, decorators, modifiers, parameters, body) {
59064         return node.decorators !== decorators
59065             || node.modifiers !== modifiers
59066             || node.parameters !== parameters
59067             || node.body !== body
59068             ? updateNode(createConstructor(decorators, modifiers, parameters, body), node)
59069             : node;
59070     }
59071     ts.updateConstructor = updateConstructor;
59072     function createGetAccessor(decorators, modifiers, name, parameters, type, body) {
59073         var node = createSynthesizedNode(163);
59074         node.decorators = asNodeArray(decorators);
59075         node.modifiers = asNodeArray(modifiers);
59076         node.name = asName(name);
59077         node.typeParameters = undefined;
59078         node.parameters = createNodeArray(parameters);
59079         node.type = type;
59080         node.body = body;
59081         return node;
59082     }
59083     ts.createGetAccessor = createGetAccessor;
59084     function updateGetAccessor(node, decorators, modifiers, name, parameters, type, body) {
59085         return node.decorators !== decorators
59086             || node.modifiers !== modifiers
59087             || node.name !== name
59088             || node.parameters !== parameters
59089             || node.type !== type
59090             || node.body !== body
59091             ? updateNode(createGetAccessor(decorators, modifiers, name, parameters, type, body), node)
59092             : node;
59093     }
59094     ts.updateGetAccessor = updateGetAccessor;
59095     function createSetAccessor(decorators, modifiers, name, parameters, body) {
59096         var node = createSynthesizedNode(164);
59097         node.decorators = asNodeArray(decorators);
59098         node.modifiers = asNodeArray(modifiers);
59099         node.name = asName(name);
59100         node.typeParameters = undefined;
59101         node.parameters = createNodeArray(parameters);
59102         node.body = body;
59103         return node;
59104     }
59105     ts.createSetAccessor = createSetAccessor;
59106     function updateSetAccessor(node, decorators, modifiers, name, parameters, body) {
59107         return node.decorators !== decorators
59108             || node.modifiers !== modifiers
59109             || node.name !== name
59110             || node.parameters !== parameters
59111             || node.body !== body
59112             ? updateNode(createSetAccessor(decorators, modifiers, name, parameters, body), node)
59113             : node;
59114     }
59115     ts.updateSetAccessor = updateSetAccessor;
59116     function createCallSignature(typeParameters, parameters, type) {
59117         return createSignatureDeclaration(165, typeParameters, parameters, type);
59118     }
59119     ts.createCallSignature = createCallSignature;
59120     function updateCallSignature(node, typeParameters, parameters, type) {
59121         return updateSignatureDeclaration(node, typeParameters, parameters, type);
59122     }
59123     ts.updateCallSignature = updateCallSignature;
59124     function createConstructSignature(typeParameters, parameters, type) {
59125         return createSignatureDeclaration(166, typeParameters, parameters, type);
59126     }
59127     ts.createConstructSignature = createConstructSignature;
59128     function updateConstructSignature(node, typeParameters, parameters, type) {
59129         return updateSignatureDeclaration(node, typeParameters, parameters, type);
59130     }
59131     ts.updateConstructSignature = updateConstructSignature;
59132     function createIndexSignature(decorators, modifiers, parameters, type) {
59133         var node = createSynthesizedNode(167);
59134         node.decorators = asNodeArray(decorators);
59135         node.modifiers = asNodeArray(modifiers);
59136         node.parameters = createNodeArray(parameters);
59137         node.type = type;
59138         return node;
59139     }
59140     ts.createIndexSignature = createIndexSignature;
59141     function updateIndexSignature(node, decorators, modifiers, parameters, type) {
59142         return node.parameters !== parameters
59143             || node.type !== type
59144             || node.decorators !== decorators
59145             || node.modifiers !== modifiers
59146             ? updateNode(createIndexSignature(decorators, modifiers, parameters, type), node)
59147             : node;
59148     }
59149     ts.updateIndexSignature = updateIndexSignature;
59150     function createSignatureDeclaration(kind, typeParameters, parameters, type, typeArguments) {
59151         var node = createSynthesizedNode(kind);
59152         node.typeParameters = asNodeArray(typeParameters);
59153         node.parameters = asNodeArray(parameters);
59154         node.type = type;
59155         node.typeArguments = asNodeArray(typeArguments);
59156         return node;
59157     }
59158     ts.createSignatureDeclaration = createSignatureDeclaration;
59159     function updateSignatureDeclaration(node, typeParameters, parameters, type) {
59160         return node.typeParameters !== typeParameters
59161             || node.parameters !== parameters
59162             || node.type !== type
59163             ? updateNode(createSignatureDeclaration(node.kind, typeParameters, parameters, type), node)
59164             : node;
59165     }
59166     function createKeywordTypeNode(kind) {
59167         return createSynthesizedNode(kind);
59168     }
59169     ts.createKeywordTypeNode = createKeywordTypeNode;
59170     function createTypePredicateNode(parameterName, type) {
59171         return createTypePredicateNodeWithModifier(undefined, parameterName, type);
59172     }
59173     ts.createTypePredicateNode = createTypePredicateNode;
59174     function createTypePredicateNodeWithModifier(assertsModifier, parameterName, type) {
59175         var node = createSynthesizedNode(168);
59176         node.assertsModifier = assertsModifier;
59177         node.parameterName = asName(parameterName);
59178         node.type = type;
59179         return node;
59180     }
59181     ts.createTypePredicateNodeWithModifier = createTypePredicateNodeWithModifier;
59182     function updateTypePredicateNode(node, parameterName, type) {
59183         return updateTypePredicateNodeWithModifier(node, node.assertsModifier, parameterName, type);
59184     }
59185     ts.updateTypePredicateNode = updateTypePredicateNode;
59186     function updateTypePredicateNodeWithModifier(node, assertsModifier, parameterName, type) {
59187         return node.assertsModifier !== assertsModifier
59188             || node.parameterName !== parameterName
59189             || node.type !== type
59190             ? updateNode(createTypePredicateNodeWithModifier(assertsModifier, parameterName, type), node)
59191             : node;
59192     }
59193     ts.updateTypePredicateNodeWithModifier = updateTypePredicateNodeWithModifier;
59194     function createTypeReferenceNode(typeName, typeArguments) {
59195         var node = createSynthesizedNode(169);
59196         node.typeName = asName(typeName);
59197         node.typeArguments = typeArguments && ts.parenthesizeTypeParameters(typeArguments);
59198         return node;
59199     }
59200     ts.createTypeReferenceNode = createTypeReferenceNode;
59201     function updateTypeReferenceNode(node, typeName, typeArguments) {
59202         return node.typeName !== typeName
59203             || node.typeArguments !== typeArguments
59204             ? updateNode(createTypeReferenceNode(typeName, typeArguments), node)
59205             : node;
59206     }
59207     ts.updateTypeReferenceNode = updateTypeReferenceNode;
59208     function createFunctionTypeNode(typeParameters, parameters, type) {
59209         return createSignatureDeclaration(170, typeParameters, parameters, type);
59210     }
59211     ts.createFunctionTypeNode = createFunctionTypeNode;
59212     function updateFunctionTypeNode(node, typeParameters, parameters, type) {
59213         return updateSignatureDeclaration(node, typeParameters, parameters, type);
59214     }
59215     ts.updateFunctionTypeNode = updateFunctionTypeNode;
59216     function createConstructorTypeNode(typeParameters, parameters, type) {
59217         return createSignatureDeclaration(171, typeParameters, parameters, type);
59218     }
59219     ts.createConstructorTypeNode = createConstructorTypeNode;
59220     function updateConstructorTypeNode(node, typeParameters, parameters, type) {
59221         return updateSignatureDeclaration(node, typeParameters, parameters, type);
59222     }
59223     ts.updateConstructorTypeNode = updateConstructorTypeNode;
59224     function createTypeQueryNode(exprName) {
59225         var node = createSynthesizedNode(172);
59226         node.exprName = exprName;
59227         return node;
59228     }
59229     ts.createTypeQueryNode = createTypeQueryNode;
59230     function updateTypeQueryNode(node, exprName) {
59231         return node.exprName !== exprName
59232             ? updateNode(createTypeQueryNode(exprName), node)
59233             : node;
59234     }
59235     ts.updateTypeQueryNode = updateTypeQueryNode;
59236     function createTypeLiteralNode(members) {
59237         var node = createSynthesizedNode(173);
59238         node.members = createNodeArray(members);
59239         return node;
59240     }
59241     ts.createTypeLiteralNode = createTypeLiteralNode;
59242     function updateTypeLiteralNode(node, members) {
59243         return node.members !== members
59244             ? updateNode(createTypeLiteralNode(members), node)
59245             : node;
59246     }
59247     ts.updateTypeLiteralNode = updateTypeLiteralNode;
59248     function createArrayTypeNode(elementType) {
59249         var node = createSynthesizedNode(174);
59250         node.elementType = ts.parenthesizeArrayTypeMember(elementType);
59251         return node;
59252     }
59253     ts.createArrayTypeNode = createArrayTypeNode;
59254     function updateArrayTypeNode(node, elementType) {
59255         return node.elementType !== elementType
59256             ? updateNode(createArrayTypeNode(elementType), node)
59257             : node;
59258     }
59259     ts.updateArrayTypeNode = updateArrayTypeNode;
59260     function createTupleTypeNode(elementTypes) {
59261         var node = createSynthesizedNode(175);
59262         node.elementTypes = createNodeArray(elementTypes);
59263         return node;
59264     }
59265     ts.createTupleTypeNode = createTupleTypeNode;
59266     function updateTupleTypeNode(node, elementTypes) {
59267         return node.elementTypes !== elementTypes
59268             ? updateNode(createTupleTypeNode(elementTypes), node)
59269             : node;
59270     }
59271     ts.updateTupleTypeNode = updateTupleTypeNode;
59272     function createOptionalTypeNode(type) {
59273         var node = createSynthesizedNode(176);
59274         node.type = ts.parenthesizeArrayTypeMember(type);
59275         return node;
59276     }
59277     ts.createOptionalTypeNode = createOptionalTypeNode;
59278     function updateOptionalTypeNode(node, type) {
59279         return node.type !== type
59280             ? updateNode(createOptionalTypeNode(type), node)
59281             : node;
59282     }
59283     ts.updateOptionalTypeNode = updateOptionalTypeNode;
59284     function createRestTypeNode(type) {
59285         var node = createSynthesizedNode(177);
59286         node.type = type;
59287         return node;
59288     }
59289     ts.createRestTypeNode = createRestTypeNode;
59290     function updateRestTypeNode(node, type) {
59291         return node.type !== type
59292             ? updateNode(createRestTypeNode(type), node)
59293             : node;
59294     }
59295     ts.updateRestTypeNode = updateRestTypeNode;
59296     function createUnionTypeNode(types) {
59297         return createUnionOrIntersectionTypeNode(178, types);
59298     }
59299     ts.createUnionTypeNode = createUnionTypeNode;
59300     function updateUnionTypeNode(node, types) {
59301         return updateUnionOrIntersectionTypeNode(node, types);
59302     }
59303     ts.updateUnionTypeNode = updateUnionTypeNode;
59304     function createIntersectionTypeNode(types) {
59305         return createUnionOrIntersectionTypeNode(179, types);
59306     }
59307     ts.createIntersectionTypeNode = createIntersectionTypeNode;
59308     function updateIntersectionTypeNode(node, types) {
59309         return updateUnionOrIntersectionTypeNode(node, types);
59310     }
59311     ts.updateIntersectionTypeNode = updateIntersectionTypeNode;
59312     function createUnionOrIntersectionTypeNode(kind, types) {
59313         var node = createSynthesizedNode(kind);
59314         node.types = ts.parenthesizeElementTypeMembers(types);
59315         return node;
59316     }
59317     ts.createUnionOrIntersectionTypeNode = createUnionOrIntersectionTypeNode;
59318     function updateUnionOrIntersectionTypeNode(node, types) {
59319         return node.types !== types
59320             ? updateNode(createUnionOrIntersectionTypeNode(node.kind, types), node)
59321             : node;
59322     }
59323     function createConditionalTypeNode(checkType, extendsType, trueType, falseType) {
59324         var node = createSynthesizedNode(180);
59325         node.checkType = ts.parenthesizeConditionalTypeMember(checkType);
59326         node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType);
59327         node.trueType = trueType;
59328         node.falseType = falseType;
59329         return node;
59330     }
59331     ts.createConditionalTypeNode = createConditionalTypeNode;
59332     function updateConditionalTypeNode(node, checkType, extendsType, trueType, falseType) {
59333         return node.checkType !== checkType
59334             || node.extendsType !== extendsType
59335             || node.trueType !== trueType
59336             || node.falseType !== falseType
59337             ? updateNode(createConditionalTypeNode(checkType, extendsType, trueType, falseType), node)
59338             : node;
59339     }
59340     ts.updateConditionalTypeNode = updateConditionalTypeNode;
59341     function createInferTypeNode(typeParameter) {
59342         var node = createSynthesizedNode(181);
59343         node.typeParameter = typeParameter;
59344         return node;
59345     }
59346     ts.createInferTypeNode = createInferTypeNode;
59347     function updateInferTypeNode(node, typeParameter) {
59348         return node.typeParameter !== typeParameter
59349             ? updateNode(createInferTypeNode(typeParameter), node)
59350             : node;
59351     }
59352     ts.updateInferTypeNode = updateInferTypeNode;
59353     function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) {
59354         var node = createSynthesizedNode(188);
59355         node.argument = argument;
59356         node.qualifier = qualifier;
59357         node.typeArguments = ts.parenthesizeTypeParameters(typeArguments);
59358         node.isTypeOf = isTypeOf;
59359         return node;
59360     }
59361     ts.createImportTypeNode = createImportTypeNode;
59362     function updateImportTypeNode(node, argument, qualifier, typeArguments, isTypeOf) {
59363         return node.argument !== argument
59364             || node.qualifier !== qualifier
59365             || node.typeArguments !== typeArguments
59366             || node.isTypeOf !== isTypeOf
59367             ? updateNode(createImportTypeNode(argument, qualifier, typeArguments, isTypeOf), node)
59368             : node;
59369     }
59370     ts.updateImportTypeNode = updateImportTypeNode;
59371     function createParenthesizedType(type) {
59372         var node = createSynthesizedNode(182);
59373         node.type = type;
59374         return node;
59375     }
59376     ts.createParenthesizedType = createParenthesizedType;
59377     function updateParenthesizedType(node, type) {
59378         return node.type !== type
59379             ? updateNode(createParenthesizedType(type), node)
59380             : node;
59381     }
59382     ts.updateParenthesizedType = updateParenthesizedType;
59383     function createThisTypeNode() {
59384         return createSynthesizedNode(183);
59385     }
59386     ts.createThisTypeNode = createThisTypeNode;
59387     function createTypeOperatorNode(operatorOrType, type) {
59388         var node = createSynthesizedNode(184);
59389         node.operator = typeof operatorOrType === "number" ? operatorOrType : 134;
59390         node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType);
59391         return node;
59392     }
59393     ts.createTypeOperatorNode = createTypeOperatorNode;
59394     function updateTypeOperatorNode(node, type) {
59395         return node.type !== type ? updateNode(createTypeOperatorNode(node.operator, type), node) : node;
59396     }
59397     ts.updateTypeOperatorNode = updateTypeOperatorNode;
59398     function createIndexedAccessTypeNode(objectType, indexType) {
59399         var node = createSynthesizedNode(185);
59400         node.objectType = ts.parenthesizeElementTypeMember(objectType);
59401         node.indexType = indexType;
59402         return node;
59403     }
59404     ts.createIndexedAccessTypeNode = createIndexedAccessTypeNode;
59405     function updateIndexedAccessTypeNode(node, objectType, indexType) {
59406         return node.objectType !== objectType
59407             || node.indexType !== indexType
59408             ? updateNode(createIndexedAccessTypeNode(objectType, indexType), node)
59409             : node;
59410     }
59411     ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode;
59412     function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) {
59413         var node = createSynthesizedNode(186);
59414         node.readonlyToken = readonlyToken;
59415         node.typeParameter = typeParameter;
59416         node.questionToken = questionToken;
59417         node.type = type;
59418         return node;
59419     }
59420     ts.createMappedTypeNode = createMappedTypeNode;
59421     function updateMappedTypeNode(node, readonlyToken, typeParameter, questionToken, type) {
59422         return node.readonlyToken !== readonlyToken
59423             || node.typeParameter !== typeParameter
59424             || node.questionToken !== questionToken
59425             || node.type !== type
59426             ? updateNode(createMappedTypeNode(readonlyToken, typeParameter, questionToken, type), node)
59427             : node;
59428     }
59429     ts.updateMappedTypeNode = updateMappedTypeNode;
59430     function createLiteralTypeNode(literal) {
59431         var node = createSynthesizedNode(187);
59432         node.literal = literal;
59433         return node;
59434     }
59435     ts.createLiteralTypeNode = createLiteralTypeNode;
59436     function updateLiteralTypeNode(node, literal) {
59437         return node.literal !== literal
59438             ? updateNode(createLiteralTypeNode(literal), node)
59439             : node;
59440     }
59441     ts.updateLiteralTypeNode = updateLiteralTypeNode;
59442     function createObjectBindingPattern(elements) {
59443         var node = createSynthesizedNode(189);
59444         node.elements = createNodeArray(elements);
59445         return node;
59446     }
59447     ts.createObjectBindingPattern = createObjectBindingPattern;
59448     function updateObjectBindingPattern(node, elements) {
59449         return node.elements !== elements
59450             ? updateNode(createObjectBindingPattern(elements), node)
59451             : node;
59452     }
59453     ts.updateObjectBindingPattern = updateObjectBindingPattern;
59454     function createArrayBindingPattern(elements) {
59455         var node = createSynthesizedNode(190);
59456         node.elements = createNodeArray(elements);
59457         return node;
59458     }
59459     ts.createArrayBindingPattern = createArrayBindingPattern;
59460     function updateArrayBindingPattern(node, elements) {
59461         return node.elements !== elements
59462             ? updateNode(createArrayBindingPattern(elements), node)
59463             : node;
59464     }
59465     ts.updateArrayBindingPattern = updateArrayBindingPattern;
59466     function createBindingElement(dotDotDotToken, propertyName, name, initializer) {
59467         var node = createSynthesizedNode(191);
59468         node.dotDotDotToken = dotDotDotToken;
59469         node.propertyName = asName(propertyName);
59470         node.name = asName(name);
59471         node.initializer = initializer;
59472         return node;
59473     }
59474     ts.createBindingElement = createBindingElement;
59475     function updateBindingElement(node, dotDotDotToken, propertyName, name, initializer) {
59476         return node.propertyName !== propertyName
59477             || node.dotDotDotToken !== dotDotDotToken
59478             || node.name !== name
59479             || node.initializer !== initializer
59480             ? updateNode(createBindingElement(dotDotDotToken, propertyName, name, initializer), node)
59481             : node;
59482     }
59483     ts.updateBindingElement = updateBindingElement;
59484     function createArrayLiteral(elements, multiLine) {
59485         var node = createSynthesizedNode(192);
59486         node.elements = ts.parenthesizeListElements(createNodeArray(elements));
59487         if (multiLine)
59488             node.multiLine = true;
59489         return node;
59490     }
59491     ts.createArrayLiteral = createArrayLiteral;
59492     function updateArrayLiteral(node, elements) {
59493         return node.elements !== elements
59494             ? updateNode(createArrayLiteral(elements, node.multiLine), node)
59495             : node;
59496     }
59497     ts.updateArrayLiteral = updateArrayLiteral;
59498     function createObjectLiteral(properties, multiLine) {
59499         var node = createSynthesizedNode(193);
59500         node.properties = createNodeArray(properties);
59501         if (multiLine)
59502             node.multiLine = true;
59503         return node;
59504     }
59505     ts.createObjectLiteral = createObjectLiteral;
59506     function updateObjectLiteral(node, properties) {
59507         return node.properties !== properties
59508             ? updateNode(createObjectLiteral(properties, node.multiLine), node)
59509             : node;
59510     }
59511     ts.updateObjectLiteral = updateObjectLiteral;
59512     function createPropertyAccess(expression, name) {
59513         var node = createSynthesizedNode(194);
59514         node.expression = ts.parenthesizeForAccess(expression);
59515         node.name = asName(name);
59516         setEmitFlags(node, 131072);
59517         return node;
59518     }
59519     ts.createPropertyAccess = createPropertyAccess;
59520     function updatePropertyAccess(node, expression, name) {
59521         if (ts.isPropertyAccessChain(node)) {
59522             return updatePropertyAccessChain(node, expression, node.questionDotToken, ts.cast(name, ts.isIdentifier));
59523         }
59524         return node.expression !== expression
59525             || node.name !== name
59526             ? updateNode(setEmitFlags(createPropertyAccess(expression, name), ts.getEmitFlags(node)), node)
59527             : node;
59528     }
59529     ts.updatePropertyAccess = updatePropertyAccess;
59530     function createPropertyAccessChain(expression, questionDotToken, name) {
59531         var node = createSynthesizedNode(194);
59532         node.flags |= 32;
59533         node.expression = ts.parenthesizeForAccess(expression);
59534         node.questionDotToken = questionDotToken;
59535         node.name = asName(name);
59536         setEmitFlags(node, 131072);
59537         return node;
59538     }
59539     ts.createPropertyAccessChain = createPropertyAccessChain;
59540     function updatePropertyAccessChain(node, expression, questionDotToken, name) {
59541         ts.Debug.assert(!!(node.flags & 32), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead.");
59542         return node.expression !== expression
59543             || node.questionDotToken !== questionDotToken
59544             || node.name !== name
59545             ? updateNode(setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), ts.getEmitFlags(node)), node)
59546             : node;
59547     }
59548     ts.updatePropertyAccessChain = updatePropertyAccessChain;
59549     function createElementAccess(expression, index) {
59550         var node = createSynthesizedNode(195);
59551         node.expression = ts.parenthesizeForAccess(expression);
59552         node.argumentExpression = asExpression(index);
59553         return node;
59554     }
59555     ts.createElementAccess = createElementAccess;
59556     function updateElementAccess(node, expression, argumentExpression) {
59557         if (ts.isOptionalChain(node)) {
59558             return updateElementAccessChain(node, expression, node.questionDotToken, argumentExpression);
59559         }
59560         return node.expression !== expression
59561             || node.argumentExpression !== argumentExpression
59562             ? updateNode(createElementAccess(expression, argumentExpression), node)
59563             : node;
59564     }
59565     ts.updateElementAccess = updateElementAccess;
59566     function createElementAccessChain(expression, questionDotToken, index) {
59567         var node = createSynthesizedNode(195);
59568         node.flags |= 32;
59569         node.expression = ts.parenthesizeForAccess(expression);
59570         node.questionDotToken = questionDotToken;
59571         node.argumentExpression = asExpression(index);
59572         return node;
59573     }
59574     ts.createElementAccessChain = createElementAccessChain;
59575     function updateElementAccessChain(node, expression, questionDotToken, argumentExpression) {
59576         ts.Debug.assert(!!(node.flags & 32), "Cannot update an ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead.");
59577         return node.expression !== expression
59578             || node.questionDotToken !== questionDotToken
59579             || node.argumentExpression !== argumentExpression
59580             ? updateNode(createElementAccessChain(expression, questionDotToken, argumentExpression), node)
59581             : node;
59582     }
59583     ts.updateElementAccessChain = updateElementAccessChain;
59584     function createCall(expression, typeArguments, argumentsArray) {
59585         var node = createSynthesizedNode(196);
59586         node.expression = ts.parenthesizeForAccess(expression);
59587         node.typeArguments = asNodeArray(typeArguments);
59588         node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray));
59589         return node;
59590     }
59591     ts.createCall = createCall;
59592     function updateCall(node, expression, typeArguments, argumentsArray) {
59593         if (ts.isOptionalChain(node)) {
59594             return updateCallChain(node, expression, node.questionDotToken, typeArguments, argumentsArray);
59595         }
59596         return node.expression !== expression
59597             || node.typeArguments !== typeArguments
59598             || node.arguments !== argumentsArray
59599             ? updateNode(createCall(expression, typeArguments, argumentsArray), node)
59600             : node;
59601     }
59602     ts.updateCall = updateCall;
59603     function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) {
59604         var node = createSynthesizedNode(196);
59605         node.flags |= 32;
59606         node.expression = ts.parenthesizeForAccess(expression);
59607         node.questionDotToken = questionDotToken;
59608         node.typeArguments = asNodeArray(typeArguments);
59609         node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray));
59610         return node;
59611     }
59612     ts.createCallChain = createCallChain;
59613     function updateCallChain(node, expression, questionDotToken, typeArguments, argumentsArray) {
59614         ts.Debug.assert(!!(node.flags & 32), "Cannot update a CallExpression using updateCallChain. Use updateCall instead.");
59615         return node.expression !== expression
59616             || node.questionDotToken !== questionDotToken
59617             || node.typeArguments !== typeArguments
59618             || node.arguments !== argumentsArray
59619             ? updateNode(createCallChain(expression, questionDotToken, typeArguments, argumentsArray), node)
59620             : node;
59621     }
59622     ts.updateCallChain = updateCallChain;
59623     function createNew(expression, typeArguments, argumentsArray) {
59624         var node = createSynthesizedNode(197);
59625         node.expression = ts.parenthesizeForNew(expression);
59626         node.typeArguments = asNodeArray(typeArguments);
59627         node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined;
59628         return node;
59629     }
59630     ts.createNew = createNew;
59631     function updateNew(node, expression, typeArguments, argumentsArray) {
59632         return node.expression !== expression
59633             || node.typeArguments !== typeArguments
59634             || node.arguments !== argumentsArray
59635             ? updateNode(createNew(expression, typeArguments, argumentsArray), node)
59636             : node;
59637     }
59638     ts.updateNew = updateNew;
59639     function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) {
59640         var node = createSynthesizedNode(198);
59641         node.tag = ts.parenthesizeForAccess(tag);
59642         if (template) {
59643             node.typeArguments = asNodeArray(typeArgumentsOrTemplate);
59644             node.template = template;
59645         }
59646         else {
59647             node.typeArguments = undefined;
59648             node.template = typeArgumentsOrTemplate;
59649         }
59650         return node;
59651     }
59652     ts.createTaggedTemplate = createTaggedTemplate;
59653     function updateTaggedTemplate(node, tag, typeArgumentsOrTemplate, template) {
59654         return node.tag !== tag
59655             || (template
59656                 ? node.typeArguments !== typeArgumentsOrTemplate || node.template !== template
59657                 : node.typeArguments !== undefined || node.template !== typeArgumentsOrTemplate)
59658             ? updateNode(createTaggedTemplate(tag, typeArgumentsOrTemplate, template), node)
59659             : node;
59660     }
59661     ts.updateTaggedTemplate = updateTaggedTemplate;
59662     function createTypeAssertion(type, expression) {
59663         var node = createSynthesizedNode(199);
59664         node.type = type;
59665         node.expression = ts.parenthesizePrefixOperand(expression);
59666         return node;
59667     }
59668     ts.createTypeAssertion = createTypeAssertion;
59669     function updateTypeAssertion(node, type, expression) {
59670         return node.type !== type
59671             || node.expression !== expression
59672             ? updateNode(createTypeAssertion(type, expression), node)
59673             : node;
59674     }
59675     ts.updateTypeAssertion = updateTypeAssertion;
59676     function createParen(expression) {
59677         var node = createSynthesizedNode(200);
59678         node.expression = expression;
59679         return node;
59680     }
59681     ts.createParen = createParen;
59682     function updateParen(node, expression) {
59683         return node.expression !== expression
59684             ? updateNode(createParen(expression), node)
59685             : node;
59686     }
59687     ts.updateParen = updateParen;
59688     function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) {
59689         var node = createSynthesizedNode(201);
59690         node.modifiers = asNodeArray(modifiers);
59691         node.asteriskToken = asteriskToken;
59692         node.name = asName(name);
59693         node.typeParameters = asNodeArray(typeParameters);
59694         node.parameters = createNodeArray(parameters);
59695         node.type = type;
59696         node.body = body;
59697         return node;
59698     }
59699     ts.createFunctionExpression = createFunctionExpression;
59700     function updateFunctionExpression(node, modifiers, asteriskToken, name, typeParameters, parameters, type, body) {
59701         return node.name !== name
59702             || node.modifiers !== modifiers
59703             || node.asteriskToken !== asteriskToken
59704             || node.typeParameters !== typeParameters
59705             || node.parameters !== parameters
59706             || node.type !== type
59707             || node.body !== body
59708             ? updateNode(createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body), node)
59709             : node;
59710     }
59711     ts.updateFunctionExpression = updateFunctionExpression;
59712     function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) {
59713         var node = createSynthesizedNode(202);
59714         node.modifiers = asNodeArray(modifiers);
59715         node.typeParameters = asNodeArray(typeParameters);
59716         node.parameters = createNodeArray(parameters);
59717         node.type = type;
59718         node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(38);
59719         node.body = ts.parenthesizeConciseBody(body);
59720         return node;
59721     }
59722     ts.createArrowFunction = createArrowFunction;
59723     function updateArrowFunction(node, modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) {
59724         return node.modifiers !== modifiers
59725             || node.typeParameters !== typeParameters
59726             || node.parameters !== parameters
59727             || node.type !== type
59728             || node.equalsGreaterThanToken !== equalsGreaterThanToken
59729             || node.body !== body
59730             ? updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body), node)
59731             : node;
59732     }
59733     ts.updateArrowFunction = updateArrowFunction;
59734     function createDelete(expression) {
59735         var node = createSynthesizedNode(203);
59736         node.expression = ts.parenthesizePrefixOperand(expression);
59737         return node;
59738     }
59739     ts.createDelete = createDelete;
59740     function updateDelete(node, expression) {
59741         return node.expression !== expression
59742             ? updateNode(createDelete(expression), node)
59743             : node;
59744     }
59745     ts.updateDelete = updateDelete;
59746     function createTypeOf(expression) {
59747         var node = createSynthesizedNode(204);
59748         node.expression = ts.parenthesizePrefixOperand(expression);
59749         return node;
59750     }
59751     ts.createTypeOf = createTypeOf;
59752     function updateTypeOf(node, expression) {
59753         return node.expression !== expression
59754             ? updateNode(createTypeOf(expression), node)
59755             : node;
59756     }
59757     ts.updateTypeOf = updateTypeOf;
59758     function createVoid(expression) {
59759         var node = createSynthesizedNode(205);
59760         node.expression = ts.parenthesizePrefixOperand(expression);
59761         return node;
59762     }
59763     ts.createVoid = createVoid;
59764     function updateVoid(node, expression) {
59765         return node.expression !== expression
59766             ? updateNode(createVoid(expression), node)
59767             : node;
59768     }
59769     ts.updateVoid = updateVoid;
59770     function createAwait(expression) {
59771         var node = createSynthesizedNode(206);
59772         node.expression = ts.parenthesizePrefixOperand(expression);
59773         return node;
59774     }
59775     ts.createAwait = createAwait;
59776     function updateAwait(node, expression) {
59777         return node.expression !== expression
59778             ? updateNode(createAwait(expression), node)
59779             : node;
59780     }
59781     ts.updateAwait = updateAwait;
59782     function createPrefix(operator, operand) {
59783         var node = createSynthesizedNode(207);
59784         node.operator = operator;
59785         node.operand = ts.parenthesizePrefixOperand(operand);
59786         return node;
59787     }
59788     ts.createPrefix = createPrefix;
59789     function updatePrefix(node, operand) {
59790         return node.operand !== operand
59791             ? updateNode(createPrefix(node.operator, operand), node)
59792             : node;
59793     }
59794     ts.updatePrefix = updatePrefix;
59795     function createPostfix(operand, operator) {
59796         var node = createSynthesizedNode(208);
59797         node.operand = ts.parenthesizePostfixOperand(operand);
59798         node.operator = operator;
59799         return node;
59800     }
59801     ts.createPostfix = createPostfix;
59802     function updatePostfix(node, operand) {
59803         return node.operand !== operand
59804             ? updateNode(createPostfix(operand, node.operator), node)
59805             : node;
59806     }
59807     ts.updatePostfix = updatePostfix;
59808     function createBinary(left, operator, right) {
59809         var node = createSynthesizedNode(209);
59810         var operatorToken = asToken(operator);
59811         var operatorKind = operatorToken.kind;
59812         node.left = ts.parenthesizeBinaryOperand(operatorKind, left, true, undefined);
59813         node.operatorToken = operatorToken;
59814         node.right = ts.parenthesizeBinaryOperand(operatorKind, right, false, node.left);
59815         return node;
59816     }
59817     ts.createBinary = createBinary;
59818     function updateBinary(node, left, right, operator) {
59819         return node.left !== left
59820             || node.right !== right
59821             ? updateNode(createBinary(left, operator || node.operatorToken, right), node)
59822             : node;
59823     }
59824     ts.updateBinary = updateBinary;
59825     function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) {
59826         var node = createSynthesizedNode(210);
59827         node.condition = ts.parenthesizeForConditionalHead(condition);
59828         node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(57);
59829         node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue);
59830         node.colonToken = whenFalse ? colonToken : createToken(58);
59831         node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse);
59832         return node;
59833     }
59834     ts.createConditional = createConditional;
59835     function updateConditional(node, condition, questionToken, whenTrue, colonToken, whenFalse) {
59836         return node.condition !== condition
59837             || node.questionToken !== questionToken
59838             || node.whenTrue !== whenTrue
59839             || node.colonToken !== colonToken
59840             || node.whenFalse !== whenFalse
59841             ? updateNode(createConditional(condition, questionToken, whenTrue, colonToken, whenFalse), node)
59842             : node;
59843     }
59844     ts.updateConditional = updateConditional;
59845     function createTemplateExpression(head, templateSpans) {
59846         var node = createSynthesizedNode(211);
59847         node.head = head;
59848         node.templateSpans = createNodeArray(templateSpans);
59849         return node;
59850     }
59851     ts.createTemplateExpression = createTemplateExpression;
59852     function updateTemplateExpression(node, head, templateSpans) {
59853         return node.head !== head
59854             || node.templateSpans !== templateSpans
59855             ? updateNode(createTemplateExpression(head, templateSpans), node)
59856             : node;
59857     }
59858     ts.updateTemplateExpression = updateTemplateExpression;
59859     var rawTextScanner;
59860     var invalidValueSentinel = {};
59861     function getCookedText(kind, rawText) {
59862         if (!rawTextScanner) {
59863             rawTextScanner = ts.createScanner(99, false, 0);
59864         }
59865         switch (kind) {
59866             case 14:
59867                 rawTextScanner.setText("`" + rawText + "`");
59868                 break;
59869             case 15:
59870                 rawTextScanner.setText("`" + rawText + "${");
59871                 break;
59872             case 16:
59873                 rawTextScanner.setText("}" + rawText + "${");
59874                 break;
59875             case 17:
59876                 rawTextScanner.setText("}" + rawText + "`");
59877                 break;
59878         }
59879         var token = rawTextScanner.scan();
59880         if (token === 23) {
59881             token = rawTextScanner.reScanTemplateToken(false);
59882         }
59883         if (rawTextScanner.isUnterminated()) {
59884             rawTextScanner.setText(undefined);
59885             return invalidValueSentinel;
59886         }
59887         var tokenValue;
59888         switch (token) {
59889             case 14:
59890             case 15:
59891             case 16:
59892             case 17:
59893                 tokenValue = rawTextScanner.getTokenValue();
59894                 break;
59895         }
59896         if (rawTextScanner.scan() !== 1) {
59897             rawTextScanner.setText(undefined);
59898             return invalidValueSentinel;
59899         }
59900         rawTextScanner.setText(undefined);
59901         return tokenValue;
59902     }
59903     function createTemplateLiteralLikeNode(kind, text, rawText) {
59904         var node = createSynthesizedNode(kind);
59905         node.text = text;
59906         if (rawText === undefined || text === rawText) {
59907             node.rawText = rawText;
59908         }
59909         else {
59910             var cooked = getCookedText(kind, rawText);
59911             if (typeof cooked === "object") {
59912                 return ts.Debug.fail("Invalid raw text");
59913             }
59914             ts.Debug.assert(text === cooked, "Expected argument 'text' to be the normalized (i.e. 'cooked') version of argument 'rawText'.");
59915             node.rawText = rawText;
59916         }
59917         return node;
59918     }
59919     function createTemplateHead(text, rawText) {
59920         var node = createTemplateLiteralLikeNode(15, text, rawText);
59921         node.text = text;
59922         return node;
59923     }
59924     ts.createTemplateHead = createTemplateHead;
59925     function createTemplateMiddle(text, rawText) {
59926         var node = createTemplateLiteralLikeNode(16, text, rawText);
59927         node.text = text;
59928         return node;
59929     }
59930     ts.createTemplateMiddle = createTemplateMiddle;
59931     function createTemplateTail(text, rawText) {
59932         var node = createTemplateLiteralLikeNode(17, text, rawText);
59933         node.text = text;
59934         return node;
59935     }
59936     ts.createTemplateTail = createTemplateTail;
59937     function createNoSubstitutionTemplateLiteral(text, rawText) {
59938         var node = createTemplateLiteralLikeNode(14, text, rawText);
59939         return node;
59940     }
59941     ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral;
59942     function createYield(asteriskTokenOrExpression, expression) {
59943         var asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 41 ? asteriskTokenOrExpression : undefined;
59944         expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 41 ? asteriskTokenOrExpression : expression;
59945         var node = createSynthesizedNode(212);
59946         node.asteriskToken = asteriskToken;
59947         node.expression = expression && ts.parenthesizeExpressionForList(expression);
59948         return node;
59949     }
59950     ts.createYield = createYield;
59951     function updateYield(node, asteriskToken, expression) {
59952         return node.expression !== expression
59953             || node.asteriskToken !== asteriskToken
59954             ? updateNode(createYield(asteriskToken, expression), node)
59955             : node;
59956     }
59957     ts.updateYield = updateYield;
59958     function createSpread(expression) {
59959         var node = createSynthesizedNode(213);
59960         node.expression = ts.parenthesizeExpressionForList(expression);
59961         return node;
59962     }
59963     ts.createSpread = createSpread;
59964     function updateSpread(node, expression) {
59965         return node.expression !== expression
59966             ? updateNode(createSpread(expression), node)
59967             : node;
59968     }
59969     ts.updateSpread = updateSpread;
59970     function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) {
59971         var node = createSynthesizedNode(214);
59972         node.decorators = undefined;
59973         node.modifiers = asNodeArray(modifiers);
59974         node.name = asName(name);
59975         node.typeParameters = asNodeArray(typeParameters);
59976         node.heritageClauses = asNodeArray(heritageClauses);
59977         node.members = createNodeArray(members);
59978         return node;
59979     }
59980     ts.createClassExpression = createClassExpression;
59981     function updateClassExpression(node, modifiers, name, typeParameters, heritageClauses, members) {
59982         return node.modifiers !== modifiers
59983             || node.name !== name
59984             || node.typeParameters !== typeParameters
59985             || node.heritageClauses !== heritageClauses
59986             || node.members !== members
59987             ? updateNode(createClassExpression(modifiers, name, typeParameters, heritageClauses, members), node)
59988             : node;
59989     }
59990     ts.updateClassExpression = updateClassExpression;
59991     function createOmittedExpression() {
59992         return createSynthesizedNode(215);
59993     }
59994     ts.createOmittedExpression = createOmittedExpression;
59995     function createExpressionWithTypeArguments(typeArguments, expression) {
59996         var node = createSynthesizedNode(216);
59997         node.expression = ts.parenthesizeForAccess(expression);
59998         node.typeArguments = asNodeArray(typeArguments);
59999         return node;
60000     }
60001     ts.createExpressionWithTypeArguments = createExpressionWithTypeArguments;
60002     function updateExpressionWithTypeArguments(node, typeArguments, expression) {
60003         return node.typeArguments !== typeArguments
60004             || node.expression !== expression
60005             ? updateNode(createExpressionWithTypeArguments(typeArguments, expression), node)
60006             : node;
60007     }
60008     ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments;
60009     function createAsExpression(expression, type) {
60010         var node = createSynthesizedNode(217);
60011         node.expression = expression;
60012         node.type = type;
60013         return node;
60014     }
60015     ts.createAsExpression = createAsExpression;
60016     function updateAsExpression(node, expression, type) {
60017         return node.expression !== expression
60018             || node.type !== type
60019             ? updateNode(createAsExpression(expression, type), node)
60020             : node;
60021     }
60022     ts.updateAsExpression = updateAsExpression;
60023     function createNonNullExpression(expression) {
60024         var node = createSynthesizedNode(218);
60025         node.expression = ts.parenthesizeForAccess(expression);
60026         return node;
60027     }
60028     ts.createNonNullExpression = createNonNullExpression;
60029     function updateNonNullExpression(node, expression) {
60030         if (ts.isNonNullChain(node)) {
60031             return updateNonNullChain(node, expression);
60032         }
60033         return node.expression !== expression
60034             ? updateNode(createNonNullExpression(expression), node)
60035             : node;
60036     }
60037     ts.updateNonNullExpression = updateNonNullExpression;
60038     function createNonNullChain(expression) {
60039         var node = createSynthesizedNode(218);
60040         node.flags |= 32;
60041         node.expression = ts.parenthesizeForAccess(expression);
60042         return node;
60043     }
60044     ts.createNonNullChain = createNonNullChain;
60045     function updateNonNullChain(node, expression) {
60046         ts.Debug.assert(!!(node.flags & 32), "Cannot update a NonNullExpression using updateNonNullChain. Use updateNonNullExpression instead.");
60047         return node.expression !== expression
60048             ? updateNode(createNonNullChain(expression), node)
60049             : node;
60050     }
60051     ts.updateNonNullChain = updateNonNullChain;
60052     function createMetaProperty(keywordToken, name) {
60053         var node = createSynthesizedNode(219);
60054         node.keywordToken = keywordToken;
60055         node.name = name;
60056         return node;
60057     }
60058     ts.createMetaProperty = createMetaProperty;
60059     function updateMetaProperty(node, name) {
60060         return node.name !== name
60061             ? updateNode(createMetaProperty(node.keywordToken, name), node)
60062             : node;
60063     }
60064     ts.updateMetaProperty = updateMetaProperty;
60065     function createTemplateSpan(expression, literal) {
60066         var node = createSynthesizedNode(221);
60067         node.expression = expression;
60068         node.literal = literal;
60069         return node;
60070     }
60071     ts.createTemplateSpan = createTemplateSpan;
60072     function updateTemplateSpan(node, expression, literal) {
60073         return node.expression !== expression
60074             || node.literal !== literal
60075             ? updateNode(createTemplateSpan(expression, literal), node)
60076             : node;
60077     }
60078     ts.updateTemplateSpan = updateTemplateSpan;
60079     function createSemicolonClassElement() {
60080         return createSynthesizedNode(222);
60081     }
60082     ts.createSemicolonClassElement = createSemicolonClassElement;
60083     function createBlock(statements, multiLine) {
60084         var block = createSynthesizedNode(223);
60085         block.statements = createNodeArray(statements);
60086         if (multiLine)
60087             block.multiLine = multiLine;
60088         return block;
60089     }
60090     ts.createBlock = createBlock;
60091     function updateBlock(node, statements) {
60092         return node.statements !== statements
60093             ? updateNode(createBlock(statements, node.multiLine), node)
60094             : node;
60095     }
60096     ts.updateBlock = updateBlock;
60097     function createVariableStatement(modifiers, declarationList) {
60098         var node = createSynthesizedNode(225);
60099         node.decorators = undefined;
60100         node.modifiers = asNodeArray(modifiers);
60101         node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList;
60102         return node;
60103     }
60104     ts.createVariableStatement = createVariableStatement;
60105     function updateVariableStatement(node, modifiers, declarationList) {
60106         return node.modifiers !== modifiers
60107             || node.declarationList !== declarationList
60108             ? updateNode(createVariableStatement(modifiers, declarationList), node)
60109             : node;
60110     }
60111     ts.updateVariableStatement = updateVariableStatement;
60112     function createEmptyStatement() {
60113         return createSynthesizedNode(224);
60114     }
60115     ts.createEmptyStatement = createEmptyStatement;
60116     function createExpressionStatement(expression) {
60117         var node = createSynthesizedNode(226);
60118         node.expression = ts.parenthesizeExpressionForExpressionStatement(expression);
60119         return node;
60120     }
60121     ts.createExpressionStatement = createExpressionStatement;
60122     function updateExpressionStatement(node, expression) {
60123         return node.expression !== expression
60124             ? updateNode(createExpressionStatement(expression), node)
60125             : node;
60126     }
60127     ts.updateExpressionStatement = updateExpressionStatement;
60128     ts.createStatement = createExpressionStatement;
60129     ts.updateStatement = updateExpressionStatement;
60130     function createIf(expression, thenStatement, elseStatement) {
60131         var node = createSynthesizedNode(227);
60132         node.expression = expression;
60133         node.thenStatement = asEmbeddedStatement(thenStatement);
60134         node.elseStatement = asEmbeddedStatement(elseStatement);
60135         return node;
60136     }
60137     ts.createIf = createIf;
60138     function updateIf(node, expression, thenStatement, elseStatement) {
60139         return node.expression !== expression
60140             || node.thenStatement !== thenStatement
60141             || node.elseStatement !== elseStatement
60142             ? updateNode(createIf(expression, thenStatement, elseStatement), node)
60143             : node;
60144     }
60145     ts.updateIf = updateIf;
60146     function createDo(statement, expression) {
60147         var node = createSynthesizedNode(228);
60148         node.statement = asEmbeddedStatement(statement);
60149         node.expression = expression;
60150         return node;
60151     }
60152     ts.createDo = createDo;
60153     function updateDo(node, statement, expression) {
60154         return node.statement !== statement
60155             || node.expression !== expression
60156             ? updateNode(createDo(statement, expression), node)
60157             : node;
60158     }
60159     ts.updateDo = updateDo;
60160     function createWhile(expression, statement) {
60161         var node = createSynthesizedNode(229);
60162         node.expression = expression;
60163         node.statement = asEmbeddedStatement(statement);
60164         return node;
60165     }
60166     ts.createWhile = createWhile;
60167     function updateWhile(node, expression, statement) {
60168         return node.expression !== expression
60169             || node.statement !== statement
60170             ? updateNode(createWhile(expression, statement), node)
60171             : node;
60172     }
60173     ts.updateWhile = updateWhile;
60174     function createFor(initializer, condition, incrementor, statement) {
60175         var node = createSynthesizedNode(230);
60176         node.initializer = initializer;
60177         node.condition = condition;
60178         node.incrementor = incrementor;
60179         node.statement = asEmbeddedStatement(statement);
60180         return node;
60181     }
60182     ts.createFor = createFor;
60183     function updateFor(node, initializer, condition, incrementor, statement) {
60184         return node.initializer !== initializer
60185             || node.condition !== condition
60186             || node.incrementor !== incrementor
60187             || node.statement !== statement
60188             ? updateNode(createFor(initializer, condition, incrementor, statement), node)
60189             : node;
60190     }
60191     ts.updateFor = updateFor;
60192     function createForIn(initializer, expression, statement) {
60193         var node = createSynthesizedNode(231);
60194         node.initializer = initializer;
60195         node.expression = expression;
60196         node.statement = asEmbeddedStatement(statement);
60197         return node;
60198     }
60199     ts.createForIn = createForIn;
60200     function updateForIn(node, initializer, expression, statement) {
60201         return node.initializer !== initializer
60202             || node.expression !== expression
60203             || node.statement !== statement
60204             ? updateNode(createForIn(initializer, expression, statement), node)
60205             : node;
60206     }
60207     ts.updateForIn = updateForIn;
60208     function createForOf(awaitModifier, initializer, expression, statement) {
60209         var node = createSynthesizedNode(232);
60210         node.awaitModifier = awaitModifier;
60211         node.initializer = initializer;
60212         node.expression = ts.isCommaSequence(expression) ? createParen(expression) : expression;
60213         node.statement = asEmbeddedStatement(statement);
60214         return node;
60215     }
60216     ts.createForOf = createForOf;
60217     function updateForOf(node, awaitModifier, initializer, expression, statement) {
60218         return node.awaitModifier !== awaitModifier
60219             || node.initializer !== initializer
60220             || node.expression !== expression
60221             || node.statement !== statement
60222             ? updateNode(createForOf(awaitModifier, initializer, expression, statement), node)
60223             : node;
60224     }
60225     ts.updateForOf = updateForOf;
60226     function createContinue(label) {
60227         var node = createSynthesizedNode(233);
60228         node.label = asName(label);
60229         return node;
60230     }
60231     ts.createContinue = createContinue;
60232     function updateContinue(node, label) {
60233         return node.label !== label
60234             ? updateNode(createContinue(label), node)
60235             : node;
60236     }
60237     ts.updateContinue = updateContinue;
60238     function createBreak(label) {
60239         var node = createSynthesizedNode(234);
60240         node.label = asName(label);
60241         return node;
60242     }
60243     ts.createBreak = createBreak;
60244     function updateBreak(node, label) {
60245         return node.label !== label
60246             ? updateNode(createBreak(label), node)
60247             : node;
60248     }
60249     ts.updateBreak = updateBreak;
60250     function createReturn(expression) {
60251         var node = createSynthesizedNode(235);
60252         node.expression = expression;
60253         return node;
60254     }
60255     ts.createReturn = createReturn;
60256     function updateReturn(node, expression) {
60257         return node.expression !== expression
60258             ? updateNode(createReturn(expression), node)
60259             : node;
60260     }
60261     ts.updateReturn = updateReturn;
60262     function createWith(expression, statement) {
60263         var node = createSynthesizedNode(236);
60264         node.expression = expression;
60265         node.statement = asEmbeddedStatement(statement);
60266         return node;
60267     }
60268     ts.createWith = createWith;
60269     function updateWith(node, expression, statement) {
60270         return node.expression !== expression
60271             || node.statement !== statement
60272             ? updateNode(createWith(expression, statement), node)
60273             : node;
60274     }
60275     ts.updateWith = updateWith;
60276     function createSwitch(expression, caseBlock) {
60277         var node = createSynthesizedNode(237);
60278         node.expression = ts.parenthesizeExpressionForList(expression);
60279         node.caseBlock = caseBlock;
60280         return node;
60281     }
60282     ts.createSwitch = createSwitch;
60283     function updateSwitch(node, expression, caseBlock) {
60284         return node.expression !== expression
60285             || node.caseBlock !== caseBlock
60286             ? updateNode(createSwitch(expression, caseBlock), node)
60287             : node;
60288     }
60289     ts.updateSwitch = updateSwitch;
60290     function createLabel(label, statement) {
60291         var node = createSynthesizedNode(238);
60292         node.label = asName(label);
60293         node.statement = asEmbeddedStatement(statement);
60294         return node;
60295     }
60296     ts.createLabel = createLabel;
60297     function updateLabel(node, label, statement) {
60298         return node.label !== label
60299             || node.statement !== statement
60300             ? updateNode(createLabel(label, statement), node)
60301             : node;
60302     }
60303     ts.updateLabel = updateLabel;
60304     function createThrow(expression) {
60305         var node = createSynthesizedNode(239);
60306         node.expression = expression;
60307         return node;
60308     }
60309     ts.createThrow = createThrow;
60310     function updateThrow(node, expression) {
60311         return node.expression !== expression
60312             ? updateNode(createThrow(expression), node)
60313             : node;
60314     }
60315     ts.updateThrow = updateThrow;
60316     function createTry(tryBlock, catchClause, finallyBlock) {
60317         var node = createSynthesizedNode(240);
60318         node.tryBlock = tryBlock;
60319         node.catchClause = catchClause;
60320         node.finallyBlock = finallyBlock;
60321         return node;
60322     }
60323     ts.createTry = createTry;
60324     function updateTry(node, tryBlock, catchClause, finallyBlock) {
60325         return node.tryBlock !== tryBlock
60326             || node.catchClause !== catchClause
60327             || node.finallyBlock !== finallyBlock
60328             ? updateNode(createTry(tryBlock, catchClause, finallyBlock), node)
60329             : node;
60330     }
60331     ts.updateTry = updateTry;
60332     function createDebuggerStatement() {
60333         return createSynthesizedNode(241);
60334     }
60335     ts.createDebuggerStatement = createDebuggerStatement;
60336     function createVariableDeclaration(name, type, initializer) {
60337         var node = createSynthesizedNode(242);
60338         node.name = asName(name);
60339         node.type = type;
60340         node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined;
60341         return node;
60342     }
60343     ts.createVariableDeclaration = createVariableDeclaration;
60344     function updateVariableDeclaration(node, name, type, initializer) {
60345         return node.name !== name
60346             || node.type !== type
60347             || node.initializer !== initializer
60348             ? updateNode(createVariableDeclaration(name, type, initializer), node)
60349             : node;
60350     }
60351     ts.updateVariableDeclaration = updateVariableDeclaration;
60352     function createTypeScriptVariableDeclaration(name, exclaimationToken, type, initializer) {
60353         var node = createSynthesizedNode(242);
60354         node.name = asName(name);
60355         node.type = type;
60356         node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined;
60357         node.exclamationToken = exclaimationToken;
60358         return node;
60359     }
60360     ts.createTypeScriptVariableDeclaration = createTypeScriptVariableDeclaration;
60361     function updateTypeScriptVariableDeclaration(node, name, exclaimationToken, type, initializer) {
60362         return node.name !== name
60363             || node.type !== type
60364             || node.initializer !== initializer
60365             || node.exclamationToken !== exclaimationToken
60366             ? updateNode(createTypeScriptVariableDeclaration(name, exclaimationToken, type, initializer), node)
60367             : node;
60368     }
60369     ts.updateTypeScriptVariableDeclaration = updateTypeScriptVariableDeclaration;
60370     function createVariableDeclarationList(declarations, flags) {
60371         if (flags === void 0) { flags = 0; }
60372         var node = createSynthesizedNode(243);
60373         node.flags |= flags & 3;
60374         node.declarations = createNodeArray(declarations);
60375         return node;
60376     }
60377     ts.createVariableDeclarationList = createVariableDeclarationList;
60378     function updateVariableDeclarationList(node, declarations) {
60379         return node.declarations !== declarations
60380             ? updateNode(createVariableDeclarationList(declarations, node.flags), node)
60381             : node;
60382     }
60383     ts.updateVariableDeclarationList = updateVariableDeclarationList;
60384     function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) {
60385         var node = createSynthesizedNode(244);
60386         node.decorators = asNodeArray(decorators);
60387         node.modifiers = asNodeArray(modifiers);
60388         node.asteriskToken = asteriskToken;
60389         node.name = asName(name);
60390         node.typeParameters = asNodeArray(typeParameters);
60391         node.parameters = createNodeArray(parameters);
60392         node.type = type;
60393         node.body = body;
60394         return node;
60395     }
60396     ts.createFunctionDeclaration = createFunctionDeclaration;
60397     function updateFunctionDeclaration(node, decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) {
60398         return node.decorators !== decorators
60399             || node.modifiers !== modifiers
60400             || node.asteriskToken !== asteriskToken
60401             || node.name !== name
60402             || node.typeParameters !== typeParameters
60403             || node.parameters !== parameters
60404             || node.type !== type
60405             || node.body !== body
60406             ? updateNode(createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body), node)
60407             : node;
60408     }
60409     ts.updateFunctionDeclaration = updateFunctionDeclaration;
60410     function updateFunctionLikeBody(declaration, body) {
60411         switch (declaration.kind) {
60412             case 244:
60413                 return createFunctionDeclaration(declaration.decorators, declaration.modifiers, declaration.asteriskToken, declaration.name, declaration.typeParameters, declaration.parameters, declaration.type, body);
60414             case 161:
60415                 return createMethod(declaration.decorators, declaration.modifiers, declaration.asteriskToken, declaration.name, declaration.questionToken, declaration.typeParameters, declaration.parameters, declaration.type, body);
60416             case 163:
60417                 return createGetAccessor(declaration.decorators, declaration.modifiers, declaration.name, declaration.parameters, declaration.type, body);
60418             case 164:
60419                 return createSetAccessor(declaration.decorators, declaration.modifiers, declaration.name, declaration.parameters, body);
60420             case 162:
60421                 return createConstructor(declaration.decorators, declaration.modifiers, declaration.parameters, body);
60422             case 201:
60423                 return createFunctionExpression(declaration.modifiers, declaration.asteriskToken, declaration.name, declaration.typeParameters, declaration.parameters, declaration.type, body);
60424             case 202:
60425                 return createArrowFunction(declaration.modifiers, declaration.typeParameters, declaration.parameters, declaration.type, declaration.equalsGreaterThanToken, body);
60426         }
60427     }
60428     ts.updateFunctionLikeBody = updateFunctionLikeBody;
60429     function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) {
60430         var node = createSynthesizedNode(245);
60431         node.decorators = asNodeArray(decorators);
60432         node.modifiers = asNodeArray(modifiers);
60433         node.name = asName(name);
60434         node.typeParameters = asNodeArray(typeParameters);
60435         node.heritageClauses = asNodeArray(heritageClauses);
60436         node.members = createNodeArray(members);
60437         return node;
60438     }
60439     ts.createClassDeclaration = createClassDeclaration;
60440     function updateClassDeclaration(node, decorators, modifiers, name, typeParameters, heritageClauses, members) {
60441         return node.decorators !== decorators
60442             || node.modifiers !== modifiers
60443             || node.name !== name
60444             || node.typeParameters !== typeParameters
60445             || node.heritageClauses !== heritageClauses
60446             || node.members !== members
60447             ? updateNode(createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members), node)
60448             : node;
60449     }
60450     ts.updateClassDeclaration = updateClassDeclaration;
60451     function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) {
60452         var node = createSynthesizedNode(246);
60453         node.decorators = asNodeArray(decorators);
60454         node.modifiers = asNodeArray(modifiers);
60455         node.name = asName(name);
60456         node.typeParameters = asNodeArray(typeParameters);
60457         node.heritageClauses = asNodeArray(heritageClauses);
60458         node.members = createNodeArray(members);
60459         return node;
60460     }
60461     ts.createInterfaceDeclaration = createInterfaceDeclaration;
60462     function updateInterfaceDeclaration(node, decorators, modifiers, name, typeParameters, heritageClauses, members) {
60463         return node.decorators !== decorators
60464             || node.modifiers !== modifiers
60465             || node.name !== name
60466             || node.typeParameters !== typeParameters
60467             || node.heritageClauses !== heritageClauses
60468             || node.members !== members
60469             ? updateNode(createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members), node)
60470             : node;
60471     }
60472     ts.updateInterfaceDeclaration = updateInterfaceDeclaration;
60473     function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) {
60474         var node = createSynthesizedNode(247);
60475         node.decorators = asNodeArray(decorators);
60476         node.modifiers = asNodeArray(modifiers);
60477         node.name = asName(name);
60478         node.typeParameters = asNodeArray(typeParameters);
60479         node.type = type;
60480         return node;
60481     }
60482     ts.createTypeAliasDeclaration = createTypeAliasDeclaration;
60483     function updateTypeAliasDeclaration(node, decorators, modifiers, name, typeParameters, type) {
60484         return node.decorators !== decorators
60485             || node.modifiers !== modifiers
60486             || node.name !== name
60487             || node.typeParameters !== typeParameters
60488             || node.type !== type
60489             ? updateNode(createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type), node)
60490             : node;
60491     }
60492     ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration;
60493     function createEnumDeclaration(decorators, modifiers, name, members) {
60494         var node = createSynthesizedNode(248);
60495         node.decorators = asNodeArray(decorators);
60496         node.modifiers = asNodeArray(modifiers);
60497         node.name = asName(name);
60498         node.members = createNodeArray(members);
60499         return node;
60500     }
60501     ts.createEnumDeclaration = createEnumDeclaration;
60502     function updateEnumDeclaration(node, decorators, modifiers, name, members) {
60503         return node.decorators !== decorators
60504             || node.modifiers !== modifiers
60505             || node.name !== name
60506             || node.members !== members
60507             ? updateNode(createEnumDeclaration(decorators, modifiers, name, members), node)
60508             : node;
60509     }
60510     ts.updateEnumDeclaration = updateEnumDeclaration;
60511     function createModuleDeclaration(decorators, modifiers, name, body, flags) {
60512         if (flags === void 0) { flags = 0; }
60513         var node = createSynthesizedNode(249);
60514         node.flags |= flags & (16 | 4 | 1024);
60515         node.decorators = asNodeArray(decorators);
60516         node.modifiers = asNodeArray(modifiers);
60517         node.name = name;
60518         node.body = body;
60519         return node;
60520     }
60521     ts.createModuleDeclaration = createModuleDeclaration;
60522     function updateModuleDeclaration(node, decorators, modifiers, name, body) {
60523         return node.decorators !== decorators
60524             || node.modifiers !== modifiers
60525             || node.name !== name
60526             || node.body !== body
60527             ? updateNode(createModuleDeclaration(decorators, modifiers, name, body, node.flags), node)
60528             : node;
60529     }
60530     ts.updateModuleDeclaration = updateModuleDeclaration;
60531     function createModuleBlock(statements) {
60532         var node = createSynthesizedNode(250);
60533         node.statements = createNodeArray(statements);
60534         return node;
60535     }
60536     ts.createModuleBlock = createModuleBlock;
60537     function updateModuleBlock(node, statements) {
60538         return node.statements !== statements
60539             ? updateNode(createModuleBlock(statements), node)
60540             : node;
60541     }
60542     ts.updateModuleBlock = updateModuleBlock;
60543     function createCaseBlock(clauses) {
60544         var node = createSynthesizedNode(251);
60545         node.clauses = createNodeArray(clauses);
60546         return node;
60547     }
60548     ts.createCaseBlock = createCaseBlock;
60549     function updateCaseBlock(node, clauses) {
60550         return node.clauses !== clauses
60551             ? updateNode(createCaseBlock(clauses), node)
60552             : node;
60553     }
60554     ts.updateCaseBlock = updateCaseBlock;
60555     function createNamespaceExportDeclaration(name) {
60556         var node = createSynthesizedNode(252);
60557         node.name = asName(name);
60558         return node;
60559     }
60560     ts.createNamespaceExportDeclaration = createNamespaceExportDeclaration;
60561     function updateNamespaceExportDeclaration(node, name) {
60562         return node.name !== name
60563             ? updateNode(createNamespaceExportDeclaration(name), node)
60564             : node;
60565     }
60566     ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration;
60567     function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) {
60568         var node = createSynthesizedNode(253);
60569         node.decorators = asNodeArray(decorators);
60570         node.modifiers = asNodeArray(modifiers);
60571         node.name = asName(name);
60572         node.moduleReference = moduleReference;
60573         return node;
60574     }
60575     ts.createImportEqualsDeclaration = createImportEqualsDeclaration;
60576     function updateImportEqualsDeclaration(node, decorators, modifiers, name, moduleReference) {
60577         return node.decorators !== decorators
60578             || node.modifiers !== modifiers
60579             || node.name !== name
60580             || node.moduleReference !== moduleReference
60581             ? updateNode(createImportEqualsDeclaration(decorators, modifiers, name, moduleReference), node)
60582             : node;
60583     }
60584     ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration;
60585     function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) {
60586         var node = createSynthesizedNode(254);
60587         node.decorators = asNodeArray(decorators);
60588         node.modifiers = asNodeArray(modifiers);
60589         node.importClause = importClause;
60590         node.moduleSpecifier = moduleSpecifier;
60591         return node;
60592     }
60593     ts.createImportDeclaration = createImportDeclaration;
60594     function updateImportDeclaration(node, decorators, modifiers, importClause, moduleSpecifier) {
60595         return node.decorators !== decorators
60596             || node.modifiers !== modifiers
60597             || node.importClause !== importClause
60598             || node.moduleSpecifier !== moduleSpecifier
60599             ? updateNode(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier), node)
60600             : node;
60601     }
60602     ts.updateImportDeclaration = updateImportDeclaration;
60603     function createImportClause(name, namedBindings, isTypeOnly) {
60604         if (isTypeOnly === void 0) { isTypeOnly = false; }
60605         var node = createSynthesizedNode(255);
60606         node.name = name;
60607         node.namedBindings = namedBindings;
60608         node.isTypeOnly = isTypeOnly;
60609         return node;
60610     }
60611     ts.createImportClause = createImportClause;
60612     function updateImportClause(node, name, namedBindings, isTypeOnly) {
60613         return node.name !== name
60614             || node.namedBindings !== namedBindings
60615             || node.isTypeOnly !== isTypeOnly
60616             ? updateNode(createImportClause(name, namedBindings, isTypeOnly), node)
60617             : node;
60618     }
60619     ts.updateImportClause = updateImportClause;
60620     function createNamespaceImport(name) {
60621         var node = createSynthesizedNode(256);
60622         node.name = name;
60623         return node;
60624     }
60625     ts.createNamespaceImport = createNamespaceImport;
60626     function createNamespaceExport(name) {
60627         var node = createSynthesizedNode(262);
60628         node.name = name;
60629         return node;
60630     }
60631     ts.createNamespaceExport = createNamespaceExport;
60632     function updateNamespaceImport(node, name) {
60633         return node.name !== name
60634             ? updateNode(createNamespaceImport(name), node)
60635             : node;
60636     }
60637     ts.updateNamespaceImport = updateNamespaceImport;
60638     function updateNamespaceExport(node, name) {
60639         return node.name !== name
60640             ? updateNode(createNamespaceExport(name), node)
60641             : node;
60642     }
60643     ts.updateNamespaceExport = updateNamespaceExport;
60644     function createNamedImports(elements) {
60645         var node = createSynthesizedNode(257);
60646         node.elements = createNodeArray(elements);
60647         return node;
60648     }
60649     ts.createNamedImports = createNamedImports;
60650     function updateNamedImports(node, elements) {
60651         return node.elements !== elements
60652             ? updateNode(createNamedImports(elements), node)
60653             : node;
60654     }
60655     ts.updateNamedImports = updateNamedImports;
60656     function createImportSpecifier(propertyName, name) {
60657         var node = createSynthesizedNode(258);
60658         node.propertyName = propertyName;
60659         node.name = name;
60660         return node;
60661     }
60662     ts.createImportSpecifier = createImportSpecifier;
60663     function updateImportSpecifier(node, propertyName, name) {
60664         return node.propertyName !== propertyName
60665             || node.name !== name
60666             ? updateNode(createImportSpecifier(propertyName, name), node)
60667             : node;
60668     }
60669     ts.updateImportSpecifier = updateImportSpecifier;
60670     function createExportAssignment(decorators, modifiers, isExportEquals, expression) {
60671         var node = createSynthesizedNode(259);
60672         node.decorators = asNodeArray(decorators);
60673         node.modifiers = asNodeArray(modifiers);
60674         node.isExportEquals = isExportEquals;
60675         node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(62, expression, false, undefined) : ts.parenthesizeDefaultExpression(expression);
60676         return node;
60677     }
60678     ts.createExportAssignment = createExportAssignment;
60679     function updateExportAssignment(node, decorators, modifiers, expression) {
60680         return node.decorators !== decorators
60681             || node.modifiers !== modifiers
60682             || node.expression !== expression
60683             ? updateNode(createExportAssignment(decorators, modifiers, node.isExportEquals, expression), node)
60684             : node;
60685     }
60686     ts.updateExportAssignment = updateExportAssignment;
60687     function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, isTypeOnly) {
60688         if (isTypeOnly === void 0) { isTypeOnly = false; }
60689         var node = createSynthesizedNode(260);
60690         node.decorators = asNodeArray(decorators);
60691         node.modifiers = asNodeArray(modifiers);
60692         node.isTypeOnly = isTypeOnly;
60693         node.exportClause = exportClause;
60694         node.moduleSpecifier = moduleSpecifier;
60695         return node;
60696     }
60697     ts.createExportDeclaration = createExportDeclaration;
60698     function updateExportDeclaration(node, decorators, modifiers, exportClause, moduleSpecifier, isTypeOnly) {
60699         return node.decorators !== decorators
60700             || node.modifiers !== modifiers
60701             || node.isTypeOnly !== isTypeOnly
60702             || node.exportClause !== exportClause
60703             || node.moduleSpecifier !== moduleSpecifier
60704             ? updateNode(createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, isTypeOnly), node)
60705             : node;
60706     }
60707     ts.updateExportDeclaration = updateExportDeclaration;
60708     function createEmptyExports() {
60709         return createExportDeclaration(undefined, undefined, createNamedExports([]), undefined);
60710     }
60711     ts.createEmptyExports = createEmptyExports;
60712     function createNamedExports(elements) {
60713         var node = createSynthesizedNode(261);
60714         node.elements = createNodeArray(elements);
60715         return node;
60716     }
60717     ts.createNamedExports = createNamedExports;
60718     function updateNamedExports(node, elements) {
60719         return node.elements !== elements
60720             ? updateNode(createNamedExports(elements), node)
60721             : node;
60722     }
60723     ts.updateNamedExports = updateNamedExports;
60724     function createExportSpecifier(propertyName, name) {
60725         var node = createSynthesizedNode(263);
60726         node.propertyName = asName(propertyName);
60727         node.name = asName(name);
60728         return node;
60729     }
60730     ts.createExportSpecifier = createExportSpecifier;
60731     function updateExportSpecifier(node, propertyName, name) {
60732         return node.propertyName !== propertyName
60733             || node.name !== name
60734             ? updateNode(createExportSpecifier(propertyName, name), node)
60735             : node;
60736     }
60737     ts.updateExportSpecifier = updateExportSpecifier;
60738     function createExternalModuleReference(expression) {
60739         var node = createSynthesizedNode(265);
60740         node.expression = expression;
60741         return node;
60742     }
60743     ts.createExternalModuleReference = createExternalModuleReference;
60744     function updateExternalModuleReference(node, expression) {
60745         return node.expression !== expression
60746             ? updateNode(createExternalModuleReference(expression), node)
60747             : node;
60748     }
60749     ts.updateExternalModuleReference = updateExternalModuleReference;
60750     function createJSDocTypeExpression(type) {
60751         var node = createSynthesizedNode(294);
60752         node.type = type;
60753         return node;
60754     }
60755     ts.createJSDocTypeExpression = createJSDocTypeExpression;
60756     function createJSDocTypeTag(typeExpression, comment) {
60757         var tag = createJSDocTag(320, "type");
60758         tag.typeExpression = typeExpression;
60759         tag.comment = comment;
60760         return tag;
60761     }
60762     ts.createJSDocTypeTag = createJSDocTypeTag;
60763     function createJSDocReturnTag(typeExpression, comment) {
60764         var tag = createJSDocTag(318, "returns");
60765         tag.typeExpression = typeExpression;
60766         tag.comment = comment;
60767         return tag;
60768     }
60769     ts.createJSDocReturnTag = createJSDocReturnTag;
60770     function createJSDocThisTag(typeExpression) {
60771         var tag = createJSDocTag(319, "this");
60772         tag.typeExpression = typeExpression;
60773         return tag;
60774     }
60775     ts.createJSDocThisTag = createJSDocThisTag;
60776     function createJSDocParamTag(name, isBracketed, typeExpression, comment) {
60777         var tag = createJSDocTag(317, "param");
60778         tag.typeExpression = typeExpression;
60779         tag.name = name;
60780         tag.isBracketed = isBracketed;
60781         tag.comment = comment;
60782         return tag;
60783     }
60784     ts.createJSDocParamTag = createJSDocParamTag;
60785     function createJSDocClassTag() {
60786         return createJSDocTag(310, "class");
60787     }
60788     ts.createJSDocClassTag = createJSDocClassTag;
60789     function createJSDocComment(comment, tags) {
60790         var node = createSynthesizedNode(303);
60791         node.comment = comment;
60792         node.tags = tags;
60793         return node;
60794     }
60795     ts.createJSDocComment = createJSDocComment;
60796     function createJSDocTag(kind, tagName) {
60797         var node = createSynthesizedNode(kind);
60798         node.tagName = createIdentifier(tagName);
60799         return node;
60800     }
60801     function createJsxElement(openingElement, children, closingElement) {
60802         var node = createSynthesizedNode(266);
60803         node.openingElement = openingElement;
60804         node.children = createNodeArray(children);
60805         node.closingElement = closingElement;
60806         return node;
60807     }
60808     ts.createJsxElement = createJsxElement;
60809     function updateJsxElement(node, openingElement, children, closingElement) {
60810         return node.openingElement !== openingElement
60811             || node.children !== children
60812             || node.closingElement !== closingElement
60813             ? updateNode(createJsxElement(openingElement, children, closingElement), node)
60814             : node;
60815     }
60816     ts.updateJsxElement = updateJsxElement;
60817     function createJsxSelfClosingElement(tagName, typeArguments, attributes) {
60818         var node = createSynthesizedNode(267);
60819         node.tagName = tagName;
60820         node.typeArguments = asNodeArray(typeArguments);
60821         node.attributes = attributes;
60822         return node;
60823     }
60824     ts.createJsxSelfClosingElement = createJsxSelfClosingElement;
60825     function updateJsxSelfClosingElement(node, tagName, typeArguments, attributes) {
60826         return node.tagName !== tagName
60827             || node.typeArguments !== typeArguments
60828             || node.attributes !== attributes
60829             ? updateNode(createJsxSelfClosingElement(tagName, typeArguments, attributes), node)
60830             : node;
60831     }
60832     ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement;
60833     function createJsxOpeningElement(tagName, typeArguments, attributes) {
60834         var node = createSynthesizedNode(268);
60835         node.tagName = tagName;
60836         node.typeArguments = asNodeArray(typeArguments);
60837         node.attributes = attributes;
60838         return node;
60839     }
60840     ts.createJsxOpeningElement = createJsxOpeningElement;
60841     function updateJsxOpeningElement(node, tagName, typeArguments, attributes) {
60842         return node.tagName !== tagName
60843             || node.typeArguments !== typeArguments
60844             || node.attributes !== attributes
60845             ? updateNode(createJsxOpeningElement(tagName, typeArguments, attributes), node)
60846             : node;
60847     }
60848     ts.updateJsxOpeningElement = updateJsxOpeningElement;
60849     function createJsxClosingElement(tagName) {
60850         var node = createSynthesizedNode(269);
60851         node.tagName = tagName;
60852         return node;
60853     }
60854     ts.createJsxClosingElement = createJsxClosingElement;
60855     function updateJsxClosingElement(node, tagName) {
60856         return node.tagName !== tagName
60857             ? updateNode(createJsxClosingElement(tagName), node)
60858             : node;
60859     }
60860     ts.updateJsxClosingElement = updateJsxClosingElement;
60861     function createJsxFragment(openingFragment, children, closingFragment) {
60862         var node = createSynthesizedNode(270);
60863         node.openingFragment = openingFragment;
60864         node.children = createNodeArray(children);
60865         node.closingFragment = closingFragment;
60866         return node;
60867     }
60868     ts.createJsxFragment = createJsxFragment;
60869     function createJsxText(text, containsOnlyTriviaWhiteSpaces) {
60870         var node = createSynthesizedNode(11);
60871         node.text = text;
60872         node.containsOnlyTriviaWhiteSpaces = !!containsOnlyTriviaWhiteSpaces;
60873         return node;
60874     }
60875     ts.createJsxText = createJsxText;
60876     function updateJsxText(node, text, containsOnlyTriviaWhiteSpaces) {
60877         return node.text !== text
60878             || node.containsOnlyTriviaWhiteSpaces !== containsOnlyTriviaWhiteSpaces
60879             ? updateNode(createJsxText(text, containsOnlyTriviaWhiteSpaces), node)
60880             : node;
60881     }
60882     ts.updateJsxText = updateJsxText;
60883     function createJsxOpeningFragment() {
60884         return createSynthesizedNode(271);
60885     }
60886     ts.createJsxOpeningFragment = createJsxOpeningFragment;
60887     function createJsxJsxClosingFragment() {
60888         return createSynthesizedNode(272);
60889     }
60890     ts.createJsxJsxClosingFragment = createJsxJsxClosingFragment;
60891     function updateJsxFragment(node, openingFragment, children, closingFragment) {
60892         return node.openingFragment !== openingFragment
60893             || node.children !== children
60894             || node.closingFragment !== closingFragment
60895             ? updateNode(createJsxFragment(openingFragment, children, closingFragment), node)
60896             : node;
60897     }
60898     ts.updateJsxFragment = updateJsxFragment;
60899     function createJsxAttribute(name, initializer) {
60900         var node = createSynthesizedNode(273);
60901         node.name = name;
60902         node.initializer = initializer;
60903         return node;
60904     }
60905     ts.createJsxAttribute = createJsxAttribute;
60906     function updateJsxAttribute(node, name, initializer) {
60907         return node.name !== name
60908             || node.initializer !== initializer
60909             ? updateNode(createJsxAttribute(name, initializer), node)
60910             : node;
60911     }
60912     ts.updateJsxAttribute = updateJsxAttribute;
60913     function createJsxAttributes(properties) {
60914         var node = createSynthesizedNode(274);
60915         node.properties = createNodeArray(properties);
60916         return node;
60917     }
60918     ts.createJsxAttributes = createJsxAttributes;
60919     function updateJsxAttributes(node, properties) {
60920         return node.properties !== properties
60921             ? updateNode(createJsxAttributes(properties), node)
60922             : node;
60923     }
60924     ts.updateJsxAttributes = updateJsxAttributes;
60925     function createJsxSpreadAttribute(expression) {
60926         var node = createSynthesizedNode(275);
60927         node.expression = expression;
60928         return node;
60929     }
60930     ts.createJsxSpreadAttribute = createJsxSpreadAttribute;
60931     function updateJsxSpreadAttribute(node, expression) {
60932         return node.expression !== expression
60933             ? updateNode(createJsxSpreadAttribute(expression), node)
60934             : node;
60935     }
60936     ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute;
60937     function createJsxExpression(dotDotDotToken, expression) {
60938         var node = createSynthesizedNode(276);
60939         node.dotDotDotToken = dotDotDotToken;
60940         node.expression = expression;
60941         return node;
60942     }
60943     ts.createJsxExpression = createJsxExpression;
60944     function updateJsxExpression(node, expression) {
60945         return node.expression !== expression
60946             ? updateNode(createJsxExpression(node.dotDotDotToken, expression), node)
60947             : node;
60948     }
60949     ts.updateJsxExpression = updateJsxExpression;
60950     function createCaseClause(expression, statements) {
60951         var node = createSynthesizedNode(277);
60952         node.expression = ts.parenthesizeExpressionForList(expression);
60953         node.statements = createNodeArray(statements);
60954         return node;
60955     }
60956     ts.createCaseClause = createCaseClause;
60957     function updateCaseClause(node, expression, statements) {
60958         return node.expression !== expression
60959             || node.statements !== statements
60960             ? updateNode(createCaseClause(expression, statements), node)
60961             : node;
60962     }
60963     ts.updateCaseClause = updateCaseClause;
60964     function createDefaultClause(statements) {
60965         var node = createSynthesizedNode(278);
60966         node.statements = createNodeArray(statements);
60967         return node;
60968     }
60969     ts.createDefaultClause = createDefaultClause;
60970     function updateDefaultClause(node, statements) {
60971         return node.statements !== statements
60972             ? updateNode(createDefaultClause(statements), node)
60973             : node;
60974     }
60975     ts.updateDefaultClause = updateDefaultClause;
60976     function createHeritageClause(token, types) {
60977         var node = createSynthesizedNode(279);
60978         node.token = token;
60979         node.types = createNodeArray(types);
60980         return node;
60981     }
60982     ts.createHeritageClause = createHeritageClause;
60983     function updateHeritageClause(node, types) {
60984         return node.types !== types
60985             ? updateNode(createHeritageClause(node.token, types), node)
60986             : node;
60987     }
60988     ts.updateHeritageClause = updateHeritageClause;
60989     function createCatchClause(variableDeclaration, block) {
60990         var node = createSynthesizedNode(280);
60991         node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration;
60992         node.block = block;
60993         return node;
60994     }
60995     ts.createCatchClause = createCatchClause;
60996     function updateCatchClause(node, variableDeclaration, block) {
60997         return node.variableDeclaration !== variableDeclaration
60998             || node.block !== block
60999             ? updateNode(createCatchClause(variableDeclaration, block), node)
61000             : node;
61001     }
61002     ts.updateCatchClause = updateCatchClause;
61003     function createPropertyAssignment(name, initializer) {
61004         var node = createSynthesizedNode(281);
61005         node.name = asName(name);
61006         node.questionToken = undefined;
61007         node.initializer = ts.parenthesizeExpressionForList(initializer);
61008         return node;
61009     }
61010     ts.createPropertyAssignment = createPropertyAssignment;
61011     function updatePropertyAssignment(node, name, initializer) {
61012         return node.name !== name
61013             || node.initializer !== initializer
61014             ? updateNode(createPropertyAssignment(name, initializer), node)
61015             : node;
61016     }
61017     ts.updatePropertyAssignment = updatePropertyAssignment;
61018     function createShorthandPropertyAssignment(name, objectAssignmentInitializer) {
61019         var node = createSynthesizedNode(282);
61020         node.name = asName(name);
61021         node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined;
61022         return node;
61023     }
61024     ts.createShorthandPropertyAssignment = createShorthandPropertyAssignment;
61025     function updateShorthandPropertyAssignment(node, name, objectAssignmentInitializer) {
61026         return node.name !== name
61027             || node.objectAssignmentInitializer !== objectAssignmentInitializer
61028             ? updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer), node)
61029             : node;
61030     }
61031     ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment;
61032     function createSpreadAssignment(expression) {
61033         var node = createSynthesizedNode(283);
61034         node.expression = ts.parenthesizeExpressionForList(expression);
61035         return node;
61036     }
61037     ts.createSpreadAssignment = createSpreadAssignment;
61038     function updateSpreadAssignment(node, expression) {
61039         return node.expression !== expression
61040             ? updateNode(createSpreadAssignment(expression), node)
61041             : node;
61042     }
61043     ts.updateSpreadAssignment = updateSpreadAssignment;
61044     function createEnumMember(name, initializer) {
61045         var node = createSynthesizedNode(284);
61046         node.name = asName(name);
61047         node.initializer = initializer && ts.parenthesizeExpressionForList(initializer);
61048         return node;
61049     }
61050     ts.createEnumMember = createEnumMember;
61051     function updateEnumMember(node, name, initializer) {
61052         return node.name !== name
61053             || node.initializer !== initializer
61054             ? updateNode(createEnumMember(name, initializer), node)
61055             : node;
61056     }
61057     ts.updateEnumMember = updateEnumMember;
61058     function updateSourceFileNode(node, statements, isDeclarationFile, referencedFiles, typeReferences, hasNoDefaultLib, libReferences) {
61059         if (node.statements !== statements ||
61060             (isDeclarationFile !== undefined && node.isDeclarationFile !== isDeclarationFile) ||
61061             (referencedFiles !== undefined && node.referencedFiles !== referencedFiles) ||
61062             (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) ||
61063             (libReferences !== undefined && node.libReferenceDirectives !== libReferences) ||
61064             (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) {
61065             var updated = createSynthesizedNode(290);
61066             updated.flags |= node.flags;
61067             updated.statements = createNodeArray(statements);
61068             updated.endOfFileToken = node.endOfFileToken;
61069             updated.fileName = node.fileName;
61070             updated.path = node.path;
61071             updated.text = node.text;
61072             updated.isDeclarationFile = isDeclarationFile === undefined ? node.isDeclarationFile : isDeclarationFile;
61073             updated.referencedFiles = referencedFiles === undefined ? node.referencedFiles : referencedFiles;
61074             updated.typeReferenceDirectives = typeReferences === undefined ? node.typeReferenceDirectives : typeReferences;
61075             updated.hasNoDefaultLib = hasNoDefaultLib === undefined ? node.hasNoDefaultLib : hasNoDefaultLib;
61076             updated.libReferenceDirectives = libReferences === undefined ? node.libReferenceDirectives : libReferences;
61077             if (node.amdDependencies !== undefined)
61078                 updated.amdDependencies = node.amdDependencies;
61079             if (node.moduleName !== undefined)
61080                 updated.moduleName = node.moduleName;
61081             if (node.languageVariant !== undefined)
61082                 updated.languageVariant = node.languageVariant;
61083             if (node.renamedDependencies !== undefined)
61084                 updated.renamedDependencies = node.renamedDependencies;
61085             if (node.languageVersion !== undefined)
61086                 updated.languageVersion = node.languageVersion;
61087             if (node.scriptKind !== undefined)
61088                 updated.scriptKind = node.scriptKind;
61089             if (node.externalModuleIndicator !== undefined)
61090                 updated.externalModuleIndicator = node.externalModuleIndicator;
61091             if (node.commonJsModuleIndicator !== undefined)
61092                 updated.commonJsModuleIndicator = node.commonJsModuleIndicator;
61093             if (node.identifiers !== undefined)
61094                 updated.identifiers = node.identifiers;
61095             if (node.nodeCount !== undefined)
61096                 updated.nodeCount = node.nodeCount;
61097             if (node.identifierCount !== undefined)
61098                 updated.identifierCount = node.identifierCount;
61099             if (node.symbolCount !== undefined)
61100                 updated.symbolCount = node.symbolCount;
61101             if (node.parseDiagnostics !== undefined)
61102                 updated.parseDiagnostics = node.parseDiagnostics;
61103             if (node.bindDiagnostics !== undefined)
61104                 updated.bindDiagnostics = node.bindDiagnostics;
61105             if (node.bindSuggestionDiagnostics !== undefined)
61106                 updated.bindSuggestionDiagnostics = node.bindSuggestionDiagnostics;
61107             if (node.lineMap !== undefined)
61108                 updated.lineMap = node.lineMap;
61109             if (node.classifiableNames !== undefined)
61110                 updated.classifiableNames = node.classifiableNames;
61111             if (node.resolvedModules !== undefined)
61112                 updated.resolvedModules = node.resolvedModules;
61113             if (node.resolvedTypeReferenceDirectiveNames !== undefined)
61114                 updated.resolvedTypeReferenceDirectiveNames = node.resolvedTypeReferenceDirectiveNames;
61115             if (node.imports !== undefined)
61116                 updated.imports = node.imports;
61117             if (node.moduleAugmentations !== undefined)
61118                 updated.moduleAugmentations = node.moduleAugmentations;
61119             if (node.pragmas !== undefined)
61120                 updated.pragmas = node.pragmas;
61121             if (node.localJsxFactory !== undefined)
61122                 updated.localJsxFactory = node.localJsxFactory;
61123             if (node.localJsxNamespace !== undefined)
61124                 updated.localJsxNamespace = node.localJsxNamespace;
61125             return updateNode(updated, node);
61126         }
61127         return node;
61128     }
61129     ts.updateSourceFileNode = updateSourceFileNode;
61130     function getMutableClone(node) {
61131         var clone = getSynthesizedClone(node);
61132         clone.pos = node.pos;
61133         clone.end = node.end;
61134         clone.parent = node.parent;
61135         return clone;
61136     }
61137     ts.getMutableClone = getMutableClone;
61138     function createNotEmittedStatement(original) {
61139         var node = createSynthesizedNode(325);
61140         node.original = original;
61141         setTextRange(node, original);
61142         return node;
61143     }
61144     ts.createNotEmittedStatement = createNotEmittedStatement;
61145     function createEndOfDeclarationMarker(original) {
61146         var node = createSynthesizedNode(329);
61147         node.emitNode = {};
61148         node.original = original;
61149         return node;
61150     }
61151     ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker;
61152     function createMergeDeclarationMarker(original) {
61153         var node = createSynthesizedNode(328);
61154         node.emitNode = {};
61155         node.original = original;
61156         return node;
61157     }
61158     ts.createMergeDeclarationMarker = createMergeDeclarationMarker;
61159     function createPartiallyEmittedExpression(expression, original) {
61160         var node = createSynthesizedNode(326);
61161         node.expression = expression;
61162         node.original = original;
61163         setTextRange(node, original);
61164         return node;
61165     }
61166     ts.createPartiallyEmittedExpression = createPartiallyEmittedExpression;
61167     function updatePartiallyEmittedExpression(node, expression) {
61168         if (node.expression !== expression) {
61169             return updateNode(createPartiallyEmittedExpression(expression, node.original), node);
61170         }
61171         return node;
61172     }
61173     ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression;
61174     function flattenCommaElements(node) {
61175         if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) {
61176             if (node.kind === 327) {
61177                 return node.elements;
61178             }
61179             if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27) {
61180                 return [node.left, node.right];
61181             }
61182         }
61183         return node;
61184     }
61185     function createCommaList(elements) {
61186         var node = createSynthesizedNode(327);
61187         node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements));
61188         return node;
61189     }
61190     ts.createCommaList = createCommaList;
61191     function updateCommaList(node, elements) {
61192         return node.elements !== elements
61193             ? updateNode(createCommaList(elements), node)
61194             : node;
61195     }
61196     ts.updateCommaList = updateCommaList;
61197     function createSyntheticReferenceExpression(expression, thisArg) {
61198         var node = createSynthesizedNode(330);
61199         node.expression = expression;
61200         node.thisArg = thisArg;
61201         return node;
61202     }
61203     ts.createSyntheticReferenceExpression = createSyntheticReferenceExpression;
61204     function updateSyntheticReferenceExpression(node, expression, thisArg) {
61205         return node.expression !== expression
61206             || node.thisArg !== thisArg
61207             ? updateNode(createSyntheticReferenceExpression(expression, thisArg), node)
61208             : node;
61209     }
61210     ts.updateSyntheticReferenceExpression = updateSyntheticReferenceExpression;
61211     function createBundle(sourceFiles, prepends) {
61212         if (prepends === void 0) { prepends = ts.emptyArray; }
61213         var node = ts.createNode(291);
61214         node.prepends = prepends;
61215         node.sourceFiles = sourceFiles;
61216         return node;
61217     }
61218     ts.createBundle = createBundle;
61219     var allUnscopedEmitHelpers;
61220     function getAllUnscopedEmitHelpers() {
61221         return allUnscopedEmitHelpers || (allUnscopedEmitHelpers = ts.arrayToMap([
61222             ts.valuesHelper,
61223             ts.readHelper,
61224             ts.spreadHelper,
61225             ts.spreadArraysHelper,
61226             ts.restHelper,
61227             ts.decorateHelper,
61228             ts.metadataHelper,
61229             ts.paramHelper,
61230             ts.awaiterHelper,
61231             ts.assignHelper,
61232             ts.awaitHelper,
61233             ts.asyncGeneratorHelper,
61234             ts.asyncDelegator,
61235             ts.asyncValues,
61236             ts.extendsHelper,
61237             ts.templateObjectHelper,
61238             ts.generatorHelper,
61239             ts.importStarHelper,
61240             ts.importDefaultHelper,
61241             ts.classPrivateFieldGetHelper,
61242             ts.classPrivateFieldSetHelper,
61243             ts.createBindingHelper,
61244             ts.setModuleDefaultHelper
61245         ], function (helper) { return helper.name; }));
61246     }
61247     function createUnparsedSource() {
61248         var node = ts.createNode(292);
61249         node.prologues = ts.emptyArray;
61250         node.referencedFiles = ts.emptyArray;
61251         node.libReferenceDirectives = ts.emptyArray;
61252         node.getLineAndCharacterOfPosition = function (pos) { return ts.getLineAndCharacterOfPosition(node, pos); };
61253         return node;
61254     }
61255     function createUnparsedSourceFile(textOrInputFiles, mapPathOrType, mapTextOrStripInternal) {
61256         var node = createUnparsedSource();
61257         var stripInternal;
61258         var bundleFileInfo;
61259         if (!ts.isString(textOrInputFiles)) {
61260             ts.Debug.assert(mapPathOrType === "js" || mapPathOrType === "dts");
61261             node.fileName = (mapPathOrType === "js" ? textOrInputFiles.javascriptPath : textOrInputFiles.declarationPath) || "";
61262             node.sourceMapPath = mapPathOrType === "js" ? textOrInputFiles.javascriptMapPath : textOrInputFiles.declarationMapPath;
61263             Object.defineProperties(node, {
61264                 text: { get: function () { return mapPathOrType === "js" ? textOrInputFiles.javascriptText : textOrInputFiles.declarationText; } },
61265                 sourceMapText: { get: function () { return mapPathOrType === "js" ? textOrInputFiles.javascriptMapText : textOrInputFiles.declarationMapText; } },
61266             });
61267             if (textOrInputFiles.buildInfo && textOrInputFiles.buildInfo.bundle) {
61268                 node.oldFileOfCurrentEmit = textOrInputFiles.oldFileOfCurrentEmit;
61269                 ts.Debug.assert(mapTextOrStripInternal === undefined || typeof mapTextOrStripInternal === "boolean");
61270                 stripInternal = mapTextOrStripInternal;
61271                 bundleFileInfo = mapPathOrType === "js" ? textOrInputFiles.buildInfo.bundle.js : textOrInputFiles.buildInfo.bundle.dts;
61272                 if (node.oldFileOfCurrentEmit) {
61273                     parseOldFileOfCurrentEmit(node, ts.Debug.checkDefined(bundleFileInfo));
61274                     return node;
61275                 }
61276             }
61277         }
61278         else {
61279             node.fileName = "";
61280             node.text = textOrInputFiles;
61281             node.sourceMapPath = mapPathOrType;
61282             node.sourceMapText = mapTextOrStripInternal;
61283         }
61284         ts.Debug.assert(!node.oldFileOfCurrentEmit);
61285         parseUnparsedSourceFile(node, bundleFileInfo, stripInternal);
61286         return node;
61287     }
61288     ts.createUnparsedSourceFile = createUnparsedSourceFile;
61289     function parseUnparsedSourceFile(node, bundleFileInfo, stripInternal) {
61290         var prologues;
61291         var helpers;
61292         var referencedFiles;
61293         var typeReferenceDirectives;
61294         var libReferenceDirectives;
61295         var texts;
61296         for (var _i = 0, _a = bundleFileInfo ? bundleFileInfo.sections : ts.emptyArray; _i < _a.length; _i++) {
61297             var section = _a[_i];
61298             switch (section.kind) {
61299                 case "prologue":
61300                     (prologues || (prologues = [])).push(createUnparsedNode(section, node));
61301                     break;
61302                 case "emitHelpers":
61303                     (helpers || (helpers = [])).push(getAllUnscopedEmitHelpers().get(section.data));
61304                     break;
61305                 case "no-default-lib":
61306                     node.hasNoDefaultLib = true;
61307                     break;
61308                 case "reference":
61309                     (referencedFiles || (referencedFiles = [])).push({ pos: -1, end: -1, fileName: section.data });
61310                     break;
61311                 case "type":
61312                     (typeReferenceDirectives || (typeReferenceDirectives = [])).push(section.data);
61313                     break;
61314                 case "lib":
61315                     (libReferenceDirectives || (libReferenceDirectives = [])).push({ pos: -1, end: -1, fileName: section.data });
61316                     break;
61317                 case "prepend":
61318                     var prependNode = createUnparsedNode(section, node);
61319                     var prependTexts = void 0;
61320                     for (var _b = 0, _c = section.texts; _b < _c.length; _b++) {
61321                         var text = _c[_b];
61322                         if (!stripInternal || text.kind !== "internal") {
61323                             (prependTexts || (prependTexts = [])).push(createUnparsedNode(text, node));
61324                         }
61325                     }
61326                     prependNode.texts = prependTexts || ts.emptyArray;
61327                     (texts || (texts = [])).push(prependNode);
61328                     break;
61329                 case "internal":
61330                     if (stripInternal) {
61331                         if (!texts)
61332                             texts = [];
61333                         break;
61334                     }
61335                 case "text":
61336                     (texts || (texts = [])).push(createUnparsedNode(section, node));
61337                     break;
61338                 default:
61339                     ts.Debug.assertNever(section);
61340             }
61341         }
61342         node.prologues = prologues || ts.emptyArray;
61343         node.helpers = helpers;
61344         node.referencedFiles = referencedFiles || ts.emptyArray;
61345         node.typeReferenceDirectives = typeReferenceDirectives;
61346         node.libReferenceDirectives = libReferenceDirectives || ts.emptyArray;
61347         node.texts = texts || [createUnparsedNode({ kind: "text", pos: 0, end: node.text.length }, node)];
61348     }
61349     function parseOldFileOfCurrentEmit(node, bundleFileInfo) {
61350         ts.Debug.assert(!!node.oldFileOfCurrentEmit);
61351         var texts;
61352         var syntheticReferences;
61353         for (var _i = 0, _a = bundleFileInfo.sections; _i < _a.length; _i++) {
61354             var section = _a[_i];
61355             switch (section.kind) {
61356                 case "internal":
61357                 case "text":
61358                     (texts || (texts = [])).push(createUnparsedNode(section, node));
61359                     break;
61360                 case "no-default-lib":
61361                 case "reference":
61362                 case "type":
61363                 case "lib":
61364                     (syntheticReferences || (syntheticReferences = [])).push(createUnparsedSyntheticReference(section, node));
61365                     break;
61366                 case "prologue":
61367                 case "emitHelpers":
61368                 case "prepend":
61369                     break;
61370                 default:
61371                     ts.Debug.assertNever(section);
61372             }
61373         }
61374         node.texts = texts || ts.emptyArray;
61375         node.helpers = ts.map(bundleFileInfo.sources && bundleFileInfo.sources.helpers, function (name) { return getAllUnscopedEmitHelpers().get(name); });
61376         node.syntheticReferences = syntheticReferences;
61377         return node;
61378     }
61379     function mapBundleFileSectionKindToSyntaxKind(kind) {
61380         switch (kind) {
61381             case "prologue": return 285;
61382             case "prepend": return 286;
61383             case "internal": return 288;
61384             case "text": return 287;
61385             case "emitHelpers":
61386             case "no-default-lib":
61387             case "reference":
61388             case "type":
61389             case "lib":
61390                 return ts.Debug.fail("BundleFileSectionKind: " + kind + " not yet mapped to SyntaxKind");
61391             default:
61392                 return ts.Debug.assertNever(kind);
61393         }
61394     }
61395     function createUnparsedNode(section, parent) {
61396         var node = ts.createNode(mapBundleFileSectionKindToSyntaxKind(section.kind), section.pos, section.end);
61397         node.parent = parent;
61398         node.data = section.data;
61399         return node;
61400     }
61401     function createUnparsedSyntheticReference(section, parent) {
61402         var node = ts.createNode(289, section.pos, section.end);
61403         node.parent = parent;
61404         node.data = section.data;
61405         node.section = section;
61406         return node;
61407     }
61408     function createInputFiles(javascriptTextOrReadFileText, declarationTextOrJavascriptPath, javascriptMapPath, javascriptMapTextOrDeclarationPath, declarationMapPath, declarationMapTextOrBuildInfoPath, javascriptPath, declarationPath, buildInfoPath, buildInfo, oldFileOfCurrentEmit) {
61409         var node = ts.createNode(293);
61410         if (!ts.isString(javascriptTextOrReadFileText)) {
61411             var cache_1 = ts.createMap();
61412             var textGetter_1 = function (path) {
61413                 if (path === undefined)
61414                     return undefined;
61415                 var value = cache_1.get(path);
61416                 if (value === undefined) {
61417                     value = javascriptTextOrReadFileText(path);
61418                     cache_1.set(path, value !== undefined ? value : false);
61419                 }
61420                 return value !== false ? value : undefined;
61421             };
61422             var definedTextGetter_1 = function (path) {
61423                 var result = textGetter_1(path);
61424                 return result !== undefined ? result : "/* Input file " + path + " was missing */\r\n";
61425             };
61426             var buildInfo_1;
61427             var getAndCacheBuildInfo_1 = function (getText) {
61428                 if (buildInfo_1 === undefined) {
61429                     var result = getText();
61430                     buildInfo_1 = result !== undefined ? ts.getBuildInfo(result) : false;
61431                 }
61432                 return buildInfo_1 || undefined;
61433             };
61434             node.javascriptPath = declarationTextOrJavascriptPath;
61435             node.javascriptMapPath = javascriptMapPath;
61436             node.declarationPath = ts.Debug.checkDefined(javascriptMapTextOrDeclarationPath);
61437             node.declarationMapPath = declarationMapPath;
61438             node.buildInfoPath = declarationMapTextOrBuildInfoPath;
61439             Object.defineProperties(node, {
61440                 javascriptText: { get: function () { return definedTextGetter_1(declarationTextOrJavascriptPath); } },
61441                 javascriptMapText: { get: function () { return textGetter_1(javascriptMapPath); } },
61442                 declarationText: { get: function () { return definedTextGetter_1(ts.Debug.checkDefined(javascriptMapTextOrDeclarationPath)); } },
61443                 declarationMapText: { get: function () { return textGetter_1(declarationMapPath); } },
61444                 buildInfo: { get: function () { return getAndCacheBuildInfo_1(function () { return textGetter_1(declarationMapTextOrBuildInfoPath); }); } }
61445             });
61446         }
61447         else {
61448             node.javascriptText = javascriptTextOrReadFileText;
61449             node.javascriptMapPath = javascriptMapPath;
61450             node.javascriptMapText = javascriptMapTextOrDeclarationPath;
61451             node.declarationText = declarationTextOrJavascriptPath;
61452             node.declarationMapPath = declarationMapPath;
61453             node.declarationMapText = declarationMapTextOrBuildInfoPath;
61454             node.javascriptPath = javascriptPath;
61455             node.declarationPath = declarationPath;
61456             node.buildInfoPath = buildInfoPath;
61457             node.buildInfo = buildInfo;
61458             node.oldFileOfCurrentEmit = oldFileOfCurrentEmit;
61459         }
61460         return node;
61461     }
61462     ts.createInputFiles = createInputFiles;
61463     function updateBundle(node, sourceFiles, prepends) {
61464         if (prepends === void 0) { prepends = ts.emptyArray; }
61465         if (node.sourceFiles !== sourceFiles || node.prepends !== prepends) {
61466             return createBundle(sourceFiles, prepends);
61467         }
61468         return node;
61469     }
61470     ts.updateBundle = updateBundle;
61471     function createImmediatelyInvokedFunctionExpression(statements, param, paramValue) {
61472         return createCall(createFunctionExpression(undefined, undefined, undefined, undefined, param ? [param] : [], undefined, createBlock(statements, true)), undefined, paramValue ? [paramValue] : []);
61473     }
61474     ts.createImmediatelyInvokedFunctionExpression = createImmediatelyInvokedFunctionExpression;
61475     function createImmediatelyInvokedArrowFunction(statements, param, paramValue) {
61476         return createCall(createArrowFunction(undefined, undefined, param ? [param] : [], undefined, undefined, createBlock(statements, true)), undefined, paramValue ? [paramValue] : []);
61477     }
61478     ts.createImmediatelyInvokedArrowFunction = createImmediatelyInvokedArrowFunction;
61479     function createComma(left, right) {
61480         return createBinary(left, 27, right);
61481     }
61482     ts.createComma = createComma;
61483     function createLessThan(left, right) {
61484         return createBinary(left, 29, right);
61485     }
61486     ts.createLessThan = createLessThan;
61487     function createAssignment(left, right) {
61488         return createBinary(left, 62, right);
61489     }
61490     ts.createAssignment = createAssignment;
61491     function createStrictEquality(left, right) {
61492         return createBinary(left, 36, right);
61493     }
61494     ts.createStrictEquality = createStrictEquality;
61495     function createStrictInequality(left, right) {
61496         return createBinary(left, 37, right);
61497     }
61498     ts.createStrictInequality = createStrictInequality;
61499     function createAdd(left, right) {
61500         return createBinary(left, 39, right);
61501     }
61502     ts.createAdd = createAdd;
61503     function createSubtract(left, right) {
61504         return createBinary(left, 40, right);
61505     }
61506     ts.createSubtract = createSubtract;
61507     function createPostfixIncrement(operand) {
61508         return createPostfix(operand, 45);
61509     }
61510     ts.createPostfixIncrement = createPostfixIncrement;
61511     function createLogicalAnd(left, right) {
61512         return createBinary(left, 55, right);
61513     }
61514     ts.createLogicalAnd = createLogicalAnd;
61515     function createLogicalOr(left, right) {
61516         return createBinary(left, 56, right);
61517     }
61518     ts.createLogicalOr = createLogicalOr;
61519     function createNullishCoalesce(left, right) {
61520         return createBinary(left, 60, right);
61521     }
61522     ts.createNullishCoalesce = createNullishCoalesce;
61523     function createLogicalNot(operand) {
61524         return createPrefix(53, operand);
61525     }
61526     ts.createLogicalNot = createLogicalNot;
61527     function createVoidZero() {
61528         return createVoid(createLiteral(0));
61529     }
61530     ts.createVoidZero = createVoidZero;
61531     function createExportDefault(expression) {
61532         return createExportAssignment(undefined, undefined, false, expression);
61533     }
61534     ts.createExportDefault = createExportDefault;
61535     function createExternalModuleExport(exportName) {
61536         return createExportDeclaration(undefined, undefined, createNamedExports([createExportSpecifier(undefined, exportName)]));
61537     }
61538     ts.createExternalModuleExport = createExternalModuleExport;
61539     function asName(name) {
61540         return ts.isString(name) ? createIdentifier(name) : name;
61541     }
61542     function asExpression(value) {
61543         return typeof value === "string" ? createStringLiteral(value) :
61544             typeof value === "number" ? createNumericLiteral("" + value) :
61545                 typeof value === "boolean" ? value ? createTrue() : createFalse() :
61546                     value;
61547     }
61548     function asNodeArray(array) {
61549         return array ? createNodeArray(array) : undefined;
61550     }
61551     function asToken(value) {
61552         return typeof value === "number" ? createToken(value) : value;
61553     }
61554     function asEmbeddedStatement(statement) {
61555         return statement && ts.isNotEmittedStatement(statement) ? setTextRange(setOriginalNode(createEmptyStatement(), statement), statement) : statement;
61556     }
61557     function disposeEmitNodes(sourceFile) {
61558         sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(sourceFile));
61559         var emitNode = sourceFile && sourceFile.emitNode;
61560         var annotatedNodes = emitNode && emitNode.annotatedNodes;
61561         if (annotatedNodes) {
61562             for (var _i = 0, annotatedNodes_1 = annotatedNodes; _i < annotatedNodes_1.length; _i++) {
61563                 var node = annotatedNodes_1[_i];
61564                 node.emitNode = undefined;
61565             }
61566         }
61567     }
61568     ts.disposeEmitNodes = disposeEmitNodes;
61569     function getOrCreateEmitNode(node) {
61570         if (!node.emitNode) {
61571             if (ts.isParseTreeNode(node)) {
61572                 if (node.kind === 290) {
61573                     return node.emitNode = { annotatedNodes: [node] };
61574                 }
61575                 var sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node)));
61576                 getOrCreateEmitNode(sourceFile).annotatedNodes.push(node);
61577             }
61578             node.emitNode = {};
61579         }
61580         return node.emitNode;
61581     }
61582     ts.getOrCreateEmitNode = getOrCreateEmitNode;
61583     function removeAllComments(node) {
61584         var emitNode = getOrCreateEmitNode(node);
61585         emitNode.flags |= 1536;
61586         emitNode.leadingComments = undefined;
61587         emitNode.trailingComments = undefined;
61588         return node;
61589     }
61590     ts.removeAllComments = removeAllComments;
61591     function setTextRange(range, location) {
61592         if (location) {
61593             range.pos = location.pos;
61594             range.end = location.end;
61595         }
61596         return range;
61597     }
61598     ts.setTextRange = setTextRange;
61599     function setEmitFlags(node, emitFlags) {
61600         getOrCreateEmitNode(node).flags = emitFlags;
61601         return node;
61602     }
61603     ts.setEmitFlags = setEmitFlags;
61604     function addEmitFlags(node, emitFlags) {
61605         var emitNode = getOrCreateEmitNode(node);
61606         emitNode.flags = emitNode.flags | emitFlags;
61607         return node;
61608     }
61609     ts.addEmitFlags = addEmitFlags;
61610     function getSourceMapRange(node) {
61611         var emitNode = node.emitNode;
61612         return (emitNode && emitNode.sourceMapRange) || node;
61613     }
61614     ts.getSourceMapRange = getSourceMapRange;
61615     function setSourceMapRange(node, range) {
61616         getOrCreateEmitNode(node).sourceMapRange = range;
61617         return node;
61618     }
61619     ts.setSourceMapRange = setSourceMapRange;
61620     var SourceMapSource;
61621     function createSourceMapSource(fileName, text, skipTrivia) {
61622         return new (SourceMapSource || (SourceMapSource = ts.objectAllocator.getSourceMapSourceConstructor()))(fileName, text, skipTrivia);
61623     }
61624     ts.createSourceMapSource = createSourceMapSource;
61625     function getTokenSourceMapRange(node, token) {
61626         var emitNode = node.emitNode;
61627         var tokenSourceMapRanges = emitNode && emitNode.tokenSourceMapRanges;
61628         return tokenSourceMapRanges && tokenSourceMapRanges[token];
61629     }
61630     ts.getTokenSourceMapRange = getTokenSourceMapRange;
61631     function setTokenSourceMapRange(node, token, range) {
61632         var emitNode = getOrCreateEmitNode(node);
61633         var tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = []);
61634         tokenSourceMapRanges[token] = range;
61635         return node;
61636     }
61637     ts.setTokenSourceMapRange = setTokenSourceMapRange;
61638     function getStartsOnNewLine(node) {
61639         var emitNode = node.emitNode;
61640         return emitNode && emitNode.startsOnNewLine;
61641     }
61642     ts.getStartsOnNewLine = getStartsOnNewLine;
61643     function setStartsOnNewLine(node, newLine) {
61644         getOrCreateEmitNode(node).startsOnNewLine = newLine;
61645         return node;
61646     }
61647     ts.setStartsOnNewLine = setStartsOnNewLine;
61648     function getCommentRange(node) {
61649         var emitNode = node.emitNode;
61650         return (emitNode && emitNode.commentRange) || node;
61651     }
61652     ts.getCommentRange = getCommentRange;
61653     function setCommentRange(node, range) {
61654         getOrCreateEmitNode(node).commentRange = range;
61655         return node;
61656     }
61657     ts.setCommentRange = setCommentRange;
61658     function getSyntheticLeadingComments(node) {
61659         var emitNode = node.emitNode;
61660         return emitNode && emitNode.leadingComments;
61661     }
61662     ts.getSyntheticLeadingComments = getSyntheticLeadingComments;
61663     function setSyntheticLeadingComments(node, comments) {
61664         getOrCreateEmitNode(node).leadingComments = comments;
61665         return node;
61666     }
61667     ts.setSyntheticLeadingComments = setSyntheticLeadingComments;
61668     function addSyntheticLeadingComment(node, kind, text, hasTrailingNewLine) {
61669         return setSyntheticLeadingComments(node, ts.append(getSyntheticLeadingComments(node), { kind: kind, pos: -1, end: -1, hasTrailingNewLine: hasTrailingNewLine, text: text }));
61670     }
61671     ts.addSyntheticLeadingComment = addSyntheticLeadingComment;
61672     function getSyntheticTrailingComments(node) {
61673         var emitNode = node.emitNode;
61674         return emitNode && emitNode.trailingComments;
61675     }
61676     ts.getSyntheticTrailingComments = getSyntheticTrailingComments;
61677     function setSyntheticTrailingComments(node, comments) {
61678         getOrCreateEmitNode(node).trailingComments = comments;
61679         return node;
61680     }
61681     ts.setSyntheticTrailingComments = setSyntheticTrailingComments;
61682     function addSyntheticTrailingComment(node, kind, text, hasTrailingNewLine) {
61683         return setSyntheticTrailingComments(node, ts.append(getSyntheticTrailingComments(node), { kind: kind, pos: -1, end: -1, hasTrailingNewLine: hasTrailingNewLine, text: text }));
61684     }
61685     ts.addSyntheticTrailingComment = addSyntheticTrailingComment;
61686     function moveSyntheticComments(node, original) {
61687         setSyntheticLeadingComments(node, getSyntheticLeadingComments(original));
61688         setSyntheticTrailingComments(node, getSyntheticTrailingComments(original));
61689         var emit = getOrCreateEmitNode(original);
61690         emit.leadingComments = undefined;
61691         emit.trailingComments = undefined;
61692         return node;
61693     }
61694     ts.moveSyntheticComments = moveSyntheticComments;
61695     function ignoreSourceNewlines(node) {
61696         getOrCreateEmitNode(node).flags |= 134217728;
61697         return node;
61698     }
61699     ts.ignoreSourceNewlines = ignoreSourceNewlines;
61700     function getConstantValue(node) {
61701         var emitNode = node.emitNode;
61702         return emitNode && emitNode.constantValue;
61703     }
61704     ts.getConstantValue = getConstantValue;
61705     function setConstantValue(node, value) {
61706         var emitNode = getOrCreateEmitNode(node);
61707         emitNode.constantValue = value;
61708         return node;
61709     }
61710     ts.setConstantValue = setConstantValue;
61711     function addEmitHelper(node, helper) {
61712         var emitNode = getOrCreateEmitNode(node);
61713         emitNode.helpers = ts.append(emitNode.helpers, helper);
61714         return node;
61715     }
61716     ts.addEmitHelper = addEmitHelper;
61717     function addEmitHelpers(node, helpers) {
61718         if (ts.some(helpers)) {
61719             var emitNode = getOrCreateEmitNode(node);
61720             for (var _i = 0, helpers_1 = helpers; _i < helpers_1.length; _i++) {
61721                 var helper = helpers_1[_i];
61722                 emitNode.helpers = ts.appendIfUnique(emitNode.helpers, helper);
61723             }
61724         }
61725         return node;
61726     }
61727     ts.addEmitHelpers = addEmitHelpers;
61728     function removeEmitHelper(node, helper) {
61729         var emitNode = node.emitNode;
61730         if (emitNode) {
61731             var helpers = emitNode.helpers;
61732             if (helpers) {
61733                 return ts.orderedRemoveItem(helpers, helper);
61734             }
61735         }
61736         return false;
61737     }
61738     ts.removeEmitHelper = removeEmitHelper;
61739     function getEmitHelpers(node) {
61740         var emitNode = node.emitNode;
61741         return emitNode && emitNode.helpers;
61742     }
61743     ts.getEmitHelpers = getEmitHelpers;
61744     function moveEmitHelpers(source, target, predicate) {
61745         var sourceEmitNode = source.emitNode;
61746         var sourceEmitHelpers = sourceEmitNode && sourceEmitNode.helpers;
61747         if (!ts.some(sourceEmitHelpers))
61748             return;
61749         var targetEmitNode = getOrCreateEmitNode(target);
61750         var helpersRemoved = 0;
61751         for (var i = 0; i < sourceEmitHelpers.length; i++) {
61752             var helper = sourceEmitHelpers[i];
61753             if (predicate(helper)) {
61754                 helpersRemoved++;
61755                 targetEmitNode.helpers = ts.appendIfUnique(targetEmitNode.helpers, helper);
61756             }
61757             else if (helpersRemoved > 0) {
61758                 sourceEmitHelpers[i - helpersRemoved] = helper;
61759             }
61760         }
61761         if (helpersRemoved > 0) {
61762             sourceEmitHelpers.length -= helpersRemoved;
61763         }
61764     }
61765     ts.moveEmitHelpers = moveEmitHelpers;
61766     function compareEmitHelpers(x, y) {
61767         if (x === y)
61768             return 0;
61769         if (x.priority === y.priority)
61770             return 0;
61771         if (x.priority === undefined)
61772             return 1;
61773         if (y.priority === undefined)
61774             return -1;
61775         return ts.compareValues(x.priority, y.priority);
61776     }
61777     ts.compareEmitHelpers = compareEmitHelpers;
61778     function setOriginalNode(node, original) {
61779         node.original = original;
61780         if (original) {
61781             var emitNode = original.emitNode;
61782             if (emitNode)
61783                 node.emitNode = mergeEmitNode(emitNode, node.emitNode);
61784         }
61785         return node;
61786     }
61787     ts.setOriginalNode = setOriginalNode;
61788     function mergeEmitNode(sourceEmitNode, destEmitNode) {
61789         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;
61790         if (!destEmitNode)
61791             destEmitNode = {};
61792         if (leadingComments)
61793             destEmitNode.leadingComments = ts.addRange(leadingComments.slice(), destEmitNode.leadingComments);
61794         if (trailingComments)
61795             destEmitNode.trailingComments = ts.addRange(trailingComments.slice(), destEmitNode.trailingComments);
61796         if (flags)
61797             destEmitNode.flags = flags;
61798         if (commentRange)
61799             destEmitNode.commentRange = commentRange;
61800         if (sourceMapRange)
61801             destEmitNode.sourceMapRange = sourceMapRange;
61802         if (tokenSourceMapRanges)
61803             destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges);
61804         if (constantValue !== undefined)
61805             destEmitNode.constantValue = constantValue;
61806         if (helpers)
61807             destEmitNode.helpers = ts.addRange(destEmitNode.helpers, helpers);
61808         if (startsOnNewLine !== undefined)
61809             destEmitNode.startsOnNewLine = startsOnNewLine;
61810         return destEmitNode;
61811     }
61812     function mergeTokenSourceMapRanges(sourceRanges, destRanges) {
61813         if (!destRanges)
61814             destRanges = [];
61815         for (var key in sourceRanges) {
61816             destRanges[key] = sourceRanges[key];
61817         }
61818         return destRanges;
61819     }
61820 })(ts || (ts = {}));
61821 var ts;
61822 (function (ts) {
61823     ts.nullTransformationContext = {
61824         enableEmitNotification: ts.noop,
61825         enableSubstitution: ts.noop,
61826         endLexicalEnvironment: ts.returnUndefined,
61827         getCompilerOptions: function () { return ({}); },
61828         getEmitHost: ts.notImplemented,
61829         getEmitResolver: ts.notImplemented,
61830         setLexicalEnvironmentFlags: ts.noop,
61831         getLexicalEnvironmentFlags: function () { return 0; },
61832         hoistFunctionDeclaration: ts.noop,
61833         hoistVariableDeclaration: ts.noop,
61834         addInitializationStatement: ts.noop,
61835         isEmitNotificationEnabled: ts.notImplemented,
61836         isSubstitutionEnabled: ts.notImplemented,
61837         onEmitNode: ts.noop,
61838         onSubstituteNode: ts.notImplemented,
61839         readEmitHelpers: ts.notImplemented,
61840         requestEmitHelper: ts.noop,
61841         resumeLexicalEnvironment: ts.noop,
61842         startLexicalEnvironment: ts.noop,
61843         suspendLexicalEnvironment: ts.noop,
61844         addDiagnostic: ts.noop,
61845     };
61846     function createTypeCheck(value, tag) {
61847         return tag === "undefined"
61848             ? ts.createStrictEquality(value, ts.createVoidZero())
61849             : ts.createStrictEquality(ts.createTypeOf(value), ts.createLiteral(tag));
61850     }
61851     ts.createTypeCheck = createTypeCheck;
61852     function createMemberAccessForPropertyName(target, memberName, location) {
61853         if (ts.isComputedPropertyName(memberName)) {
61854             return ts.setTextRange(ts.createElementAccess(target, memberName.expression), location);
61855         }
61856         else {
61857             var expression = ts.setTextRange((ts.isIdentifier(memberName) || ts.isPrivateIdentifier(memberName))
61858                 ? ts.createPropertyAccess(target, memberName)
61859                 : ts.createElementAccess(target, memberName), memberName);
61860             ts.getOrCreateEmitNode(expression).flags |= 64;
61861             return expression;
61862         }
61863     }
61864     ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName;
61865     function createFunctionCall(func, thisArg, argumentsList, location) {
61866         return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "call"), undefined, __spreadArrays([
61867             thisArg
61868         ], argumentsList)), location);
61869     }
61870     ts.createFunctionCall = createFunctionCall;
61871     function createFunctionApply(func, thisArg, argumentsExpression, location) {
61872         return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "apply"), undefined, [
61873             thisArg,
61874             argumentsExpression
61875         ]), location);
61876     }
61877     ts.createFunctionApply = createFunctionApply;
61878     function createArraySlice(array, start) {
61879         var argumentsList = [];
61880         if (start !== undefined) {
61881             argumentsList.push(typeof start === "number" ? ts.createLiteral(start) : start);
61882         }
61883         return ts.createCall(ts.createPropertyAccess(array, "slice"), undefined, argumentsList);
61884     }
61885     ts.createArraySlice = createArraySlice;
61886     function createArrayConcat(array, values) {
61887         return ts.createCall(ts.createPropertyAccess(array, "concat"), undefined, values);
61888     }
61889     ts.createArrayConcat = createArrayConcat;
61890     function createMathPow(left, right, location) {
61891         return ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Math"), "pow"), undefined, [left, right]), location);
61892     }
61893     ts.createMathPow = createMathPow;
61894     function createReactNamespace(reactNamespace, parent) {
61895         var react = ts.createIdentifier(reactNamespace || "React");
61896         react.flags &= ~8;
61897         react.parent = ts.getParseTreeNode(parent);
61898         return react;
61899     }
61900     function createJsxFactoryExpressionFromEntityName(jsxFactory, parent) {
61901         if (ts.isQualifiedName(jsxFactory)) {
61902             var left = createJsxFactoryExpressionFromEntityName(jsxFactory.left, parent);
61903             var right = ts.createIdentifier(ts.idText(jsxFactory.right));
61904             right.escapedText = jsxFactory.right.escapedText;
61905             return ts.createPropertyAccess(left, right);
61906         }
61907         else {
61908             return createReactNamespace(ts.idText(jsxFactory), parent);
61909         }
61910     }
61911     function createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parent) {
61912         return jsxFactoryEntity ?
61913             createJsxFactoryExpressionFromEntityName(jsxFactoryEntity, parent) :
61914             ts.createPropertyAccess(createReactNamespace(reactNamespace, parent), "createElement");
61915     }
61916     function createExpressionForJsxElement(jsxFactoryEntity, reactNamespace, tagName, props, children, parentElement, location) {
61917         var argumentsList = [tagName];
61918         if (props) {
61919             argumentsList.push(props);
61920         }
61921         if (children && children.length > 0) {
61922             if (!props) {
61923                 argumentsList.push(ts.createNull());
61924             }
61925             if (children.length > 1) {
61926                 for (var _i = 0, children_2 = children; _i < children_2.length; _i++) {
61927                     var child = children_2[_i];
61928                     startOnNewLine(child);
61929                     argumentsList.push(child);
61930                 }
61931             }
61932             else {
61933                 argumentsList.push(children[0]);
61934             }
61935         }
61936         return ts.setTextRange(ts.createCall(createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), undefined, argumentsList), location);
61937     }
61938     ts.createExpressionForJsxElement = createExpressionForJsxElement;
61939     function createExpressionForJsxFragment(jsxFactoryEntity, reactNamespace, children, parentElement, location) {
61940         var tagName = ts.createPropertyAccess(createReactNamespace(reactNamespace, parentElement), "Fragment");
61941         var argumentsList = [tagName];
61942         argumentsList.push(ts.createNull());
61943         if (children && children.length > 0) {
61944             if (children.length > 1) {
61945                 for (var _i = 0, children_3 = children; _i < children_3.length; _i++) {
61946                     var child = children_3[_i];
61947                     startOnNewLine(child);
61948                     argumentsList.push(child);
61949                 }
61950             }
61951             else {
61952                 argumentsList.push(children[0]);
61953             }
61954         }
61955         return ts.setTextRange(ts.createCall(createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), undefined, argumentsList), location);
61956     }
61957     ts.createExpressionForJsxFragment = createExpressionForJsxFragment;
61958     function getUnscopedHelperName(name) {
61959         return ts.setEmitFlags(ts.createIdentifier(name), 4096 | 2);
61960     }
61961     ts.getUnscopedHelperName = getUnscopedHelperName;
61962     ts.valuesHelper = {
61963         name: "typescript:values",
61964         importName: "__values",
61965         scoped: false,
61966         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            };"
61967     };
61968     function createValuesHelper(context, expression, location) {
61969         context.requestEmitHelper(ts.valuesHelper);
61970         return ts.setTextRange(ts.createCall(getUnscopedHelperName("__values"), undefined, [expression]), location);
61971     }
61972     ts.createValuesHelper = createValuesHelper;
61973     ts.readHelper = {
61974         name: "typescript:read",
61975         importName: "__read",
61976         scoped: false,
61977         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            };"
61978     };
61979     function createReadHelper(context, iteratorRecord, count, location) {
61980         context.requestEmitHelper(ts.readHelper);
61981         return ts.setTextRange(ts.createCall(getUnscopedHelperName("__read"), undefined, count !== undefined
61982             ? [iteratorRecord, ts.createLiteral(count)]
61983             : [iteratorRecord]), location);
61984     }
61985     ts.createReadHelper = createReadHelper;
61986     ts.spreadHelper = {
61987         name: "typescript:spread",
61988         importName: "__spread",
61989         scoped: false,
61990         dependencies: [ts.readHelper],
61991         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            };"
61992     };
61993     function createSpreadHelper(context, argumentList, location) {
61994         context.requestEmitHelper(ts.spreadHelper);
61995         return ts.setTextRange(ts.createCall(getUnscopedHelperName("__spread"), undefined, argumentList), location);
61996     }
61997     ts.createSpreadHelper = createSpreadHelper;
61998     ts.spreadArraysHelper = {
61999         name: "typescript:spreadArrays",
62000         importName: "__spreadArrays",
62001         scoped: false,
62002         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            };"
62003     };
62004     function createSpreadArraysHelper(context, argumentList, location) {
62005         context.requestEmitHelper(ts.spreadArraysHelper);
62006         return ts.setTextRange(ts.createCall(getUnscopedHelperName("__spreadArrays"), undefined, argumentList), location);
62007     }
62008     ts.createSpreadArraysHelper = createSpreadArraysHelper;
62009     function createForOfBindingStatement(node, boundValue) {
62010         if (ts.isVariableDeclarationList(node)) {
62011             var firstDeclaration = ts.first(node.declarations);
62012             var updatedDeclaration = ts.updateVariableDeclaration(firstDeclaration, firstDeclaration.name, undefined, boundValue);
62013             return ts.setTextRange(ts.createVariableStatement(undefined, ts.updateVariableDeclarationList(node, [updatedDeclaration])), node);
62014         }
62015         else {
62016             var updatedExpression = ts.setTextRange(ts.createAssignment(node, boundValue), node);
62017             return ts.setTextRange(ts.createStatement(updatedExpression), node);
62018         }
62019     }
62020     ts.createForOfBindingStatement = createForOfBindingStatement;
62021     function insertLeadingStatement(dest, source) {
62022         if (ts.isBlock(dest)) {
62023             return ts.updateBlock(dest, ts.setTextRange(ts.createNodeArray(__spreadArrays([source], dest.statements)), dest.statements));
62024         }
62025         else {
62026             return ts.createBlock(ts.createNodeArray([dest, source]), true);
62027         }
62028     }
62029     ts.insertLeadingStatement = insertLeadingStatement;
62030     function restoreEnclosingLabel(node, outermostLabeledStatement, afterRestoreLabelCallback) {
62031         if (!outermostLabeledStatement) {
62032             return node;
62033         }
62034         var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 238
62035             ? restoreEnclosingLabel(node, outermostLabeledStatement.statement)
62036             : node);
62037         if (afterRestoreLabelCallback) {
62038             afterRestoreLabelCallback(outermostLabeledStatement);
62039         }
62040         return updated;
62041     }
62042     ts.restoreEnclosingLabel = restoreEnclosingLabel;
62043     function shouldBeCapturedInTempVariable(node, cacheIdentifiers) {
62044         var target = ts.skipParentheses(node);
62045         switch (target.kind) {
62046             case 75:
62047                 return cacheIdentifiers;
62048             case 104:
62049             case 8:
62050             case 9:
62051             case 10:
62052                 return false;
62053             case 192:
62054                 var elements = target.elements;
62055                 if (elements.length === 0) {
62056                     return false;
62057                 }
62058                 return true;
62059             case 193:
62060                 return target.properties.length > 0;
62061             default:
62062                 return true;
62063         }
62064     }
62065     function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) {
62066         if (cacheIdentifiers === void 0) { cacheIdentifiers = false; }
62067         var callee = skipOuterExpressions(expression, 15);
62068         var thisArg;
62069         var target;
62070         if (ts.isSuperProperty(callee)) {
62071             thisArg = ts.createThis();
62072             target = callee;
62073         }
62074         else if (callee.kind === 102) {
62075             thisArg = ts.createThis();
62076             target = languageVersion < 2
62077                 ? ts.setTextRange(ts.createIdentifier("_super"), callee)
62078                 : callee;
62079         }
62080         else if (ts.getEmitFlags(callee) & 4096) {
62081             thisArg = ts.createVoidZero();
62082             target = parenthesizeForAccess(callee);
62083         }
62084         else {
62085             switch (callee.kind) {
62086                 case 194: {
62087                     if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) {
62088                         thisArg = ts.createTempVariable(recordTempVariable);
62089                         target = ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.name);
62090                         ts.setTextRange(target, callee);
62091                     }
62092                     else {
62093                         thisArg = callee.expression;
62094                         target = callee;
62095                     }
62096                     break;
62097                 }
62098                 case 195: {
62099                     if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) {
62100                         thisArg = ts.createTempVariable(recordTempVariable);
62101                         target = ts.createElementAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.argumentExpression);
62102                         ts.setTextRange(target, callee);
62103                     }
62104                     else {
62105                         thisArg = callee.expression;
62106                         target = callee;
62107                     }
62108                     break;
62109                 }
62110                 default: {
62111                     thisArg = ts.createVoidZero();
62112                     target = parenthesizeForAccess(expression);
62113                     break;
62114                 }
62115             }
62116         }
62117         return { target: target, thisArg: thisArg };
62118     }
62119     ts.createCallBinding = createCallBinding;
62120     function inlineExpressions(expressions) {
62121         return expressions.length > 10
62122             ? ts.createCommaList(expressions)
62123             : ts.reduceLeft(expressions, ts.createComma);
62124     }
62125     ts.inlineExpressions = inlineExpressions;
62126     function createExpressionFromEntityName(node) {
62127         if (ts.isQualifiedName(node)) {
62128             var left = createExpressionFromEntityName(node.left);
62129             var right = ts.getMutableClone(node.right);
62130             return ts.setTextRange(ts.createPropertyAccess(left, right), node);
62131         }
62132         else {
62133             return ts.getMutableClone(node);
62134         }
62135     }
62136     ts.createExpressionFromEntityName = createExpressionFromEntityName;
62137     function createExpressionForPropertyName(memberName) {
62138         if (ts.isIdentifier(memberName)) {
62139             return ts.createLiteral(memberName);
62140         }
62141         else if (ts.isComputedPropertyName(memberName)) {
62142             return ts.getMutableClone(memberName.expression);
62143         }
62144         else {
62145             return ts.getMutableClone(memberName);
62146         }
62147     }
62148     ts.createExpressionForPropertyName = createExpressionForPropertyName;
62149     function createExpressionForObjectLiteralElementLike(node, property, receiver) {
62150         if (property.name && ts.isPrivateIdentifier(property.name)) {
62151             ts.Debug.failBadSyntaxKind(property.name, "Private identifiers are not allowed in object literals.");
62152         }
62153         switch (property.kind) {
62154             case 163:
62155             case 164:
62156                 return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine);
62157             case 281:
62158                 return createExpressionForPropertyAssignment(property, receiver);
62159             case 282:
62160                 return createExpressionForShorthandPropertyAssignment(property, receiver);
62161             case 161:
62162                 return createExpressionForMethodDeclaration(property, receiver);
62163         }
62164     }
62165     ts.createExpressionForObjectLiteralElementLike = createExpressionForObjectLiteralElementLike;
62166     function createExpressionForAccessorDeclaration(properties, property, receiver, multiLine) {
62167         var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor;
62168         if (property === firstAccessor) {
62169             var properties_7 = [];
62170             if (getAccessor) {
62171                 var getterFunction = ts.createFunctionExpression(getAccessor.modifiers, undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body);
62172                 ts.setTextRange(getterFunction, getAccessor);
62173                 ts.setOriginalNode(getterFunction, getAccessor);
62174                 var getter = ts.createPropertyAssignment("get", getterFunction);
62175                 properties_7.push(getter);
62176             }
62177             if (setAccessor) {
62178                 var setterFunction = ts.createFunctionExpression(setAccessor.modifiers, undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body);
62179                 ts.setTextRange(setterFunction, setAccessor);
62180                 ts.setOriginalNode(setterFunction, setAccessor);
62181                 var setter = ts.createPropertyAssignment("set", setterFunction);
62182                 properties_7.push(setter);
62183             }
62184             properties_7.push(ts.createPropertyAssignment("enumerable", getAccessor || setAccessor ? ts.createFalse() : ts.createTrue()));
62185             properties_7.push(ts.createPropertyAssignment("configurable", ts.createTrue()));
62186             var expression = ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [
62187                 receiver,
62188                 createExpressionForPropertyName(property.name),
62189                 ts.createObjectLiteral(properties_7, multiLine)
62190             ]), firstAccessor);
62191             return ts.aggregateTransformFlags(expression);
62192         }
62193         return undefined;
62194     }
62195     function createExpressionForPropertyAssignment(property, receiver) {
62196         return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), property.initializer), property), property));
62197     }
62198     function createExpressionForShorthandPropertyAssignment(property, receiver) {
62199         return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), ts.getSynthesizedClone(property.name)), property), property));
62200     }
62201     function createExpressionForMethodDeclaration(method, receiver) {
62202         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));
62203     }
62204     function getInternalName(node, allowComments, allowSourceMaps) {
62205         return getName(node, allowComments, allowSourceMaps, 16384 | 32768);
62206     }
62207     ts.getInternalName = getInternalName;
62208     function isInternalName(node) {
62209         return (ts.getEmitFlags(node) & 32768) !== 0;
62210     }
62211     ts.isInternalName = isInternalName;
62212     function getLocalName(node, allowComments, allowSourceMaps) {
62213         return getName(node, allowComments, allowSourceMaps, 16384);
62214     }
62215     ts.getLocalName = getLocalName;
62216     function isLocalName(node) {
62217         return (ts.getEmitFlags(node) & 16384) !== 0;
62218     }
62219     ts.isLocalName = isLocalName;
62220     function getExportName(node, allowComments, allowSourceMaps) {
62221         return getName(node, allowComments, allowSourceMaps, 8192);
62222     }
62223     ts.getExportName = getExportName;
62224     function isExportName(node) {
62225         return (ts.getEmitFlags(node) & 8192) !== 0;
62226     }
62227     ts.isExportName = isExportName;
62228     function getDeclarationName(node, allowComments, allowSourceMaps) {
62229         return getName(node, allowComments, allowSourceMaps);
62230     }
62231     ts.getDeclarationName = getDeclarationName;
62232     function getName(node, allowComments, allowSourceMaps, emitFlags) {
62233         if (emitFlags === void 0) { emitFlags = 0; }
62234         var nodeName = ts.getNameOfDeclaration(node);
62235         if (nodeName && ts.isIdentifier(nodeName) && !ts.isGeneratedIdentifier(nodeName)) {
62236             var name = ts.getMutableClone(nodeName);
62237             emitFlags |= ts.getEmitFlags(nodeName);
62238             if (!allowSourceMaps)
62239                 emitFlags |= 48;
62240             if (!allowComments)
62241                 emitFlags |= 1536;
62242             if (emitFlags)
62243                 ts.setEmitFlags(name, emitFlags);
62244             return name;
62245         }
62246         return ts.getGeneratedNameForNode(node);
62247     }
62248     function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) {
62249         if (ns && ts.hasModifier(node, 1)) {
62250             return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps);
62251         }
62252         return getExportName(node, allowComments, allowSourceMaps);
62253     }
62254     ts.getExternalModuleOrNamespaceExportName = getExternalModuleOrNamespaceExportName;
62255     function getNamespaceMemberName(ns, name, allowComments, allowSourceMaps) {
62256         var qualifiedName = ts.createPropertyAccess(ns, ts.nodeIsSynthesized(name) ? name : ts.getSynthesizedClone(name));
62257         ts.setTextRange(qualifiedName, name);
62258         var emitFlags = 0;
62259         if (!allowSourceMaps)
62260             emitFlags |= 48;
62261         if (!allowComments)
62262             emitFlags |= 1536;
62263         if (emitFlags)
62264             ts.setEmitFlags(qualifiedName, emitFlags);
62265         return qualifiedName;
62266     }
62267     ts.getNamespaceMemberName = getNamespaceMemberName;
62268     function convertToFunctionBody(node, multiLine) {
62269         return ts.isBlock(node) ? node : ts.setTextRange(ts.createBlock([ts.setTextRange(ts.createReturn(node), node)], multiLine), node);
62270     }
62271     ts.convertToFunctionBody = convertToFunctionBody;
62272     function convertFunctionDeclarationToExpression(node) {
62273         if (!node.body)
62274             return ts.Debug.fail();
62275         var updated = ts.createFunctionExpression(node.modifiers, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body);
62276         ts.setOriginalNode(updated, node);
62277         ts.setTextRange(updated, node);
62278         if (ts.getStartsOnNewLine(node)) {
62279             ts.setStartsOnNewLine(updated, true);
62280         }
62281         ts.aggregateTransformFlags(updated);
62282         return updated;
62283     }
62284     ts.convertFunctionDeclarationToExpression = convertFunctionDeclarationToExpression;
62285     function isUseStrictPrologue(node) {
62286         return ts.isStringLiteral(node.expression) && node.expression.text === "use strict";
62287     }
62288     function addPrologue(target, source, ensureUseStrict, visitor) {
62289         var offset = addStandardPrologue(target, source, ensureUseStrict);
62290         return addCustomPrologue(target, source, offset, visitor);
62291     }
62292     ts.addPrologue = addPrologue;
62293     function addStandardPrologue(target, source, ensureUseStrict) {
62294         ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array");
62295         var foundUseStrict = false;
62296         var statementOffset = 0;
62297         var numStatements = source.length;
62298         while (statementOffset < numStatements) {
62299             var statement = source[statementOffset];
62300             if (ts.isPrologueDirective(statement)) {
62301                 if (isUseStrictPrologue(statement)) {
62302                     foundUseStrict = true;
62303                 }
62304                 target.push(statement);
62305             }
62306             else {
62307                 break;
62308             }
62309             statementOffset++;
62310         }
62311         if (ensureUseStrict && !foundUseStrict) {
62312             target.push(startOnNewLine(ts.createStatement(ts.createLiteral("use strict"))));
62313         }
62314         return statementOffset;
62315     }
62316     ts.addStandardPrologue = addStandardPrologue;
62317     function addCustomPrologue(target, source, statementOffset, visitor, filter) {
62318         if (filter === void 0) { filter = ts.returnTrue; }
62319         var numStatements = source.length;
62320         while (statementOffset !== undefined && statementOffset < numStatements) {
62321             var statement = source[statementOffset];
62322             if (ts.getEmitFlags(statement) & 1048576 && filter(statement)) {
62323                 ts.append(target, visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement);
62324             }
62325             else {
62326                 break;
62327             }
62328             statementOffset++;
62329         }
62330         return statementOffset;
62331     }
62332     ts.addCustomPrologue = addCustomPrologue;
62333     function findUseStrictPrologue(statements) {
62334         for (var _i = 0, statements_4 = statements; _i < statements_4.length; _i++) {
62335             var statement = statements_4[_i];
62336             if (ts.isPrologueDirective(statement)) {
62337                 if (isUseStrictPrologue(statement)) {
62338                     return statement;
62339                 }
62340             }
62341             else {
62342                 break;
62343             }
62344         }
62345         return undefined;
62346     }
62347     ts.findUseStrictPrologue = findUseStrictPrologue;
62348     function startsWithUseStrict(statements) {
62349         var firstStatement = ts.firstOrUndefined(statements);
62350         return firstStatement !== undefined
62351             && ts.isPrologueDirective(firstStatement)
62352             && isUseStrictPrologue(firstStatement);
62353     }
62354     ts.startsWithUseStrict = startsWithUseStrict;
62355     function ensureUseStrict(statements) {
62356         var foundUseStrict = findUseStrictPrologue(statements);
62357         if (!foundUseStrict) {
62358             return ts.setTextRange(ts.createNodeArray(__spreadArrays([
62359                 startOnNewLine(ts.createStatement(ts.createLiteral("use strict")))
62360             ], statements)), statements);
62361         }
62362         return statements;
62363     }
62364     ts.ensureUseStrict = ensureUseStrict;
62365     function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) {
62366         var skipped = ts.skipPartiallyEmittedExpressions(operand);
62367         if (skipped.kind === 200) {
62368             return operand;
62369         }
62370         return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand)
62371             ? ts.createParen(operand)
62372             : operand;
62373     }
62374     ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand;
62375     function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) {
62376         var binaryOperatorPrecedence = ts.getOperatorPrecedence(209, binaryOperator);
62377         var binaryOperatorAssociativity = ts.getOperatorAssociativity(209, binaryOperator);
62378         var emittedOperand = ts.skipPartiallyEmittedExpressions(operand);
62379         if (!isLeftSideOfBinary && operand.kind === 202 && binaryOperatorPrecedence > 3) {
62380             return true;
62381         }
62382         var operandPrecedence = ts.getExpressionPrecedence(emittedOperand);
62383         switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) {
62384             case -1:
62385                 if (!isLeftSideOfBinary
62386                     && binaryOperatorAssociativity === 1
62387                     && operand.kind === 212) {
62388                     return false;
62389                 }
62390                 return true;
62391             case 1:
62392                 return false;
62393             case 0:
62394                 if (isLeftSideOfBinary) {
62395                     return binaryOperatorAssociativity === 1;
62396                 }
62397                 else {
62398                     if (ts.isBinaryExpression(emittedOperand)
62399                         && emittedOperand.operatorToken.kind === binaryOperator) {
62400                         if (operatorHasAssociativeProperty(binaryOperator)) {
62401                             return false;
62402                         }
62403                         if (binaryOperator === 39) {
62404                             var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0;
62405                             if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) {
62406                                 return false;
62407                             }
62408                         }
62409                     }
62410                     var operandAssociativity = ts.getExpressionAssociativity(emittedOperand);
62411                     return operandAssociativity === 0;
62412                 }
62413         }
62414     }
62415     function operatorHasAssociativeProperty(binaryOperator) {
62416         return binaryOperator === 41
62417             || binaryOperator === 51
62418             || binaryOperator === 50
62419             || binaryOperator === 52;
62420     }
62421     function getLiteralKindOfBinaryPlusOperand(node) {
62422         node = ts.skipPartiallyEmittedExpressions(node);
62423         if (ts.isLiteralKind(node.kind)) {
62424             return node.kind;
62425         }
62426         if (node.kind === 209 && node.operatorToken.kind === 39) {
62427             if (node.cachedLiteralKind !== undefined) {
62428                 return node.cachedLiteralKind;
62429             }
62430             var leftKind = getLiteralKindOfBinaryPlusOperand(node.left);
62431             var literalKind = ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) ? leftKind :
62432                 0;
62433             node.cachedLiteralKind = literalKind;
62434             return literalKind;
62435         }
62436         return 0;
62437     }
62438     function parenthesizeForConditionalHead(condition) {
62439         var conditionalPrecedence = ts.getOperatorPrecedence(210, 57);
62440         var emittedCondition = ts.skipPartiallyEmittedExpressions(condition);
62441         var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition);
62442         if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1) {
62443             return ts.createParen(condition);
62444         }
62445         return condition;
62446     }
62447     ts.parenthesizeForConditionalHead = parenthesizeForConditionalHead;
62448     function parenthesizeSubexpressionOfConditionalExpression(e) {
62449         var emittedExpression = ts.skipPartiallyEmittedExpressions(e);
62450         return isCommaSequence(emittedExpression)
62451             ? ts.createParen(e)
62452             : e;
62453     }
62454     ts.parenthesizeSubexpressionOfConditionalExpression = parenthesizeSubexpressionOfConditionalExpression;
62455     function parenthesizeDefaultExpression(e) {
62456         var check = ts.skipPartiallyEmittedExpressions(e);
62457         var needsParens = isCommaSequence(check);
62458         if (!needsParens) {
62459             switch (getLeftmostExpression(check, false).kind) {
62460                 case 214:
62461                 case 201:
62462                     needsParens = true;
62463             }
62464         }
62465         return needsParens ? ts.createParen(e) : e;
62466     }
62467     ts.parenthesizeDefaultExpression = parenthesizeDefaultExpression;
62468     function parenthesizeForNew(expression) {
62469         var leftmostExpr = getLeftmostExpression(expression, true);
62470         switch (leftmostExpr.kind) {
62471             case 196:
62472                 return ts.createParen(expression);
62473             case 197:
62474                 return !leftmostExpr.arguments
62475                     ? ts.createParen(expression)
62476                     : expression;
62477         }
62478         return parenthesizeForAccess(expression);
62479     }
62480     ts.parenthesizeForNew = parenthesizeForNew;
62481     function parenthesizeForAccess(expression) {
62482         var emittedExpression = ts.skipPartiallyEmittedExpressions(expression);
62483         if (ts.isLeftHandSideExpression(emittedExpression)
62484             && (emittedExpression.kind !== 197 || emittedExpression.arguments)) {
62485             return expression;
62486         }
62487         return ts.setTextRange(ts.createParen(expression), expression);
62488     }
62489     ts.parenthesizeForAccess = parenthesizeForAccess;
62490     function parenthesizePostfixOperand(operand) {
62491         return ts.isLeftHandSideExpression(operand)
62492             ? operand
62493             : ts.setTextRange(ts.createParen(operand), operand);
62494     }
62495     ts.parenthesizePostfixOperand = parenthesizePostfixOperand;
62496     function parenthesizePrefixOperand(operand) {
62497         return ts.isUnaryExpression(operand)
62498             ? operand
62499             : ts.setTextRange(ts.createParen(operand), operand);
62500     }
62501     ts.parenthesizePrefixOperand = parenthesizePrefixOperand;
62502     function parenthesizeListElements(elements) {
62503         var result;
62504         for (var i = 0; i < elements.length; i++) {
62505             var element = parenthesizeExpressionForList(elements[i]);
62506             if (result !== undefined || element !== elements[i]) {
62507                 if (result === undefined) {
62508                     result = elements.slice(0, i);
62509                 }
62510                 result.push(element);
62511             }
62512         }
62513         if (result !== undefined) {
62514             return ts.setTextRange(ts.createNodeArray(result, elements.hasTrailingComma), elements);
62515         }
62516         return elements;
62517     }
62518     ts.parenthesizeListElements = parenthesizeListElements;
62519     function parenthesizeExpressionForList(expression) {
62520         var emittedExpression = ts.skipPartiallyEmittedExpressions(expression);
62521         var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression);
62522         var commaPrecedence = ts.getOperatorPrecedence(209, 27);
62523         return expressionPrecedence > commaPrecedence
62524             ? expression
62525             : ts.setTextRange(ts.createParen(expression), expression);
62526     }
62527     ts.parenthesizeExpressionForList = parenthesizeExpressionForList;
62528     function parenthesizeExpressionForExpressionStatement(expression) {
62529         var emittedExpression = ts.skipPartiallyEmittedExpressions(expression);
62530         if (ts.isCallExpression(emittedExpression)) {
62531             var callee = emittedExpression.expression;
62532             var kind = ts.skipPartiallyEmittedExpressions(callee).kind;
62533             if (kind === 201 || kind === 202) {
62534                 var mutableCall = ts.getMutableClone(emittedExpression);
62535                 mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee);
62536                 return recreateOuterExpressions(expression, mutableCall, 8);
62537             }
62538         }
62539         var leftmostExpressionKind = getLeftmostExpression(emittedExpression, false).kind;
62540         if (leftmostExpressionKind === 193 || leftmostExpressionKind === 201) {
62541             return ts.setTextRange(ts.createParen(expression), expression);
62542         }
62543         return expression;
62544     }
62545     ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement;
62546     function parenthesizeConditionalTypeMember(member) {
62547         return member.kind === 180 ? ts.createParenthesizedType(member) : member;
62548     }
62549     ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember;
62550     function parenthesizeElementTypeMember(member) {
62551         switch (member.kind) {
62552             case 178:
62553             case 179:
62554             case 170:
62555             case 171:
62556                 return ts.createParenthesizedType(member);
62557         }
62558         return parenthesizeConditionalTypeMember(member);
62559     }
62560     ts.parenthesizeElementTypeMember = parenthesizeElementTypeMember;
62561     function parenthesizeArrayTypeMember(member) {
62562         switch (member.kind) {
62563             case 172:
62564             case 184:
62565             case 181:
62566                 return ts.createParenthesizedType(member);
62567         }
62568         return parenthesizeElementTypeMember(member);
62569     }
62570     ts.parenthesizeArrayTypeMember = parenthesizeArrayTypeMember;
62571     function parenthesizeElementTypeMembers(members) {
62572         return ts.createNodeArray(ts.sameMap(members, parenthesizeElementTypeMember));
62573     }
62574     ts.parenthesizeElementTypeMembers = parenthesizeElementTypeMembers;
62575     function parenthesizeTypeParameters(typeParameters) {
62576         if (ts.some(typeParameters)) {
62577             var params = [];
62578             for (var i = 0; i < typeParameters.length; ++i) {
62579                 var entry = typeParameters[i];
62580                 params.push(i === 0 && ts.isFunctionOrConstructorTypeNode(entry) && entry.typeParameters ?
62581                     ts.createParenthesizedType(entry) :
62582                     entry);
62583             }
62584             return ts.createNodeArray(params);
62585         }
62586     }
62587     ts.parenthesizeTypeParameters = parenthesizeTypeParameters;
62588     function getLeftmostExpression(node, stopAtCallExpressions) {
62589         while (true) {
62590             switch (node.kind) {
62591                 case 208:
62592                     node = node.operand;
62593                     continue;
62594                 case 209:
62595                     node = node.left;
62596                     continue;
62597                 case 210:
62598                     node = node.condition;
62599                     continue;
62600                 case 198:
62601                     node = node.tag;
62602                     continue;
62603                 case 196:
62604                     if (stopAtCallExpressions) {
62605                         return node;
62606                     }
62607                 case 217:
62608                 case 195:
62609                 case 194:
62610                 case 218:
62611                 case 326:
62612                     node = node.expression;
62613                     continue;
62614             }
62615             return node;
62616         }
62617     }
62618     ts.getLeftmostExpression = getLeftmostExpression;
62619     function parenthesizeConciseBody(body) {
62620         if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, false).kind === 193)) {
62621             return ts.setTextRange(ts.createParen(body), body);
62622         }
62623         return body;
62624     }
62625     ts.parenthesizeConciseBody = parenthesizeConciseBody;
62626     function isCommaSequence(node) {
62627         return node.kind === 209 && node.operatorToken.kind === 27 ||
62628             node.kind === 327;
62629     }
62630     ts.isCommaSequence = isCommaSequence;
62631     function isOuterExpression(node, kinds) {
62632         if (kinds === void 0) { kinds = 15; }
62633         switch (node.kind) {
62634             case 200:
62635                 return (kinds & 1) !== 0;
62636             case 199:
62637             case 217:
62638                 return (kinds & 2) !== 0;
62639             case 218:
62640                 return (kinds & 4) !== 0;
62641             case 326:
62642                 return (kinds & 8) !== 0;
62643         }
62644         return false;
62645     }
62646     ts.isOuterExpression = isOuterExpression;
62647     function skipOuterExpressions(node, kinds) {
62648         if (kinds === void 0) { kinds = 15; }
62649         while (isOuterExpression(node, kinds)) {
62650             node = node.expression;
62651         }
62652         return node;
62653     }
62654     ts.skipOuterExpressions = skipOuterExpressions;
62655     function skipAssertions(node) {
62656         return skipOuterExpressions(node, 6);
62657     }
62658     ts.skipAssertions = skipAssertions;
62659     function updateOuterExpression(outerExpression, expression) {
62660         switch (outerExpression.kind) {
62661             case 200: return ts.updateParen(outerExpression, expression);
62662             case 199: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression);
62663             case 217: return ts.updateAsExpression(outerExpression, expression, outerExpression.type);
62664             case 218: return ts.updateNonNullExpression(outerExpression, expression);
62665             case 326: return ts.updatePartiallyEmittedExpression(outerExpression, expression);
62666         }
62667     }
62668     function isIgnorableParen(node) {
62669         return node.kind === 200
62670             && ts.nodeIsSynthesized(node)
62671             && ts.nodeIsSynthesized(ts.getSourceMapRange(node))
62672             && ts.nodeIsSynthesized(ts.getCommentRange(node))
62673             && !ts.some(ts.getSyntheticLeadingComments(node))
62674             && !ts.some(ts.getSyntheticTrailingComments(node));
62675     }
62676     function recreateOuterExpressions(outerExpression, innerExpression, kinds) {
62677         if (kinds === void 0) { kinds = 15; }
62678         if (outerExpression && isOuterExpression(outerExpression, kinds) && !isIgnorableParen(outerExpression)) {
62679             return updateOuterExpression(outerExpression, recreateOuterExpressions(outerExpression.expression, innerExpression));
62680         }
62681         return innerExpression;
62682     }
62683     ts.recreateOuterExpressions = recreateOuterExpressions;
62684     function startOnNewLine(node) {
62685         return ts.setStartsOnNewLine(node, true);
62686     }
62687     ts.startOnNewLine = startOnNewLine;
62688     function getExternalHelpersModuleName(node) {
62689         var parseNode = ts.getOriginalNode(node, ts.isSourceFile);
62690         var emitNode = parseNode && parseNode.emitNode;
62691         return emitNode && emitNode.externalHelpersModuleName;
62692     }
62693     ts.getExternalHelpersModuleName = getExternalHelpersModuleName;
62694     function hasRecordedExternalHelpers(sourceFile) {
62695         var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile);
62696         var emitNode = parseNode && parseNode.emitNode;
62697         return !!emitNode && (!!emitNode.externalHelpersModuleName || !!emitNode.externalHelpers);
62698     }
62699     ts.hasRecordedExternalHelpers = hasRecordedExternalHelpers;
62700     function createExternalHelpersImportDeclarationIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault) {
62701         if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
62702             var namedBindings = void 0;
62703             var moduleKind = ts.getEmitModuleKind(compilerOptions);
62704             if (moduleKind >= ts.ModuleKind.ES2015 && moduleKind <= ts.ModuleKind.ESNext) {
62705                 var helpers = ts.getEmitHelpers(sourceFile);
62706                 if (helpers) {
62707                     var helperNames = [];
62708                     for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) {
62709                         var helper = helpers_2[_i];
62710                         if (!helper.scoped) {
62711                             var importName = helper.importName;
62712                             if (importName) {
62713                                 ts.pushIfUnique(helperNames, importName);
62714                             }
62715                         }
62716                     }
62717                     if (ts.some(helperNames)) {
62718                         helperNames.sort(ts.compareStringsCaseSensitive);
62719                         namedBindings = ts.createNamedImports(ts.map(helperNames, function (name) { return ts.isFileLevelUniqueName(sourceFile, name)
62720                             ? ts.createImportSpecifier(undefined, ts.createIdentifier(name))
62721                             : ts.createImportSpecifier(ts.createIdentifier(name), getUnscopedHelperName(name)); }));
62722                         var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile);
62723                         var emitNode = ts.getOrCreateEmitNode(parseNode);
62724                         emitNode.externalHelpers = true;
62725                     }
62726                 }
62727             }
62728             else {
62729                 var externalHelpersModuleName = getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar || hasImportDefault);
62730                 if (externalHelpersModuleName) {
62731                     namedBindings = ts.createNamespaceImport(externalHelpersModuleName);
62732                 }
62733             }
62734             if (namedBindings) {
62735                 var externalHelpersImportDeclaration = ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, namedBindings), ts.createLiteral(ts.externalHelpersModuleNameText));
62736                 ts.addEmitFlags(externalHelpersImportDeclaration, 67108864);
62737                 return externalHelpersImportDeclaration;
62738             }
62739         }
62740     }
62741     ts.createExternalHelpersImportDeclarationIfNeeded = createExternalHelpersImportDeclarationIfNeeded;
62742     function getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions, hasExportStarsToExportValues, hasImportStarOrImportDefault) {
62743         if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(node, compilerOptions)) {
62744             var externalHelpersModuleName = getExternalHelpersModuleName(node);
62745             if (externalHelpersModuleName) {
62746                 return externalHelpersModuleName;
62747             }
62748             var moduleKind = ts.getEmitModuleKind(compilerOptions);
62749             var create = (hasExportStarsToExportValues || (compilerOptions.esModuleInterop && hasImportStarOrImportDefault))
62750                 && moduleKind !== ts.ModuleKind.System
62751                 && moduleKind < ts.ModuleKind.ES2015;
62752             if (!create) {
62753                 var helpers = ts.getEmitHelpers(node);
62754                 if (helpers) {
62755                     for (var _i = 0, helpers_3 = helpers; _i < helpers_3.length; _i++) {
62756                         var helper = helpers_3[_i];
62757                         if (!helper.scoped) {
62758                             create = true;
62759                             break;
62760                         }
62761                     }
62762                 }
62763             }
62764             if (create) {
62765                 var parseNode = ts.getOriginalNode(node, ts.isSourceFile);
62766                 var emitNode = ts.getOrCreateEmitNode(parseNode);
62767                 return emitNode.externalHelpersModuleName || (emitNode.externalHelpersModuleName = ts.createUniqueName(ts.externalHelpersModuleNameText));
62768             }
62769         }
62770     }
62771     ts.getOrCreateExternalHelpersModuleNameIfNeeded = getOrCreateExternalHelpersModuleNameIfNeeded;
62772     function getLocalNameForExternalImport(node, sourceFile) {
62773         var namespaceDeclaration = ts.getNamespaceDeclarationNode(node);
62774         if (namespaceDeclaration && !ts.isDefaultImport(node)) {
62775             var name = namespaceDeclaration.name;
62776             return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name));
62777         }
62778         if (node.kind === 254 && node.importClause) {
62779             return ts.getGeneratedNameForNode(node);
62780         }
62781         if (node.kind === 260 && node.moduleSpecifier) {
62782             return ts.getGeneratedNameForNode(node);
62783         }
62784         return undefined;
62785     }
62786     ts.getLocalNameForExternalImport = getLocalNameForExternalImport;
62787     function getExternalModuleNameLiteral(importNode, sourceFile, host, resolver, compilerOptions) {
62788         var moduleName = ts.getExternalModuleName(importNode);
62789         if (moduleName.kind === 10) {
62790             return tryGetModuleNameFromDeclaration(importNode, host, resolver, compilerOptions)
62791                 || tryRenameExternalModule(moduleName, sourceFile)
62792                 || ts.getSynthesizedClone(moduleName);
62793         }
62794         return undefined;
62795     }
62796     ts.getExternalModuleNameLiteral = getExternalModuleNameLiteral;
62797     function tryRenameExternalModule(moduleName, sourceFile) {
62798         var rename = sourceFile.renamedDependencies && sourceFile.renamedDependencies.get(moduleName.text);
62799         return rename && ts.createLiteral(rename);
62800     }
62801     function tryGetModuleNameFromFile(file, host, options) {
62802         if (!file) {
62803             return undefined;
62804         }
62805         if (file.moduleName) {
62806             return ts.createLiteral(file.moduleName);
62807         }
62808         if (!file.isDeclarationFile && (options.out || options.outFile)) {
62809             return ts.createLiteral(ts.getExternalModuleNameFromPath(host, file.fileName));
62810         }
62811         return undefined;
62812     }
62813     ts.tryGetModuleNameFromFile = tryGetModuleNameFromFile;
62814     function tryGetModuleNameFromDeclaration(declaration, host, resolver, compilerOptions) {
62815         return tryGetModuleNameFromFile(resolver.getExternalModuleFileFromDeclaration(declaration), host, compilerOptions);
62816     }
62817     function getInitializerOfBindingOrAssignmentElement(bindingElement) {
62818         if (ts.isDeclarationBindingElement(bindingElement)) {
62819             return bindingElement.initializer;
62820         }
62821         if (ts.isPropertyAssignment(bindingElement)) {
62822             var initializer = bindingElement.initializer;
62823             return ts.isAssignmentExpression(initializer, true)
62824                 ? initializer.right
62825                 : undefined;
62826         }
62827         if (ts.isShorthandPropertyAssignment(bindingElement)) {
62828             return bindingElement.objectAssignmentInitializer;
62829         }
62830         if (ts.isAssignmentExpression(bindingElement, true)) {
62831             return bindingElement.right;
62832         }
62833         if (ts.isSpreadElement(bindingElement)) {
62834             return getInitializerOfBindingOrAssignmentElement(bindingElement.expression);
62835         }
62836     }
62837     ts.getInitializerOfBindingOrAssignmentElement = getInitializerOfBindingOrAssignmentElement;
62838     function getTargetOfBindingOrAssignmentElement(bindingElement) {
62839         if (ts.isDeclarationBindingElement(bindingElement)) {
62840             return bindingElement.name;
62841         }
62842         if (ts.isObjectLiteralElementLike(bindingElement)) {
62843             switch (bindingElement.kind) {
62844                 case 281:
62845                     return getTargetOfBindingOrAssignmentElement(bindingElement.initializer);
62846                 case 282:
62847                     return bindingElement.name;
62848                 case 283:
62849                     return getTargetOfBindingOrAssignmentElement(bindingElement.expression);
62850             }
62851             return undefined;
62852         }
62853         if (ts.isAssignmentExpression(bindingElement, true)) {
62854             return getTargetOfBindingOrAssignmentElement(bindingElement.left);
62855         }
62856         if (ts.isSpreadElement(bindingElement)) {
62857             return getTargetOfBindingOrAssignmentElement(bindingElement.expression);
62858         }
62859         return bindingElement;
62860     }
62861     ts.getTargetOfBindingOrAssignmentElement = getTargetOfBindingOrAssignmentElement;
62862     function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) {
62863         switch (bindingElement.kind) {
62864             case 156:
62865             case 191:
62866                 return bindingElement.dotDotDotToken;
62867             case 213:
62868             case 283:
62869                 return bindingElement;
62870         }
62871         return undefined;
62872     }
62873     ts.getRestIndicatorOfBindingOrAssignmentElement = getRestIndicatorOfBindingOrAssignmentElement;
62874     function getPropertyNameOfBindingOrAssignmentElement(bindingElement) {
62875         var propertyName = tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement);
62876         ts.Debug.assert(!!propertyName || ts.isSpreadAssignment(bindingElement), "Invalid property name for binding element.");
62877         return propertyName;
62878     }
62879     ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement;
62880     function tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement) {
62881         switch (bindingElement.kind) {
62882             case 191:
62883                 if (bindingElement.propertyName) {
62884                     var propertyName = bindingElement.propertyName;
62885                     if (ts.isPrivateIdentifier(propertyName)) {
62886                         return ts.Debug.failBadSyntaxKind(propertyName);
62887                     }
62888                     return ts.isComputedPropertyName(propertyName) && isStringOrNumericLiteral(propertyName.expression)
62889                         ? propertyName.expression
62890                         : propertyName;
62891                 }
62892                 break;
62893             case 281:
62894                 if (bindingElement.name) {
62895                     var propertyName = bindingElement.name;
62896                     if (ts.isPrivateIdentifier(propertyName)) {
62897                         return ts.Debug.failBadSyntaxKind(propertyName);
62898                     }
62899                     return ts.isComputedPropertyName(propertyName) && isStringOrNumericLiteral(propertyName.expression)
62900                         ? propertyName.expression
62901                         : propertyName;
62902                 }
62903                 break;
62904             case 283:
62905                 if (bindingElement.name && ts.isPrivateIdentifier(bindingElement.name)) {
62906                     return ts.Debug.failBadSyntaxKind(bindingElement.name);
62907                 }
62908                 return bindingElement.name;
62909         }
62910         var target = getTargetOfBindingOrAssignmentElement(bindingElement);
62911         if (target && ts.isPropertyName(target)) {
62912             return target;
62913         }
62914     }
62915     ts.tryGetPropertyNameOfBindingOrAssignmentElement = tryGetPropertyNameOfBindingOrAssignmentElement;
62916     function isStringOrNumericLiteral(node) {
62917         var kind = node.kind;
62918         return kind === 10
62919             || kind === 8;
62920     }
62921     function getElementsOfBindingOrAssignmentPattern(name) {
62922         switch (name.kind) {
62923             case 189:
62924             case 190:
62925             case 192:
62926                 return name.elements;
62927             case 193:
62928                 return name.properties;
62929         }
62930     }
62931     ts.getElementsOfBindingOrAssignmentPattern = getElementsOfBindingOrAssignmentPattern;
62932     function convertToArrayAssignmentElement(element) {
62933         if (ts.isBindingElement(element)) {
62934             if (element.dotDotDotToken) {
62935                 ts.Debug.assertNode(element.name, ts.isIdentifier);
62936                 return ts.setOriginalNode(ts.setTextRange(ts.createSpread(element.name), element), element);
62937             }
62938             var expression = convertToAssignmentElementTarget(element.name);
62939             return element.initializer
62940                 ? ts.setOriginalNode(ts.setTextRange(ts.createAssignment(expression, element.initializer), element), element)
62941                 : expression;
62942         }
62943         ts.Debug.assertNode(element, ts.isExpression);
62944         return element;
62945     }
62946     ts.convertToArrayAssignmentElement = convertToArrayAssignmentElement;
62947     function convertToObjectAssignmentElement(element) {
62948         if (ts.isBindingElement(element)) {
62949             if (element.dotDotDotToken) {
62950                 ts.Debug.assertNode(element.name, ts.isIdentifier);
62951                 return ts.setOriginalNode(ts.setTextRange(ts.createSpreadAssignment(element.name), element), element);
62952             }
62953             if (element.propertyName) {
62954                 var expression = convertToAssignmentElementTarget(element.name);
62955                 return ts.setOriginalNode(ts.setTextRange(ts.createPropertyAssignment(element.propertyName, element.initializer ? ts.createAssignment(expression, element.initializer) : expression), element), element);
62956             }
62957             ts.Debug.assertNode(element.name, ts.isIdentifier);
62958             return ts.setOriginalNode(ts.setTextRange(ts.createShorthandPropertyAssignment(element.name, element.initializer), element), element);
62959         }
62960         ts.Debug.assertNode(element, ts.isObjectLiteralElementLike);
62961         return element;
62962     }
62963     ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement;
62964     function convertToAssignmentPattern(node) {
62965         switch (node.kind) {
62966             case 190:
62967             case 192:
62968                 return convertToArrayAssignmentPattern(node);
62969             case 189:
62970             case 193:
62971                 return convertToObjectAssignmentPattern(node);
62972         }
62973     }
62974     ts.convertToAssignmentPattern = convertToAssignmentPattern;
62975     function convertToObjectAssignmentPattern(node) {
62976         if (ts.isObjectBindingPattern(node)) {
62977             return ts.setOriginalNode(ts.setTextRange(ts.createObjectLiteral(ts.map(node.elements, convertToObjectAssignmentElement)), node), node);
62978         }
62979         ts.Debug.assertNode(node, ts.isObjectLiteralExpression);
62980         return node;
62981     }
62982     ts.convertToObjectAssignmentPattern = convertToObjectAssignmentPattern;
62983     function convertToArrayAssignmentPattern(node) {
62984         if (ts.isArrayBindingPattern(node)) {
62985             return ts.setOriginalNode(ts.setTextRange(ts.createArrayLiteral(ts.map(node.elements, convertToArrayAssignmentElement)), node), node);
62986         }
62987         ts.Debug.assertNode(node, ts.isArrayLiteralExpression);
62988         return node;
62989     }
62990     ts.convertToArrayAssignmentPattern = convertToArrayAssignmentPattern;
62991     function convertToAssignmentElementTarget(node) {
62992         if (ts.isBindingPattern(node)) {
62993             return convertToAssignmentPattern(node);
62994         }
62995         ts.Debug.assertNode(node, ts.isExpression);
62996         return node;
62997     }
62998     ts.convertToAssignmentElementTarget = convertToAssignmentElementTarget;
62999 })(ts || (ts = {}));
63000 var ts;
63001 (function (ts) {
63002     var isTypeNodeOrTypeParameterDeclaration = ts.or(ts.isTypeNode, ts.isTypeParameterDeclaration);
63003     function visitNode(node, visitor, test, lift) {
63004         if (node === undefined || visitor === undefined) {
63005             return node;
63006         }
63007         ts.aggregateTransformFlags(node);
63008         var visited = visitor(node);
63009         if (visited === node) {
63010             return node;
63011         }
63012         var visitedNode;
63013         if (visited === undefined) {
63014             return undefined;
63015         }
63016         else if (ts.isArray(visited)) {
63017             visitedNode = (lift || extractSingleNode)(visited);
63018         }
63019         else {
63020             visitedNode = visited;
63021         }
63022         ts.Debug.assertNode(visitedNode, test);
63023         ts.aggregateTransformFlags(visitedNode);
63024         return visitedNode;
63025     }
63026     ts.visitNode = visitNode;
63027     function visitNodes(nodes, visitor, test, start, count) {
63028         if (nodes === undefined || visitor === undefined) {
63029             return nodes;
63030         }
63031         var updated;
63032         var length = nodes.length;
63033         if (start === undefined || start < 0) {
63034             start = 0;
63035         }
63036         if (count === undefined || count > length - start) {
63037             count = length - start;
63038         }
63039         if (start > 0 || count < length) {
63040             updated = ts.createNodeArray([], nodes.hasTrailingComma && start + count === length);
63041         }
63042         for (var i = 0; i < count; i++) {
63043             var node = nodes[i + start];
63044             ts.aggregateTransformFlags(node);
63045             var visited = node !== undefined ? visitor(node) : undefined;
63046             if (updated !== undefined || visited === undefined || visited !== node) {
63047                 if (updated === undefined) {
63048                     updated = ts.createNodeArray(nodes.slice(0, i), nodes.hasTrailingComma);
63049                     ts.setTextRange(updated, nodes);
63050                 }
63051                 if (visited) {
63052                     if (ts.isArray(visited)) {
63053                         for (var _i = 0, visited_1 = visited; _i < visited_1.length; _i++) {
63054                             var visitedNode = visited_1[_i];
63055                             ts.Debug.assertNode(visitedNode, test);
63056                             ts.aggregateTransformFlags(visitedNode);
63057                             updated.push(visitedNode);
63058                         }
63059                     }
63060                     else {
63061                         ts.Debug.assertNode(visited, test);
63062                         ts.aggregateTransformFlags(visited);
63063                         updated.push(visited);
63064                     }
63065                 }
63066             }
63067         }
63068         return updated || nodes;
63069     }
63070     ts.visitNodes = visitNodes;
63071     function visitLexicalEnvironment(statements, visitor, context, start, ensureUseStrict) {
63072         context.startLexicalEnvironment();
63073         statements = visitNodes(statements, visitor, ts.isStatement, start);
63074         if (ensureUseStrict)
63075             statements = ts.ensureUseStrict(statements);
63076         return ts.mergeLexicalEnvironment(statements, context.endLexicalEnvironment());
63077     }
63078     ts.visitLexicalEnvironment = visitLexicalEnvironment;
63079     function visitParameterList(nodes, visitor, context, nodesVisitor) {
63080         if (nodesVisitor === void 0) { nodesVisitor = visitNodes; }
63081         var updated;
63082         context.startLexicalEnvironment();
63083         if (nodes) {
63084             context.setLexicalEnvironmentFlags(1, true);
63085             updated = nodesVisitor(nodes, visitor, ts.isParameterDeclaration);
63086             if (context.getLexicalEnvironmentFlags() & 2 &&
63087                 ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2) {
63088                 updated = addDefaultValueAssignmentsIfNeeded(updated, context);
63089             }
63090             context.setLexicalEnvironmentFlags(1, false);
63091         }
63092         context.suspendLexicalEnvironment();
63093         return updated;
63094     }
63095     ts.visitParameterList = visitParameterList;
63096     function addDefaultValueAssignmentsIfNeeded(parameters, context) {
63097         var result;
63098         for (var i = 0; i < parameters.length; i++) {
63099             var parameter = parameters[i];
63100             var updated = addDefaultValueAssignmentIfNeeded(parameter, context);
63101             if (result || updated !== parameter) {
63102                 if (!result)
63103                     result = parameters.slice(0, i);
63104                 result[i] = updated;
63105             }
63106         }
63107         if (result) {
63108             return ts.setTextRange(ts.createNodeArray(result, parameters.hasTrailingComma), parameters);
63109         }
63110         return parameters;
63111     }
63112     function addDefaultValueAssignmentIfNeeded(parameter, context) {
63113         return parameter.dotDotDotToken ? parameter :
63114             ts.isBindingPattern(parameter.name) ? addDefaultValueAssignmentForBindingPattern(parameter, context) :
63115                 parameter.initializer ? addDefaultValueAssignmentForInitializer(parameter, parameter.name, parameter.initializer, context) :
63116                     parameter;
63117     }
63118     function addDefaultValueAssignmentForBindingPattern(parameter, context) {
63119         context.addInitializationStatement(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
63120             ts.createVariableDeclaration(parameter.name, parameter.type, parameter.initializer ?
63121                 ts.createConditional(ts.createStrictEquality(ts.getGeneratedNameForNode(parameter), ts.createVoidZero()), parameter.initializer, ts.getGeneratedNameForNode(parameter)) :
63122                 ts.getGeneratedNameForNode(parameter)),
63123         ])));
63124         return ts.updateParameter(parameter, parameter.decorators, parameter.modifiers, parameter.dotDotDotToken, ts.getGeneratedNameForNode(parameter), parameter.questionToken, parameter.type, undefined);
63125     }
63126     function addDefaultValueAssignmentForInitializer(parameter, name, initializer, context) {
63127         context.addInitializationStatement(ts.createIf(ts.createTypeCheck(ts.getSynthesizedClone(name), "undefined"), ts.setEmitFlags(ts.setTextRange(ts.createBlock([
63128             ts.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48), ts.setEmitFlags(initializer, 48 | ts.getEmitFlags(initializer) | 1536)), parameter), 1536))
63129         ]), parameter), 1 | 32 | 384 | 1536)));
63130         return ts.updateParameter(parameter, parameter.decorators, parameter.modifiers, parameter.dotDotDotToken, parameter.name, parameter.questionToken, parameter.type, undefined);
63131     }
63132     function visitFunctionBody(node, visitor, context) {
63133         context.resumeLexicalEnvironment();
63134         var updated = visitNode(node, visitor, ts.isConciseBody);
63135         var declarations = context.endLexicalEnvironment();
63136         if (ts.some(declarations)) {
63137             var block = ts.convertToFunctionBody(updated);
63138             var statements = ts.mergeLexicalEnvironment(block.statements, declarations);
63139             return ts.updateBlock(block, statements);
63140         }
63141         return updated;
63142     }
63143     ts.visitFunctionBody = visitFunctionBody;
63144     function visitEachChild(node, visitor, context, nodesVisitor, tokenVisitor) {
63145         if (nodesVisitor === void 0) { nodesVisitor = visitNodes; }
63146         if (node === undefined) {
63147             return undefined;
63148         }
63149         var kind = node.kind;
63150         if ((kind > 0 && kind <= 152) || kind === 183) {
63151             return node;
63152         }
63153         switch (kind) {
63154             case 75:
63155                 return ts.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration));
63156             case 153:
63157                 return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier));
63158             case 154:
63159                 return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression));
63160             case 155:
63161                 return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode));
63162             case 156:
63163                 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));
63164             case 157:
63165                 return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression));
63166             case 158:
63167                 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));
63168             case 159:
63169                 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));
63170             case 160:
63171                 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));
63172             case 161:
63173                 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));
63174             case 162:
63175                 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));
63176             case 163:
63177                 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));
63178             case 164:
63179                 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));
63180             case 165:
63181                 return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode));
63182             case 166:
63183                 return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode));
63184             case 167:
63185                 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));
63186             case 168:
63187                 return ts.updateTypePredicateNodeWithModifier(node, visitNode(node.assertsModifier, visitor), visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode));
63188             case 169:
63189                 return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode));
63190             case 170:
63191                 return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode));
63192             case 171:
63193                 return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode));
63194             case 172:
63195                 return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName));
63196             case 173:
63197                 return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement));
63198             case 174:
63199                 return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode));
63200             case 175:
63201                 return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode));
63202             case 176:
63203                 return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode));
63204             case 177:
63205                 return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode));
63206             case 178:
63207                 return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode));
63208             case 179:
63209                 return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode));
63210             case 180:
63211                 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));
63212             case 181:
63213                 return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration));
63214             case 188:
63215                 return ts.updateImportTypeNode(node, visitNode(node.argument, visitor, ts.isTypeNode), visitNode(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf);
63216             case 182:
63217                 return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode));
63218             case 184:
63219                 return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode));
63220             case 185:
63221                 return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode));
63222             case 186:
63223                 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));
63224             case 187:
63225                 return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression));
63226             case 189:
63227                 return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement));
63228             case 190:
63229                 return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement));
63230             case 191:
63231                 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));
63232             case 192:
63233                 return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression));
63234             case 193:
63235                 return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike));
63236             case 194:
63237                 if (node.flags & 32) {
63238                     return ts.updatePropertyAccessChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier));
63239                 }
63240                 return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifierOrPrivateIdentifier));
63241             case 195:
63242                 if (node.flags & 32) {
63243                     return ts.updateElementAccessChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, tokenVisitor, ts.isToken), visitNode(node.argumentExpression, visitor, ts.isExpression));
63244                 }
63245                 return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression));
63246             case 196:
63247                 if (node.flags & 32) {
63248                     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));
63249                 }
63250                 return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression));
63251             case 197:
63252                 return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression));
63253             case 198:
63254                 return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral));
63255             case 199:
63256                 return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression));
63257             case 200:
63258                 return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression));
63259             case 201:
63260                 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));
63261             case 202:
63262                 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));
63263             case 203:
63264                 return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression));
63265             case 204:
63266                 return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression));
63267             case 205:
63268                 return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression));
63269             case 206:
63270                 return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression));
63271             case 207:
63272                 return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression));
63273             case 208:
63274                 return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression));
63275             case 209:
63276                 return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, tokenVisitor, ts.isToken));
63277             case 210:
63278                 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));
63279             case 211:
63280                 return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan));
63281             case 212:
63282                 return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression));
63283             case 213:
63284                 return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression));
63285             case 214:
63286                 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));
63287             case 216:
63288                 return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression));
63289             case 217:
63290                 return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode));
63291             case 218:
63292                 return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression));
63293             case 219:
63294                 return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier));
63295             case 221:
63296                 return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail));
63297             case 223:
63298                 return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement));
63299             case 225:
63300                 return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList));
63301             case 226:
63302                 return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression));
63303             case 227:
63304                 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));
63305             case 228:
63306                 return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression));
63307             case 229:
63308                 return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock));
63309             case 230:
63310                 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));
63311             case 231:
63312                 return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock));
63313             case 232:
63314                 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));
63315             case 233:
63316                 return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier));
63317             case 234:
63318                 return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier));
63319             case 235:
63320                 return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression));
63321             case 236:
63322                 return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock));
63323             case 237:
63324                 return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock));
63325             case 238:
63326                 return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock));
63327             case 239:
63328                 return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression));
63329             case 240:
63330                 return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock));
63331             case 242:
63332                 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));
63333             case 243:
63334                 return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration));
63335             case 244:
63336                 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));
63337             case 245:
63338                 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));
63339             case 246:
63340                 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));
63341             case 247:
63342                 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));
63343             case 248:
63344                 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));
63345             case 249:
63346                 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));
63347             case 250:
63348                 return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement));
63349             case 251:
63350                 return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause));
63351             case 252:
63352                 return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier));
63353             case 253:
63354                 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));
63355             case 254:
63356                 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));
63357             case 255:
63358                 return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings), node.isTypeOnly);
63359             case 256:
63360                 return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier));
63361             case 262:
63362                 return ts.updateNamespaceExport(node, visitNode(node.name, visitor, ts.isIdentifier));
63363             case 257:
63364                 return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier));
63365             case 258:
63366                 return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier));
63367             case 259:
63368                 return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression));
63369             case 260:
63370                 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);
63371             case 261:
63372                 return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier));
63373             case 263:
63374                 return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier));
63375             case 265:
63376                 return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression));
63377             case 266:
63378                 return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement));
63379             case 267:
63380                 return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes));
63381             case 268:
63382                 return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes));
63383             case 269:
63384                 return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression));
63385             case 270:
63386                 return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment));
63387             case 273:
63388                 return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression));
63389             case 274:
63390                 return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike));
63391             case 275:
63392                 return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression));
63393             case 276:
63394                 return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression));
63395             case 277:
63396                 return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement));
63397             case 278:
63398                 return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement));
63399             case 279:
63400                 return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments));
63401             case 280:
63402                 return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock));
63403             case 281:
63404                 return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression));
63405             case 282:
63406                 return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression));
63407             case 283:
63408                 return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression));
63409             case 284:
63410                 return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression));
63411             case 290:
63412                 return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context));
63413             case 326:
63414                 return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression));
63415             case 327:
63416                 return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression));
63417             default:
63418                 return node;
63419         }
63420     }
63421     ts.visitEachChild = visitEachChild;
63422     function extractSingleNode(nodes) {
63423         ts.Debug.assert(nodes.length <= 1, "Too many nodes written to output.");
63424         return ts.singleOrUndefined(nodes);
63425     }
63426 })(ts || (ts = {}));
63427 var ts;
63428 (function (ts) {
63429     function reduceNode(node, f, initial) {
63430         return node ? f(initial, node) : initial;
63431     }
63432     function reduceNodeArray(nodes, f, initial) {
63433         return nodes ? f(initial, nodes) : initial;
63434     }
63435     function reduceEachChild(node, initial, cbNode, cbNodeArray) {
63436         if (node === undefined) {
63437             return initial;
63438         }
63439         var reduceNodes = cbNodeArray ? reduceNodeArray : ts.reduceLeft;
63440         var cbNodes = cbNodeArray || cbNode;
63441         var kind = node.kind;
63442         if ((kind > 0 && kind <= 152)) {
63443             return initial;
63444         }
63445         if ((kind >= 168 && kind <= 187)) {
63446             return initial;
63447         }
63448         var result = initial;
63449         switch (node.kind) {
63450             case 222:
63451             case 224:
63452             case 215:
63453             case 241:
63454             case 325:
63455                 break;
63456             case 153:
63457                 result = reduceNode(node.left, cbNode, result);
63458                 result = reduceNode(node.right, cbNode, result);
63459                 break;
63460             case 154:
63461                 result = reduceNode(node.expression, cbNode, result);
63462                 break;
63463             case 156:
63464                 result = reduceNodes(node.decorators, cbNodes, result);
63465                 result = reduceNodes(node.modifiers, cbNodes, result);
63466                 result = reduceNode(node.name, cbNode, result);
63467                 result = reduceNode(node.type, cbNode, result);
63468                 result = reduceNode(node.initializer, cbNode, result);
63469                 break;
63470             case 157:
63471                 result = reduceNode(node.expression, cbNode, result);
63472                 break;
63473             case 158:
63474                 result = reduceNodes(node.modifiers, cbNodes, result);
63475                 result = reduceNode(node.name, cbNode, result);
63476                 result = reduceNode(node.questionToken, cbNode, result);
63477                 result = reduceNode(node.type, cbNode, result);
63478                 result = reduceNode(node.initializer, cbNode, result);
63479                 break;
63480             case 159:
63481                 result = reduceNodes(node.decorators, cbNodes, result);
63482                 result = reduceNodes(node.modifiers, cbNodes, result);
63483                 result = reduceNode(node.name, cbNode, result);
63484                 result = reduceNode(node.type, cbNode, result);
63485                 result = reduceNode(node.initializer, cbNode, result);
63486                 break;
63487             case 161:
63488                 result = reduceNodes(node.decorators, cbNodes, result);
63489                 result = reduceNodes(node.modifiers, cbNodes, result);
63490                 result = reduceNode(node.name, cbNode, result);
63491                 result = reduceNodes(node.typeParameters, cbNodes, result);
63492                 result = reduceNodes(node.parameters, cbNodes, result);
63493                 result = reduceNode(node.type, cbNode, result);
63494                 result = reduceNode(node.body, cbNode, result);
63495                 break;
63496             case 162:
63497                 result = reduceNodes(node.modifiers, cbNodes, result);
63498                 result = reduceNodes(node.parameters, cbNodes, result);
63499                 result = reduceNode(node.body, cbNode, result);
63500                 break;
63501             case 163:
63502                 result = reduceNodes(node.decorators, cbNodes, result);
63503                 result = reduceNodes(node.modifiers, cbNodes, result);
63504                 result = reduceNode(node.name, cbNode, 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 164:
63510                 result = reduceNodes(node.decorators, cbNodes, result);
63511                 result = reduceNodes(node.modifiers, cbNodes, result);
63512                 result = reduceNode(node.name, cbNode, result);
63513                 result = reduceNodes(node.parameters, cbNodes, result);
63514                 result = reduceNode(node.body, cbNode, result);
63515                 break;
63516             case 189:
63517             case 190:
63518                 result = reduceNodes(node.elements, cbNodes, result);
63519                 break;
63520             case 191:
63521                 result = reduceNode(node.propertyName, cbNode, result);
63522                 result = reduceNode(node.name, cbNode, result);
63523                 result = reduceNode(node.initializer, cbNode, result);
63524                 break;
63525             case 192:
63526                 result = reduceNodes(node.elements, cbNodes, result);
63527                 break;
63528             case 193:
63529                 result = reduceNodes(node.properties, cbNodes, result);
63530                 break;
63531             case 194:
63532                 result = reduceNode(node.expression, cbNode, result);
63533                 result = reduceNode(node.name, cbNode, result);
63534                 break;
63535             case 195:
63536                 result = reduceNode(node.expression, cbNode, result);
63537                 result = reduceNode(node.argumentExpression, cbNode, result);
63538                 break;
63539             case 196:
63540                 result = reduceNode(node.expression, cbNode, result);
63541                 result = reduceNodes(node.typeArguments, cbNodes, result);
63542                 result = reduceNodes(node.arguments, cbNodes, result);
63543                 break;
63544             case 197:
63545                 result = reduceNode(node.expression, cbNode, result);
63546                 result = reduceNodes(node.typeArguments, cbNodes, result);
63547                 result = reduceNodes(node.arguments, cbNodes, result);
63548                 break;
63549             case 198:
63550                 result = reduceNode(node.tag, cbNode, result);
63551                 result = reduceNodes(node.typeArguments, cbNodes, result);
63552                 result = reduceNode(node.template, cbNode, result);
63553                 break;
63554             case 199:
63555                 result = reduceNode(node.type, cbNode, result);
63556                 result = reduceNode(node.expression, cbNode, result);
63557                 break;
63558             case 201:
63559                 result = reduceNodes(node.modifiers, cbNodes, result);
63560                 result = reduceNode(node.name, cbNode, result);
63561                 result = reduceNodes(node.typeParameters, cbNodes, result);
63562                 result = reduceNodes(node.parameters, cbNodes, result);
63563                 result = reduceNode(node.type, cbNode, result);
63564                 result = reduceNode(node.body, cbNode, result);
63565                 break;
63566             case 202:
63567                 result = reduceNodes(node.modifiers, cbNodes, result);
63568                 result = reduceNodes(node.typeParameters, cbNodes, result);
63569                 result = reduceNodes(node.parameters, cbNodes, result);
63570                 result = reduceNode(node.type, cbNode, result);
63571                 result = reduceNode(node.body, cbNode, result);
63572                 break;
63573             case 200:
63574             case 203:
63575             case 204:
63576             case 205:
63577             case 206:
63578             case 212:
63579             case 213:
63580             case 218:
63581                 result = reduceNode(node.expression, cbNode, result);
63582                 break;
63583             case 207:
63584             case 208:
63585                 result = reduceNode(node.operand, cbNode, result);
63586                 break;
63587             case 209:
63588                 result = reduceNode(node.left, cbNode, result);
63589                 result = reduceNode(node.right, cbNode, result);
63590                 break;
63591             case 210:
63592                 result = reduceNode(node.condition, cbNode, result);
63593                 result = reduceNode(node.whenTrue, cbNode, result);
63594                 result = reduceNode(node.whenFalse, cbNode, result);
63595                 break;
63596             case 211:
63597                 result = reduceNode(node.head, cbNode, result);
63598                 result = reduceNodes(node.templateSpans, cbNodes, result);
63599                 break;
63600             case 214:
63601                 result = reduceNodes(node.modifiers, cbNodes, result);
63602                 result = reduceNode(node.name, cbNode, result);
63603                 result = reduceNodes(node.typeParameters, cbNodes, result);
63604                 result = reduceNodes(node.heritageClauses, cbNodes, result);
63605                 result = reduceNodes(node.members, cbNodes, result);
63606                 break;
63607             case 216:
63608                 result = reduceNode(node.expression, cbNode, result);
63609                 result = reduceNodes(node.typeArguments, cbNodes, result);
63610                 break;
63611             case 217:
63612                 result = reduceNode(node.expression, cbNode, result);
63613                 result = reduceNode(node.type, cbNode, result);
63614                 break;
63615             case 221:
63616                 result = reduceNode(node.expression, cbNode, result);
63617                 result = reduceNode(node.literal, cbNode, result);
63618                 break;
63619             case 223:
63620                 result = reduceNodes(node.statements, cbNodes, result);
63621                 break;
63622             case 225:
63623                 result = reduceNodes(node.modifiers, cbNodes, result);
63624                 result = reduceNode(node.declarationList, cbNode, result);
63625                 break;
63626             case 226:
63627                 result = reduceNode(node.expression, cbNode, result);
63628                 break;
63629             case 227:
63630                 result = reduceNode(node.expression, cbNode, result);
63631                 result = reduceNode(node.thenStatement, cbNode, result);
63632                 result = reduceNode(node.elseStatement, cbNode, result);
63633                 break;
63634             case 228:
63635                 result = reduceNode(node.statement, cbNode, result);
63636                 result = reduceNode(node.expression, cbNode, result);
63637                 break;
63638             case 229:
63639             case 236:
63640                 result = reduceNode(node.expression, cbNode, result);
63641                 result = reduceNode(node.statement, cbNode, result);
63642                 break;
63643             case 230:
63644                 result = reduceNode(node.initializer, cbNode, result);
63645                 result = reduceNode(node.condition, cbNode, result);
63646                 result = reduceNode(node.incrementor, cbNode, result);
63647                 result = reduceNode(node.statement, cbNode, result);
63648                 break;
63649             case 231:
63650             case 232:
63651                 result = reduceNode(node.initializer, cbNode, result);
63652                 result = reduceNode(node.expression, cbNode, result);
63653                 result = reduceNode(node.statement, cbNode, result);
63654                 break;
63655             case 235:
63656             case 239:
63657                 result = reduceNode(node.expression, cbNode, result);
63658                 break;
63659             case 237:
63660                 result = reduceNode(node.expression, cbNode, result);
63661                 result = reduceNode(node.caseBlock, cbNode, result);
63662                 break;
63663             case 238:
63664                 result = reduceNode(node.label, cbNode, result);
63665                 result = reduceNode(node.statement, cbNode, result);
63666                 break;
63667             case 240:
63668                 result = reduceNode(node.tryBlock, cbNode, result);
63669                 result = reduceNode(node.catchClause, cbNode, result);
63670                 result = reduceNode(node.finallyBlock, cbNode, result);
63671                 break;
63672             case 242:
63673                 result = reduceNode(node.name, cbNode, result);
63674                 result = reduceNode(node.type, cbNode, result);
63675                 result = reduceNode(node.initializer, cbNode, result);
63676                 break;
63677             case 243:
63678                 result = reduceNodes(node.declarations, cbNodes, result);
63679                 break;
63680             case 244:
63681                 result = reduceNodes(node.decorators, cbNodes, result);
63682                 result = reduceNodes(node.modifiers, cbNodes, result);
63683                 result = reduceNode(node.name, cbNode, result);
63684                 result = reduceNodes(node.typeParameters, cbNodes, result);
63685                 result = reduceNodes(node.parameters, cbNodes, result);
63686                 result = reduceNode(node.type, cbNode, result);
63687                 result = reduceNode(node.body, cbNode, result);
63688                 break;
63689             case 245:
63690                 result = reduceNodes(node.decorators, cbNodes, result);
63691                 result = reduceNodes(node.modifiers, cbNodes, result);
63692                 result = reduceNode(node.name, cbNode, result);
63693                 result = reduceNodes(node.typeParameters, cbNodes, result);
63694                 result = reduceNodes(node.heritageClauses, cbNodes, result);
63695                 result = reduceNodes(node.members, cbNodes, result);
63696                 break;
63697             case 248:
63698                 result = reduceNodes(node.decorators, cbNodes, result);
63699                 result = reduceNodes(node.modifiers, cbNodes, result);
63700                 result = reduceNode(node.name, cbNode, result);
63701                 result = reduceNodes(node.members, cbNodes, result);
63702                 break;
63703             case 249:
63704                 result = reduceNodes(node.decorators, cbNodes, result);
63705                 result = reduceNodes(node.modifiers, cbNodes, result);
63706                 result = reduceNode(node.name, cbNode, result);
63707                 result = reduceNode(node.body, cbNode, result);
63708                 break;
63709             case 250:
63710                 result = reduceNodes(node.statements, cbNodes, result);
63711                 break;
63712             case 251:
63713                 result = reduceNodes(node.clauses, cbNodes, result);
63714                 break;
63715             case 253:
63716                 result = reduceNodes(node.decorators, cbNodes, result);
63717                 result = reduceNodes(node.modifiers, cbNodes, result);
63718                 result = reduceNode(node.name, cbNode, result);
63719                 result = reduceNode(node.moduleReference, cbNode, result);
63720                 break;
63721             case 254:
63722                 result = reduceNodes(node.decorators, cbNodes, result);
63723                 result = reduceNodes(node.modifiers, cbNodes, result);
63724                 result = reduceNode(node.importClause, cbNode, result);
63725                 result = reduceNode(node.moduleSpecifier, cbNode, result);
63726                 break;
63727             case 255:
63728                 result = reduceNode(node.name, cbNode, result);
63729                 result = reduceNode(node.namedBindings, cbNode, result);
63730                 break;
63731             case 256:
63732                 result = reduceNode(node.name, cbNode, result);
63733                 break;
63734             case 262:
63735                 result = reduceNode(node.name, cbNode, result);
63736                 break;
63737             case 257:
63738             case 261:
63739                 result = reduceNodes(node.elements, cbNodes, result);
63740                 break;
63741             case 258:
63742             case 263:
63743                 result = reduceNode(node.propertyName, cbNode, result);
63744                 result = reduceNode(node.name, cbNode, result);
63745                 break;
63746             case 259:
63747                 result = ts.reduceLeft(node.decorators, cbNode, result);
63748                 result = ts.reduceLeft(node.modifiers, cbNode, result);
63749                 result = reduceNode(node.expression, cbNode, result);
63750                 break;
63751             case 260:
63752                 result = ts.reduceLeft(node.decorators, cbNode, result);
63753                 result = ts.reduceLeft(node.modifiers, cbNode, result);
63754                 result = reduceNode(node.exportClause, cbNode, result);
63755                 result = reduceNode(node.moduleSpecifier, cbNode, result);
63756                 break;
63757             case 265:
63758                 result = reduceNode(node.expression, cbNode, result);
63759                 break;
63760             case 266:
63761                 result = reduceNode(node.openingElement, cbNode, result);
63762                 result = ts.reduceLeft(node.children, cbNode, result);
63763                 result = reduceNode(node.closingElement, cbNode, result);
63764                 break;
63765             case 270:
63766                 result = reduceNode(node.openingFragment, cbNode, result);
63767                 result = ts.reduceLeft(node.children, cbNode, result);
63768                 result = reduceNode(node.closingFragment, cbNode, result);
63769                 break;
63770             case 267:
63771             case 268:
63772                 result = reduceNode(node.tagName, cbNode, result);
63773                 result = reduceNodes(node.typeArguments, cbNode, result);
63774                 result = reduceNode(node.attributes, cbNode, result);
63775                 break;
63776             case 274:
63777                 result = reduceNodes(node.properties, cbNodes, result);
63778                 break;
63779             case 269:
63780                 result = reduceNode(node.tagName, cbNode, result);
63781                 break;
63782             case 273:
63783                 result = reduceNode(node.name, cbNode, result);
63784                 result = reduceNode(node.initializer, cbNode, result);
63785                 break;
63786             case 275:
63787                 result = reduceNode(node.expression, cbNode, result);
63788                 break;
63789             case 276:
63790                 result = reduceNode(node.expression, cbNode, result);
63791                 break;
63792             case 277:
63793                 result = reduceNode(node.expression, cbNode, result);
63794             case 278:
63795                 result = reduceNodes(node.statements, cbNodes, result);
63796                 break;
63797             case 279:
63798                 result = reduceNodes(node.types, cbNodes, result);
63799                 break;
63800             case 280:
63801                 result = reduceNode(node.variableDeclaration, cbNode, result);
63802                 result = reduceNode(node.block, cbNode, result);
63803                 break;
63804             case 281:
63805                 result = reduceNode(node.name, cbNode, result);
63806                 result = reduceNode(node.initializer, cbNode, result);
63807                 break;
63808             case 282:
63809                 result = reduceNode(node.name, cbNode, result);
63810                 result = reduceNode(node.objectAssignmentInitializer, cbNode, result);
63811                 break;
63812             case 283:
63813                 result = reduceNode(node.expression, cbNode, result);
63814                 break;
63815             case 284:
63816                 result = reduceNode(node.name, cbNode, result);
63817                 result = reduceNode(node.initializer, cbNode, result);
63818                 break;
63819             case 290:
63820                 result = reduceNodes(node.statements, cbNodes, result);
63821                 break;
63822             case 326:
63823                 result = reduceNode(node.expression, cbNode, result);
63824                 break;
63825             case 327:
63826                 result = reduceNodes(node.elements, cbNodes, result);
63827                 break;
63828             default:
63829                 break;
63830         }
63831         return result;
63832     }
63833     ts.reduceEachChild = reduceEachChild;
63834     function findSpanEnd(array, test, start) {
63835         var i = start;
63836         while (i < array.length && test(array[i])) {
63837             i++;
63838         }
63839         return i;
63840     }
63841     function mergeLexicalEnvironment(statements, declarations) {
63842         if (!ts.some(declarations)) {
63843             return statements;
63844         }
63845         var leftStandardPrologueEnd = findSpanEnd(statements, ts.isPrologueDirective, 0);
63846         var leftHoistedFunctionsEnd = findSpanEnd(statements, ts.isHoistedFunction, leftStandardPrologueEnd);
63847         var leftHoistedVariablesEnd = findSpanEnd(statements, ts.isHoistedVariableStatement, leftHoistedFunctionsEnd);
63848         var rightStandardPrologueEnd = findSpanEnd(declarations, ts.isPrologueDirective, 0);
63849         var rightHoistedFunctionsEnd = findSpanEnd(declarations, ts.isHoistedFunction, rightStandardPrologueEnd);
63850         var rightHoistedVariablesEnd = findSpanEnd(declarations, ts.isHoistedVariableStatement, rightHoistedFunctionsEnd);
63851         var rightCustomPrologueEnd = findSpanEnd(declarations, ts.isCustomPrologue, rightHoistedVariablesEnd);
63852         ts.Debug.assert(rightCustomPrologueEnd === declarations.length, "Expected declarations to be valid standard or custom prologues");
63853         var left = ts.isNodeArray(statements) ? statements.slice() : statements;
63854         if (rightCustomPrologueEnd > rightHoistedVariablesEnd) {
63855             left.splice.apply(left, __spreadArrays([leftHoistedVariablesEnd, 0], declarations.slice(rightHoistedVariablesEnd, rightCustomPrologueEnd)));
63856         }
63857         if (rightHoistedVariablesEnd > rightHoistedFunctionsEnd) {
63858             left.splice.apply(left, __spreadArrays([leftHoistedFunctionsEnd, 0], declarations.slice(rightHoistedFunctionsEnd, rightHoistedVariablesEnd)));
63859         }
63860         if (rightHoistedFunctionsEnd > rightStandardPrologueEnd) {
63861             left.splice.apply(left, __spreadArrays([leftStandardPrologueEnd, 0], declarations.slice(rightStandardPrologueEnd, rightHoistedFunctionsEnd)));
63862         }
63863         if (rightStandardPrologueEnd > 0) {
63864             if (leftStandardPrologueEnd === 0) {
63865                 left.splice.apply(left, __spreadArrays([0, 0], declarations.slice(0, rightStandardPrologueEnd)));
63866             }
63867             else {
63868                 var leftPrologues = ts.createMap();
63869                 for (var i = 0; i < leftStandardPrologueEnd; i++) {
63870                     var leftPrologue = statements[i];
63871                     leftPrologues.set(leftPrologue.expression.text, true);
63872                 }
63873                 for (var i = rightStandardPrologueEnd - 1; i >= 0; i--) {
63874                     var rightPrologue = declarations[i];
63875                     if (!leftPrologues.has(rightPrologue.expression.text)) {
63876                         left.unshift(rightPrologue);
63877                     }
63878                 }
63879             }
63880         }
63881         if (ts.isNodeArray(statements)) {
63882             return ts.setTextRange(ts.createNodeArray(left, statements.hasTrailingComma), statements);
63883         }
63884         return statements;
63885     }
63886     ts.mergeLexicalEnvironment = mergeLexicalEnvironment;
63887     function liftToBlock(nodes) {
63888         ts.Debug.assert(ts.every(nodes, ts.isStatement), "Cannot lift nodes to a Block.");
63889         return ts.singleOrUndefined(nodes) || ts.createBlock(nodes);
63890     }
63891     ts.liftToBlock = liftToBlock;
63892     function aggregateTransformFlags(node) {
63893         aggregateTransformFlagsForNode(node);
63894         return node;
63895     }
63896     ts.aggregateTransformFlags = aggregateTransformFlags;
63897     function aggregateTransformFlagsForNode(node) {
63898         if (node === undefined) {
63899             return 0;
63900         }
63901         if (node.transformFlags & 536870912) {
63902             return node.transformFlags & ~ts.getTransformFlagsSubtreeExclusions(node.kind);
63903         }
63904         var subtreeFlags = aggregateTransformFlagsForSubtree(node);
63905         return ts.computeTransformFlagsForNode(node, subtreeFlags);
63906     }
63907     function aggregateTransformFlagsForNodeArray(nodes) {
63908         if (nodes === undefined) {
63909             return 0;
63910         }
63911         var subtreeFlags = 0;
63912         var nodeArrayFlags = 0;
63913         for (var _i = 0, nodes_3 = nodes; _i < nodes_3.length; _i++) {
63914             var node = nodes_3[_i];
63915             subtreeFlags |= aggregateTransformFlagsForNode(node);
63916             nodeArrayFlags |= node.transformFlags & ~536870912;
63917         }
63918         nodes.transformFlags = nodeArrayFlags | 536870912;
63919         return subtreeFlags;
63920     }
63921     function aggregateTransformFlagsForSubtree(node) {
63922         if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 216)) {
63923             return 0;
63924         }
63925         return reduceEachChild(node, 0, aggregateTransformFlagsForChildNode, aggregateTransformFlagsForChildNodes);
63926     }
63927     function aggregateTransformFlagsForChildNode(transformFlags, node) {
63928         return transformFlags | aggregateTransformFlagsForNode(node);
63929     }
63930     function aggregateTransformFlagsForChildNodes(transformFlags, nodes) {
63931         return transformFlags | aggregateTransformFlagsForNodeArray(nodes);
63932     }
63933 })(ts || (ts = {}));
63934 var ts;
63935 (function (ts) {
63936     function createSourceMapGenerator(host, file, sourceRoot, sourcesDirectoryPath, generatorOptions) {
63937         var _a = generatorOptions.extendedDiagnostics
63938             ? ts.performance.createTimer("Source Map", "beforeSourcemap", "afterSourcemap")
63939             : ts.performance.nullTimer, enter = _a.enter, exit = _a.exit;
63940         var rawSources = [];
63941         var sources = [];
63942         var sourceToSourceIndexMap = ts.createMap();
63943         var sourcesContent;
63944         var names = [];
63945         var nameToNameIndexMap;
63946         var mappings = "";
63947         var lastGeneratedLine = 0;
63948         var lastGeneratedCharacter = 0;
63949         var lastSourceIndex = 0;
63950         var lastSourceLine = 0;
63951         var lastSourceCharacter = 0;
63952         var lastNameIndex = 0;
63953         var hasLast = false;
63954         var pendingGeneratedLine = 0;
63955         var pendingGeneratedCharacter = 0;
63956         var pendingSourceIndex = 0;
63957         var pendingSourceLine = 0;
63958         var pendingSourceCharacter = 0;
63959         var pendingNameIndex = 0;
63960         var hasPending = false;
63961         var hasPendingSource = false;
63962         var hasPendingName = false;
63963         return {
63964             getSources: function () { return rawSources; },
63965             addSource: addSource,
63966             setSourceContent: setSourceContent,
63967             addName: addName,
63968             addMapping: addMapping,
63969             appendSourceMap: appendSourceMap,
63970             toJSON: toJSON,
63971             toString: function () { return JSON.stringify(toJSON()); }
63972         };
63973         function addSource(fileName) {
63974             enter();
63975             var source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, true);
63976             var sourceIndex = sourceToSourceIndexMap.get(source);
63977             if (sourceIndex === undefined) {
63978                 sourceIndex = sources.length;
63979                 sources.push(source);
63980                 rawSources.push(fileName);
63981                 sourceToSourceIndexMap.set(source, sourceIndex);
63982             }
63983             exit();
63984             return sourceIndex;
63985         }
63986         function setSourceContent(sourceIndex, content) {
63987             enter();
63988             if (content !== null) {
63989                 if (!sourcesContent)
63990                     sourcesContent = [];
63991                 while (sourcesContent.length < sourceIndex) {
63992                     sourcesContent.push(null);
63993                 }
63994                 sourcesContent[sourceIndex] = content;
63995             }
63996             exit();
63997         }
63998         function addName(name) {
63999             enter();
64000             if (!nameToNameIndexMap)
64001                 nameToNameIndexMap = ts.createMap();
64002             var nameIndex = nameToNameIndexMap.get(name);
64003             if (nameIndex === undefined) {
64004                 nameIndex = names.length;
64005                 names.push(name);
64006                 nameToNameIndexMap.set(name, nameIndex);
64007             }
64008             exit();
64009             return nameIndex;
64010         }
64011         function isNewGeneratedPosition(generatedLine, generatedCharacter) {
64012             return !hasPending
64013                 || pendingGeneratedLine !== generatedLine
64014                 || pendingGeneratedCharacter !== generatedCharacter;
64015         }
64016         function isBacktrackingSourcePosition(sourceIndex, sourceLine, sourceCharacter) {
64017             return sourceIndex !== undefined
64018                 && sourceLine !== undefined
64019                 && sourceCharacter !== undefined
64020                 && pendingSourceIndex === sourceIndex
64021                 && (pendingSourceLine > sourceLine
64022                     || pendingSourceLine === sourceLine && pendingSourceCharacter > sourceCharacter);
64023         }
64024         function addMapping(generatedLine, generatedCharacter, sourceIndex, sourceLine, sourceCharacter, nameIndex) {
64025             ts.Debug.assert(generatedLine >= pendingGeneratedLine, "generatedLine cannot backtrack");
64026             ts.Debug.assert(generatedCharacter >= 0, "generatedCharacter cannot be negative");
64027             ts.Debug.assert(sourceIndex === undefined || sourceIndex >= 0, "sourceIndex cannot be negative");
64028             ts.Debug.assert(sourceLine === undefined || sourceLine >= 0, "sourceLine cannot be negative");
64029             ts.Debug.assert(sourceCharacter === undefined || sourceCharacter >= 0, "sourceCharacter cannot be negative");
64030             enter();
64031             if (isNewGeneratedPosition(generatedLine, generatedCharacter) ||
64032                 isBacktrackingSourcePosition(sourceIndex, sourceLine, sourceCharacter)) {
64033                 commitPendingMapping();
64034                 pendingGeneratedLine = generatedLine;
64035                 pendingGeneratedCharacter = generatedCharacter;
64036                 hasPendingSource = false;
64037                 hasPendingName = false;
64038                 hasPending = true;
64039             }
64040             if (sourceIndex !== undefined && sourceLine !== undefined && sourceCharacter !== undefined) {
64041                 pendingSourceIndex = sourceIndex;
64042                 pendingSourceLine = sourceLine;
64043                 pendingSourceCharacter = sourceCharacter;
64044                 hasPendingSource = true;
64045                 if (nameIndex !== undefined) {
64046                     pendingNameIndex = nameIndex;
64047                     hasPendingName = true;
64048                 }
64049             }
64050             exit();
64051         }
64052         function appendSourceMap(generatedLine, generatedCharacter, map, sourceMapPath, start, end) {
64053             ts.Debug.assert(generatedLine >= pendingGeneratedLine, "generatedLine cannot backtrack");
64054             ts.Debug.assert(generatedCharacter >= 0, "generatedCharacter cannot be negative");
64055             enter();
64056             var sourceIndexToNewSourceIndexMap = [];
64057             var nameIndexToNewNameIndexMap;
64058             var mappingIterator = decodeMappings(map.mappings);
64059             for (var iterResult = mappingIterator.next(); !iterResult.done; iterResult = mappingIterator.next()) {
64060                 var raw = iterResult.value;
64061                 if (end && (raw.generatedLine > end.line ||
64062                     (raw.generatedLine === end.line && raw.generatedCharacter > end.character))) {
64063                     break;
64064                 }
64065                 if (start && (raw.generatedLine < start.line ||
64066                     (start.line === raw.generatedLine && raw.generatedCharacter < start.character))) {
64067                     continue;
64068                 }
64069                 var newSourceIndex = void 0;
64070                 var newSourceLine = void 0;
64071                 var newSourceCharacter = void 0;
64072                 var newNameIndex = void 0;
64073                 if (raw.sourceIndex !== undefined) {
64074                     newSourceIndex = sourceIndexToNewSourceIndexMap[raw.sourceIndex];
64075                     if (newSourceIndex === undefined) {
64076                         var rawPath = map.sources[raw.sourceIndex];
64077                         var relativePath = map.sourceRoot ? ts.combinePaths(map.sourceRoot, rawPath) : rawPath;
64078                         var combinedPath = ts.combinePaths(ts.getDirectoryPath(sourceMapPath), relativePath);
64079                         sourceIndexToNewSourceIndexMap[raw.sourceIndex] = newSourceIndex = addSource(combinedPath);
64080                         if (map.sourcesContent && typeof map.sourcesContent[raw.sourceIndex] === "string") {
64081                             setSourceContent(newSourceIndex, map.sourcesContent[raw.sourceIndex]);
64082                         }
64083                     }
64084                     newSourceLine = raw.sourceLine;
64085                     newSourceCharacter = raw.sourceCharacter;
64086                     if (map.names && raw.nameIndex !== undefined) {
64087                         if (!nameIndexToNewNameIndexMap)
64088                             nameIndexToNewNameIndexMap = [];
64089                         newNameIndex = nameIndexToNewNameIndexMap[raw.nameIndex];
64090                         if (newNameIndex === undefined) {
64091                             nameIndexToNewNameIndexMap[raw.nameIndex] = newNameIndex = addName(map.names[raw.nameIndex]);
64092                         }
64093                     }
64094                 }
64095                 var rawGeneratedLine = raw.generatedLine - (start ? start.line : 0);
64096                 var newGeneratedLine = rawGeneratedLine + generatedLine;
64097                 var rawGeneratedCharacter = start && start.line === raw.generatedLine ? raw.generatedCharacter - start.character : raw.generatedCharacter;
64098                 var newGeneratedCharacter = rawGeneratedLine === 0 ? rawGeneratedCharacter + generatedCharacter : rawGeneratedCharacter;
64099                 addMapping(newGeneratedLine, newGeneratedCharacter, newSourceIndex, newSourceLine, newSourceCharacter, newNameIndex);
64100             }
64101             exit();
64102         }
64103         function shouldCommitMapping() {
64104             return !hasLast
64105                 || lastGeneratedLine !== pendingGeneratedLine
64106                 || lastGeneratedCharacter !== pendingGeneratedCharacter
64107                 || lastSourceIndex !== pendingSourceIndex
64108                 || lastSourceLine !== pendingSourceLine
64109                 || lastSourceCharacter !== pendingSourceCharacter
64110                 || lastNameIndex !== pendingNameIndex;
64111         }
64112         function commitPendingMapping() {
64113             if (!hasPending || !shouldCommitMapping()) {
64114                 return;
64115             }
64116             enter();
64117             if (lastGeneratedLine < pendingGeneratedLine) {
64118                 do {
64119                     mappings += ";";
64120                     lastGeneratedLine++;
64121                     lastGeneratedCharacter = 0;
64122                 } while (lastGeneratedLine < pendingGeneratedLine);
64123             }
64124             else {
64125                 ts.Debug.assertEqual(lastGeneratedLine, pendingGeneratedLine, "generatedLine cannot backtrack");
64126                 if (hasLast) {
64127                     mappings += ",";
64128                 }
64129             }
64130             mappings += base64VLQFormatEncode(pendingGeneratedCharacter - lastGeneratedCharacter);
64131             lastGeneratedCharacter = pendingGeneratedCharacter;
64132             if (hasPendingSource) {
64133                 mappings += base64VLQFormatEncode(pendingSourceIndex - lastSourceIndex);
64134                 lastSourceIndex = pendingSourceIndex;
64135                 mappings += base64VLQFormatEncode(pendingSourceLine - lastSourceLine);
64136                 lastSourceLine = pendingSourceLine;
64137                 mappings += base64VLQFormatEncode(pendingSourceCharacter - lastSourceCharacter);
64138                 lastSourceCharacter = pendingSourceCharacter;
64139                 if (hasPendingName) {
64140                     mappings += base64VLQFormatEncode(pendingNameIndex - lastNameIndex);
64141                     lastNameIndex = pendingNameIndex;
64142                 }
64143             }
64144             hasLast = true;
64145             exit();
64146         }
64147         function toJSON() {
64148             commitPendingMapping();
64149             return {
64150                 version: 3,
64151                 file: file,
64152                 sourceRoot: sourceRoot,
64153                 sources: sources,
64154                 names: names,
64155                 mappings: mappings,
64156                 sourcesContent: sourcesContent,
64157             };
64158         }
64159     }
64160     ts.createSourceMapGenerator = createSourceMapGenerator;
64161     var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\s*$/;
64162     var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/;
64163     function getLineInfo(text, lineStarts) {
64164         return {
64165             getLineCount: function () { return lineStarts.length; },
64166             getLineText: function (line) { return text.substring(lineStarts[line], lineStarts[line + 1]); }
64167         };
64168     }
64169     ts.getLineInfo = getLineInfo;
64170     function tryGetSourceMappingURL(lineInfo) {
64171         for (var index = lineInfo.getLineCount() - 1; index >= 0; index--) {
64172             var line = lineInfo.getLineText(index);
64173             var comment = sourceMapCommentRegExp.exec(line);
64174             if (comment) {
64175                 return comment[1];
64176             }
64177             else if (!line.match(whitespaceOrMapCommentRegExp)) {
64178                 break;
64179             }
64180         }
64181     }
64182     ts.tryGetSourceMappingURL = tryGetSourceMappingURL;
64183     function isStringOrNull(x) {
64184         return typeof x === "string" || x === null;
64185     }
64186     function isRawSourceMap(x) {
64187         return x !== null
64188             && typeof x === "object"
64189             && x.version === 3
64190             && typeof x.file === "string"
64191             && typeof x.mappings === "string"
64192             && ts.isArray(x.sources) && ts.every(x.sources, ts.isString)
64193             && (x.sourceRoot === undefined || x.sourceRoot === null || typeof x.sourceRoot === "string")
64194             && (x.sourcesContent === undefined || x.sourcesContent === null || ts.isArray(x.sourcesContent) && ts.every(x.sourcesContent, isStringOrNull))
64195             && (x.names === undefined || x.names === null || ts.isArray(x.names) && ts.every(x.names, ts.isString));
64196     }
64197     ts.isRawSourceMap = isRawSourceMap;
64198     function tryParseRawSourceMap(text) {
64199         try {
64200             var parsed = JSON.parse(text);
64201             if (isRawSourceMap(parsed)) {
64202                 return parsed;
64203             }
64204         }
64205         catch (_a) {
64206         }
64207         return undefined;
64208     }
64209     ts.tryParseRawSourceMap = tryParseRawSourceMap;
64210     function decodeMappings(mappings) {
64211         var done = false;
64212         var pos = 0;
64213         var generatedLine = 0;
64214         var generatedCharacter = 0;
64215         var sourceIndex = 0;
64216         var sourceLine = 0;
64217         var sourceCharacter = 0;
64218         var nameIndex = 0;
64219         var error;
64220         return {
64221             get pos() { return pos; },
64222             get error() { return error; },
64223             get state() { return captureMapping(true, true); },
64224             next: function () {
64225                 while (!done && pos < mappings.length) {
64226                     var ch = mappings.charCodeAt(pos);
64227                     if (ch === 59) {
64228                         generatedLine++;
64229                         generatedCharacter = 0;
64230                         pos++;
64231                         continue;
64232                     }
64233                     if (ch === 44) {
64234                         pos++;
64235                         continue;
64236                     }
64237                     var hasSource = false;
64238                     var hasName = false;
64239                     generatedCharacter += base64VLQFormatDecode();
64240                     if (hasReportedError())
64241                         return stopIterating();
64242                     if (generatedCharacter < 0)
64243                         return setErrorAndStopIterating("Invalid generatedCharacter found");
64244                     if (!isSourceMappingSegmentEnd()) {
64245                         hasSource = true;
64246                         sourceIndex += base64VLQFormatDecode();
64247                         if (hasReportedError())
64248                             return stopIterating();
64249                         if (sourceIndex < 0)
64250                             return setErrorAndStopIterating("Invalid sourceIndex found");
64251                         if (isSourceMappingSegmentEnd())
64252                             return setErrorAndStopIterating("Unsupported Format: No entries after sourceIndex");
64253                         sourceLine += base64VLQFormatDecode();
64254                         if (hasReportedError())
64255                             return stopIterating();
64256                         if (sourceLine < 0)
64257                             return setErrorAndStopIterating("Invalid sourceLine found");
64258                         if (isSourceMappingSegmentEnd())
64259                             return setErrorAndStopIterating("Unsupported Format: No entries after sourceLine");
64260                         sourceCharacter += base64VLQFormatDecode();
64261                         if (hasReportedError())
64262                             return stopIterating();
64263                         if (sourceCharacter < 0)
64264                             return setErrorAndStopIterating("Invalid sourceCharacter found");
64265                         if (!isSourceMappingSegmentEnd()) {
64266                             hasName = true;
64267                             nameIndex += base64VLQFormatDecode();
64268                             if (hasReportedError())
64269                                 return stopIterating();
64270                             if (nameIndex < 0)
64271                                 return setErrorAndStopIterating("Invalid nameIndex found");
64272                             if (!isSourceMappingSegmentEnd())
64273                                 return setErrorAndStopIterating("Unsupported Error Format: Entries after nameIndex");
64274                         }
64275                     }
64276                     return { value: captureMapping(hasSource, hasName), done: done };
64277                 }
64278                 return stopIterating();
64279             }
64280         };
64281         function captureMapping(hasSource, hasName) {
64282             return {
64283                 generatedLine: generatedLine,
64284                 generatedCharacter: generatedCharacter,
64285                 sourceIndex: hasSource ? sourceIndex : undefined,
64286                 sourceLine: hasSource ? sourceLine : undefined,
64287                 sourceCharacter: hasSource ? sourceCharacter : undefined,
64288                 nameIndex: hasName ? nameIndex : undefined
64289             };
64290         }
64291         function stopIterating() {
64292             done = true;
64293             return { value: undefined, done: true };
64294         }
64295         function setError(message) {
64296             if (error === undefined) {
64297                 error = message;
64298             }
64299         }
64300         function setErrorAndStopIterating(message) {
64301             setError(message);
64302             return stopIterating();
64303         }
64304         function hasReportedError() {
64305             return error !== undefined;
64306         }
64307         function isSourceMappingSegmentEnd() {
64308             return (pos === mappings.length ||
64309                 mappings.charCodeAt(pos) === 44 ||
64310                 mappings.charCodeAt(pos) === 59);
64311         }
64312         function base64VLQFormatDecode() {
64313             var moreDigits = true;
64314             var shiftCount = 0;
64315             var value = 0;
64316             for (; moreDigits; pos++) {
64317                 if (pos >= mappings.length)
64318                     return setError("Error in decoding base64VLQFormatDecode, past the mapping string"), -1;
64319                 var currentByte = base64FormatDecode(mappings.charCodeAt(pos));
64320                 if (currentByte === -1)
64321                     return setError("Invalid character in VLQ"), -1;
64322                 moreDigits = (currentByte & 32) !== 0;
64323                 value = value | ((currentByte & 31) << shiftCount);
64324                 shiftCount += 5;
64325             }
64326             if ((value & 1) === 0) {
64327                 value = value >> 1;
64328             }
64329             else {
64330                 value = value >> 1;
64331                 value = -value;
64332             }
64333             return value;
64334         }
64335     }
64336     ts.decodeMappings = decodeMappings;
64337     function sameMapping(left, right) {
64338         return left === right
64339             || left.generatedLine === right.generatedLine
64340                 && left.generatedCharacter === right.generatedCharacter
64341                 && left.sourceIndex === right.sourceIndex
64342                 && left.sourceLine === right.sourceLine
64343                 && left.sourceCharacter === right.sourceCharacter
64344                 && left.nameIndex === right.nameIndex;
64345     }
64346     ts.sameMapping = sameMapping;
64347     function isSourceMapping(mapping) {
64348         return mapping.sourceIndex !== undefined
64349             && mapping.sourceLine !== undefined
64350             && mapping.sourceCharacter !== undefined;
64351     }
64352     ts.isSourceMapping = isSourceMapping;
64353     function base64FormatEncode(value) {
64354         return value >= 0 && value < 26 ? 65 + value :
64355             value >= 26 && value < 52 ? 97 + value - 26 :
64356                 value >= 52 && value < 62 ? 48 + value - 52 :
64357                     value === 62 ? 43 :
64358                         value === 63 ? 47 :
64359                             ts.Debug.fail(value + ": not a base64 value");
64360     }
64361     function base64FormatDecode(ch) {
64362         return ch >= 65 && ch <= 90 ? ch - 65 :
64363             ch >= 97 && ch <= 122 ? ch - 97 + 26 :
64364                 ch >= 48 && ch <= 57 ? ch - 48 + 52 :
64365                     ch === 43 ? 62 :
64366                         ch === 47 ? 63 :
64367                             -1;
64368     }
64369     function base64VLQFormatEncode(inValue) {
64370         if (inValue < 0) {
64371             inValue = ((-inValue) << 1) + 1;
64372         }
64373         else {
64374             inValue = inValue << 1;
64375         }
64376         var encodedStr = "";
64377         do {
64378             var currentDigit = inValue & 31;
64379             inValue = inValue >> 5;
64380             if (inValue > 0) {
64381                 currentDigit = currentDigit | 32;
64382             }
64383             encodedStr = encodedStr + String.fromCharCode(base64FormatEncode(currentDigit));
64384         } while (inValue > 0);
64385         return encodedStr;
64386     }
64387     function isSourceMappedPosition(value) {
64388         return value.sourceIndex !== undefined
64389             && value.sourcePosition !== undefined;
64390     }
64391     function sameMappedPosition(left, right) {
64392         return left.generatedPosition === right.generatedPosition
64393             && left.sourceIndex === right.sourceIndex
64394             && left.sourcePosition === right.sourcePosition;
64395     }
64396     function compareSourcePositions(left, right) {
64397         ts.Debug.assert(left.sourceIndex === right.sourceIndex);
64398         return ts.compareValues(left.sourcePosition, right.sourcePosition);
64399     }
64400     function compareGeneratedPositions(left, right) {
64401         return ts.compareValues(left.generatedPosition, right.generatedPosition);
64402     }
64403     function getSourcePositionOfMapping(value) {
64404         return value.sourcePosition;
64405     }
64406     function getGeneratedPositionOfMapping(value) {
64407         return value.generatedPosition;
64408     }
64409     function createDocumentPositionMapper(host, map, mapPath) {
64410         var mapDirectory = ts.getDirectoryPath(mapPath);
64411         var sourceRoot = map.sourceRoot ? ts.getNormalizedAbsolutePath(map.sourceRoot, mapDirectory) : mapDirectory;
64412         var generatedAbsoluteFilePath = ts.getNormalizedAbsolutePath(map.file, mapDirectory);
64413         var generatedFile = host.getSourceFileLike(generatedAbsoluteFilePath);
64414         var sourceFileAbsolutePaths = map.sources.map(function (source) { return ts.getNormalizedAbsolutePath(source, sourceRoot); });
64415         var sourceToSourceIndexMap = ts.createMapFromEntries(sourceFileAbsolutePaths.map(function (source, i) { return [host.getCanonicalFileName(source), i]; }));
64416         var decodedMappings;
64417         var generatedMappings;
64418         var sourceMappings;
64419         return {
64420             getSourcePosition: getSourcePosition,
64421             getGeneratedPosition: getGeneratedPosition
64422         };
64423         function processMapping(mapping) {
64424             var generatedPosition = generatedFile !== undefined
64425                 ? ts.getPositionOfLineAndCharacter(generatedFile, mapping.generatedLine, mapping.generatedCharacter, true)
64426                 : -1;
64427             var source;
64428             var sourcePosition;
64429             if (isSourceMapping(mapping)) {
64430                 var sourceFile = host.getSourceFileLike(sourceFileAbsolutePaths[mapping.sourceIndex]);
64431                 source = map.sources[mapping.sourceIndex];
64432                 sourcePosition = sourceFile !== undefined
64433                     ? ts.getPositionOfLineAndCharacter(sourceFile, mapping.sourceLine, mapping.sourceCharacter, true)
64434                     : -1;
64435             }
64436             return {
64437                 generatedPosition: generatedPosition,
64438                 source: source,
64439                 sourceIndex: mapping.sourceIndex,
64440                 sourcePosition: sourcePosition,
64441                 nameIndex: mapping.nameIndex
64442             };
64443         }
64444         function getDecodedMappings() {
64445             if (decodedMappings === undefined) {
64446                 var decoder = decodeMappings(map.mappings);
64447                 var mappings = ts.arrayFrom(decoder, processMapping);
64448                 if (decoder.error !== undefined) {
64449                     if (host.log) {
64450                         host.log("Encountered error while decoding sourcemap: " + decoder.error);
64451                     }
64452                     decodedMappings = ts.emptyArray;
64453                 }
64454                 else {
64455                     decodedMappings = mappings;
64456                 }
64457             }
64458             return decodedMappings;
64459         }
64460         function getSourceMappings(sourceIndex) {
64461             if (sourceMappings === undefined) {
64462                 var lists = [];
64463                 for (var _i = 0, _a = getDecodedMappings(); _i < _a.length; _i++) {
64464                     var mapping = _a[_i];
64465                     if (!isSourceMappedPosition(mapping))
64466                         continue;
64467                     var list = lists[mapping.sourceIndex];
64468                     if (!list)
64469                         lists[mapping.sourceIndex] = list = [];
64470                     list.push(mapping);
64471                 }
64472                 sourceMappings = lists.map(function (list) { return ts.sortAndDeduplicate(list, compareSourcePositions, sameMappedPosition); });
64473             }
64474             return sourceMappings[sourceIndex];
64475         }
64476         function getGeneratedMappings() {
64477             if (generatedMappings === undefined) {
64478                 var list = [];
64479                 for (var _i = 0, _a = getDecodedMappings(); _i < _a.length; _i++) {
64480                     var mapping = _a[_i];
64481                     list.push(mapping);
64482                 }
64483                 generatedMappings = ts.sortAndDeduplicate(list, compareGeneratedPositions, sameMappedPosition);
64484             }
64485             return generatedMappings;
64486         }
64487         function getGeneratedPosition(loc) {
64488             var sourceIndex = sourceToSourceIndexMap.get(host.getCanonicalFileName(loc.fileName));
64489             if (sourceIndex === undefined)
64490                 return loc;
64491             var sourceMappings = getSourceMappings(sourceIndex);
64492             if (!ts.some(sourceMappings))
64493                 return loc;
64494             var targetIndex = ts.binarySearchKey(sourceMappings, loc.pos, getSourcePositionOfMapping, ts.compareValues);
64495             if (targetIndex < 0) {
64496                 targetIndex = ~targetIndex;
64497             }
64498             var mapping = sourceMappings[targetIndex];
64499             if (mapping === undefined || mapping.sourceIndex !== sourceIndex) {
64500                 return loc;
64501             }
64502             return { fileName: generatedAbsoluteFilePath, pos: mapping.generatedPosition };
64503         }
64504         function getSourcePosition(loc) {
64505             var generatedMappings = getGeneratedMappings();
64506             if (!ts.some(generatedMappings))
64507                 return loc;
64508             var targetIndex = ts.binarySearchKey(generatedMappings, loc.pos, getGeneratedPositionOfMapping, ts.compareValues);
64509             if (targetIndex < 0) {
64510                 targetIndex = ~targetIndex;
64511             }
64512             var mapping = generatedMappings[targetIndex];
64513             if (mapping === undefined || !isSourceMappedPosition(mapping)) {
64514                 return loc;
64515             }
64516             return { fileName: sourceFileAbsolutePaths[mapping.sourceIndex], pos: mapping.sourcePosition };
64517         }
64518     }
64519     ts.createDocumentPositionMapper = createDocumentPositionMapper;
64520     ts.identitySourceMapConsumer = {
64521         getSourcePosition: ts.identity,
64522         getGeneratedPosition: ts.identity
64523     };
64524 })(ts || (ts = {}));
64525 var ts;
64526 (function (ts) {
64527     function getOriginalNodeId(node) {
64528         node = ts.getOriginalNode(node);
64529         return node ? ts.getNodeId(node) : 0;
64530     }
64531     ts.getOriginalNodeId = getOriginalNodeId;
64532     function containsDefaultReference(node) {
64533         if (!node)
64534             return false;
64535         if (!ts.isNamedImports(node))
64536             return false;
64537         return ts.some(node.elements, isNamedDefaultReference);
64538     }
64539     function isNamedDefaultReference(e) {
64540         return e.propertyName !== undefined && e.propertyName.escapedText === "default";
64541     }
64542     function chainBundle(transformSourceFile) {
64543         return transformSourceFileOrBundle;
64544         function transformSourceFileOrBundle(node) {
64545             return node.kind === 290 ? transformSourceFile(node) : transformBundle(node);
64546         }
64547         function transformBundle(node) {
64548             return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends);
64549         }
64550     }
64551     ts.chainBundle = chainBundle;
64552     function getExportNeedsImportStarHelper(node) {
64553         return !!ts.getNamespaceDeclarationNode(node);
64554     }
64555     ts.getExportNeedsImportStarHelper = getExportNeedsImportStarHelper;
64556     function getImportNeedsImportStarHelper(node) {
64557         if (!!ts.getNamespaceDeclarationNode(node)) {
64558             return true;
64559         }
64560         var bindings = node.importClause && node.importClause.namedBindings;
64561         if (!bindings) {
64562             return false;
64563         }
64564         if (!ts.isNamedImports(bindings))
64565             return false;
64566         var defaultRefCount = 0;
64567         for (var _i = 0, _a = bindings.elements; _i < _a.length; _i++) {
64568             var binding = _a[_i];
64569             if (isNamedDefaultReference(binding)) {
64570                 defaultRefCount++;
64571             }
64572         }
64573         return (defaultRefCount > 0 && defaultRefCount !== bindings.elements.length) || (!!(bindings.elements.length - defaultRefCount) && ts.isDefaultImport(node));
64574     }
64575     ts.getImportNeedsImportStarHelper = getImportNeedsImportStarHelper;
64576     function getImportNeedsImportDefaultHelper(node) {
64577         return !getImportNeedsImportStarHelper(node) && (ts.isDefaultImport(node) || (!!node.importClause && ts.isNamedImports(node.importClause.namedBindings) && containsDefaultReference(node.importClause.namedBindings)));
64578     }
64579     ts.getImportNeedsImportDefaultHelper = getImportNeedsImportDefaultHelper;
64580     function collectExternalModuleInfo(sourceFile, resolver, compilerOptions) {
64581         var externalImports = [];
64582         var exportSpecifiers = ts.createMultiMap();
64583         var exportedBindings = [];
64584         var uniqueExports = ts.createMap();
64585         var exportedNames;
64586         var hasExportDefault = false;
64587         var exportEquals;
64588         var hasExportStarsToExportValues = false;
64589         var hasImportStar = false;
64590         var hasImportDefault = false;
64591         for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) {
64592             var node = _a[_i];
64593             switch (node.kind) {
64594                 case 254:
64595                     externalImports.push(node);
64596                     if (!hasImportStar && getImportNeedsImportStarHelper(node)) {
64597                         hasImportStar = true;
64598                     }
64599                     if (!hasImportDefault && getImportNeedsImportDefaultHelper(node)) {
64600                         hasImportDefault = true;
64601                     }
64602                     break;
64603                 case 253:
64604                     if (node.moduleReference.kind === 265) {
64605                         externalImports.push(node);
64606                     }
64607                     break;
64608                 case 260:
64609                     if (node.moduleSpecifier) {
64610                         if (!node.exportClause) {
64611                             externalImports.push(node);
64612                             hasExportStarsToExportValues = true;
64613                         }
64614                         else {
64615                             externalImports.push(node);
64616                         }
64617                     }
64618                     else {
64619                         for (var _b = 0, _c = ts.cast(node.exportClause, ts.isNamedExports).elements; _b < _c.length; _b++) {
64620                             var specifier = _c[_b];
64621                             if (!uniqueExports.get(ts.idText(specifier.name))) {
64622                                 var name = specifier.propertyName || specifier.name;
64623                                 exportSpecifiers.add(ts.idText(name), specifier);
64624                                 var decl = resolver.getReferencedImportDeclaration(name)
64625                                     || resolver.getReferencedValueDeclaration(name);
64626                                 if (decl) {
64627                                     multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(decl), specifier.name);
64628                                 }
64629                                 uniqueExports.set(ts.idText(specifier.name), true);
64630                                 exportedNames = ts.append(exportedNames, specifier.name);
64631                             }
64632                         }
64633                     }
64634                     break;
64635                 case 259:
64636                     if (node.isExportEquals && !exportEquals) {
64637                         exportEquals = node;
64638                     }
64639                     break;
64640                 case 225:
64641                     if (ts.hasModifier(node, 1)) {
64642                         for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) {
64643                             var decl = _e[_d];
64644                             exportedNames = collectExportedVariableInfo(decl, uniqueExports, exportedNames);
64645                         }
64646                     }
64647                     break;
64648                 case 244:
64649                     if (ts.hasModifier(node, 1)) {
64650                         if (ts.hasModifier(node, 512)) {
64651                             if (!hasExportDefault) {
64652                                 multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), ts.getDeclarationName(node));
64653                                 hasExportDefault = true;
64654                             }
64655                         }
64656                         else {
64657                             var name = node.name;
64658                             if (!uniqueExports.get(ts.idText(name))) {
64659                                 multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name);
64660                                 uniqueExports.set(ts.idText(name), true);
64661                                 exportedNames = ts.append(exportedNames, name);
64662                             }
64663                         }
64664                     }
64665                     break;
64666                 case 245:
64667                     if (ts.hasModifier(node, 1)) {
64668                         if (ts.hasModifier(node, 512)) {
64669                             if (!hasExportDefault) {
64670                                 multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), ts.getDeclarationName(node));
64671                                 hasExportDefault = true;
64672                             }
64673                         }
64674                         else {
64675                             var name = node.name;
64676                             if (name && !uniqueExports.get(ts.idText(name))) {
64677                                 multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name);
64678                                 uniqueExports.set(ts.idText(name), true);
64679                                 exportedNames = ts.append(exportedNames, name);
64680                             }
64681                         }
64682                     }
64683                     break;
64684             }
64685         }
64686         var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault);
64687         if (externalHelpersImportDeclaration) {
64688             externalImports.unshift(externalHelpersImportDeclaration);
64689         }
64690         return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues, exportedBindings: exportedBindings, exportedNames: exportedNames, externalHelpersImportDeclaration: externalHelpersImportDeclaration };
64691     }
64692     ts.collectExternalModuleInfo = collectExternalModuleInfo;
64693     function collectExportedVariableInfo(decl, uniqueExports, exportedNames) {
64694         if (ts.isBindingPattern(decl.name)) {
64695             for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) {
64696                 var element = _a[_i];
64697                 if (!ts.isOmittedExpression(element)) {
64698                     exportedNames = collectExportedVariableInfo(element, uniqueExports, exportedNames);
64699                 }
64700             }
64701         }
64702         else if (!ts.isGeneratedIdentifier(decl.name)) {
64703             var text = ts.idText(decl.name);
64704             if (!uniqueExports.get(text)) {
64705                 uniqueExports.set(text, true);
64706                 exportedNames = ts.append(exportedNames, decl.name);
64707             }
64708         }
64709         return exportedNames;
64710     }
64711     function multiMapSparseArrayAdd(map, key, value) {
64712         var values = map[key];
64713         if (values) {
64714             values.push(value);
64715         }
64716         else {
64717             map[key] = values = [value];
64718         }
64719         return values;
64720     }
64721     function isSimpleCopiableExpression(expression) {
64722         return ts.isStringLiteralLike(expression) ||
64723             expression.kind === 8 ||
64724             ts.isKeyword(expression.kind) ||
64725             ts.isIdentifier(expression);
64726     }
64727     ts.isSimpleCopiableExpression = isSimpleCopiableExpression;
64728     function isSimpleInlineableExpression(expression) {
64729         return !ts.isIdentifier(expression) && isSimpleCopiableExpression(expression) ||
64730             ts.isWellKnownSymbolSyntactically(expression);
64731     }
64732     ts.isSimpleInlineableExpression = isSimpleInlineableExpression;
64733     function isCompoundAssignment(kind) {
64734         return kind >= 63
64735             && kind <= 74;
64736     }
64737     ts.isCompoundAssignment = isCompoundAssignment;
64738     function getNonAssignmentOperatorForCompoundAssignment(kind) {
64739         switch (kind) {
64740             case 63: return 39;
64741             case 64: return 40;
64742             case 65: return 41;
64743             case 66: return 42;
64744             case 67: return 43;
64745             case 68: return 44;
64746             case 69: return 47;
64747             case 70: return 48;
64748             case 71: return 49;
64749             case 72: return 50;
64750             case 73: return 51;
64751             case 74: return 52;
64752         }
64753     }
64754     ts.getNonAssignmentOperatorForCompoundAssignment = getNonAssignmentOperatorForCompoundAssignment;
64755     function addPrologueDirectivesAndInitialSuperCall(ctor, result, visitor) {
64756         if (ctor.body) {
64757             var statements = ctor.body.statements;
64758             var index = ts.addPrologue(result, statements, false, visitor);
64759             if (index === statements.length) {
64760                 return index;
64761             }
64762             var superIndex = ts.findIndex(statements, function (s) { return ts.isExpressionStatement(s) && ts.isSuperCall(s.expression); }, index);
64763             if (superIndex > -1) {
64764                 for (var i = index; i <= superIndex; i++) {
64765                     result.push(ts.visitNode(statements[i], visitor, ts.isStatement));
64766                 }
64767                 return superIndex + 1;
64768             }
64769             return index;
64770         }
64771         return 0;
64772     }
64773     ts.addPrologueDirectivesAndInitialSuperCall = addPrologueDirectivesAndInitialSuperCall;
64774     function helperString(input) {
64775         var args = [];
64776         for (var _i = 1; _i < arguments.length; _i++) {
64777             args[_i - 1] = arguments[_i];
64778         }
64779         return function (uniqueName) {
64780             var result = "";
64781             for (var i = 0; i < args.length; i++) {
64782                 result += input[i];
64783                 result += uniqueName(args[i]);
64784             }
64785             result += input[input.length - 1];
64786             return result;
64787         };
64788     }
64789     ts.helperString = helperString;
64790     function getProperties(node, requireInitializer, isStatic) {
64791         return ts.filter(node.members, function (m) { return isInitializedOrStaticProperty(m, requireInitializer, isStatic); });
64792     }
64793     ts.getProperties = getProperties;
64794     function isInitializedOrStaticProperty(member, requireInitializer, isStatic) {
64795         return ts.isPropertyDeclaration(member)
64796             && (!!member.initializer || !requireInitializer)
64797             && ts.hasStaticModifier(member) === isStatic;
64798     }
64799     function isInitializedProperty(member) {
64800         return member.kind === 159
64801             && member.initializer !== undefined;
64802     }
64803     ts.isInitializedProperty = isInitializedProperty;
64804 })(ts || (ts = {}));
64805 var ts;
64806 (function (ts) {
64807     function flattenDestructuringAssignment(node, visitor, context, level, needsValue, createAssignmentCallback) {
64808         var location = node;
64809         var value;
64810         if (ts.isDestructuringAssignment(node)) {
64811             value = node.right;
64812             while (ts.isEmptyArrayLiteral(node.left) || ts.isEmptyObjectLiteral(node.left)) {
64813                 if (ts.isDestructuringAssignment(value)) {
64814                     location = node = value;
64815                     value = node.right;
64816                 }
64817                 else {
64818                     return ts.visitNode(value, visitor, ts.isExpression);
64819                 }
64820             }
64821         }
64822         var expressions;
64823         var flattenContext = {
64824             context: context,
64825             level: level,
64826             downlevelIteration: !!context.getCompilerOptions().downlevelIteration,
64827             hoistTempVariables: true,
64828             emitExpression: emitExpression,
64829             emitBindingOrAssignment: emitBindingOrAssignment,
64830             createArrayBindingOrAssignmentPattern: makeArrayAssignmentPattern,
64831             createObjectBindingOrAssignmentPattern: makeObjectAssignmentPattern,
64832             createArrayBindingOrAssignmentElement: makeAssignmentElement,
64833             visitor: visitor
64834         };
64835         if (value) {
64836             value = ts.visitNode(value, visitor, ts.isExpression);
64837             if (ts.isIdentifier(value) && bindingOrAssignmentElementAssignsToName(node, value.escapedText) ||
64838                 bindingOrAssignmentElementContainsNonLiteralComputedName(node)) {
64839                 value = ensureIdentifier(flattenContext, value, false, location);
64840             }
64841             else if (needsValue) {
64842                 value = ensureIdentifier(flattenContext, value, true, location);
64843             }
64844             else if (ts.nodeIsSynthesized(node)) {
64845                 location = value;
64846             }
64847         }
64848         flattenBindingOrAssignmentElement(flattenContext, node, value, location, ts.isDestructuringAssignment(node));
64849         if (value && needsValue) {
64850             if (!ts.some(expressions)) {
64851                 return value;
64852             }
64853             expressions.push(value);
64854         }
64855         return ts.aggregateTransformFlags(ts.inlineExpressions(expressions)) || ts.createOmittedExpression();
64856         function emitExpression(expression) {
64857             ts.aggregateTransformFlags(expression);
64858             expressions = ts.append(expressions, expression);
64859         }
64860         function emitBindingOrAssignment(target, value, location, original) {
64861             ts.Debug.assertNode(target, createAssignmentCallback ? ts.isIdentifier : ts.isExpression);
64862             var expression = createAssignmentCallback
64863                 ? createAssignmentCallback(target, value, location)
64864                 : ts.setTextRange(ts.createAssignment(ts.visitNode(target, visitor, ts.isExpression), value), location);
64865             expression.original = original;
64866             emitExpression(expression);
64867         }
64868     }
64869     ts.flattenDestructuringAssignment = flattenDestructuringAssignment;
64870     function bindingOrAssignmentElementAssignsToName(element, escapedName) {
64871         var target = ts.getTargetOfBindingOrAssignmentElement(element);
64872         if (ts.isBindingOrAssignmentPattern(target)) {
64873             return bindingOrAssignmentPatternAssignsToName(target, escapedName);
64874         }
64875         else if (ts.isIdentifier(target)) {
64876             return target.escapedText === escapedName;
64877         }
64878         return false;
64879     }
64880     function bindingOrAssignmentPatternAssignsToName(pattern, escapedName) {
64881         var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern);
64882         for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) {
64883             var element = elements_3[_i];
64884             if (bindingOrAssignmentElementAssignsToName(element, escapedName)) {
64885                 return true;
64886             }
64887         }
64888         return false;
64889     }
64890     function bindingOrAssignmentElementContainsNonLiteralComputedName(element) {
64891         var propertyName = ts.tryGetPropertyNameOfBindingOrAssignmentElement(element);
64892         if (propertyName && ts.isComputedPropertyName(propertyName) && !ts.isLiteralExpression(propertyName.expression)) {
64893             return true;
64894         }
64895         var target = ts.getTargetOfBindingOrAssignmentElement(element);
64896         return !!target && ts.isBindingOrAssignmentPattern(target) && bindingOrAssignmentPatternContainsNonLiteralComputedName(target);
64897     }
64898     function bindingOrAssignmentPatternContainsNonLiteralComputedName(pattern) {
64899         return !!ts.forEach(ts.getElementsOfBindingOrAssignmentPattern(pattern), bindingOrAssignmentElementContainsNonLiteralComputedName);
64900     }
64901     function flattenDestructuringBinding(node, visitor, context, level, rval, hoistTempVariables, skipInitializer) {
64902         if (hoistTempVariables === void 0) { hoistTempVariables = false; }
64903         var pendingExpressions;
64904         var pendingDeclarations = [];
64905         var declarations = [];
64906         var flattenContext = {
64907             context: context,
64908             level: level,
64909             downlevelIteration: !!context.getCompilerOptions().downlevelIteration,
64910             hoistTempVariables: hoistTempVariables,
64911             emitExpression: emitExpression,
64912             emitBindingOrAssignment: emitBindingOrAssignment,
64913             createArrayBindingOrAssignmentPattern: makeArrayBindingPattern,
64914             createObjectBindingOrAssignmentPattern: makeObjectBindingPattern,
64915             createArrayBindingOrAssignmentElement: makeBindingElement,
64916             visitor: visitor
64917         };
64918         if (ts.isVariableDeclaration(node)) {
64919             var initializer = ts.getInitializerOfBindingOrAssignmentElement(node);
64920             if (initializer && (ts.isIdentifier(initializer) && bindingOrAssignmentElementAssignsToName(node, initializer.escapedText) ||
64921                 bindingOrAssignmentElementContainsNonLiteralComputedName(node))) {
64922                 initializer = ensureIdentifier(flattenContext, initializer, false, initializer);
64923                 node = ts.updateVariableDeclaration(node, node.name, node.type, initializer);
64924             }
64925         }
64926         flattenBindingOrAssignmentElement(flattenContext, node, rval, node, skipInitializer);
64927         if (pendingExpressions) {
64928             var temp = ts.createTempVariable(undefined);
64929             if (hoistTempVariables) {
64930                 var value = ts.inlineExpressions(pendingExpressions);
64931                 pendingExpressions = undefined;
64932                 emitBindingOrAssignment(temp, value, undefined, undefined);
64933             }
64934             else {
64935                 context.hoistVariableDeclaration(temp);
64936                 var pendingDeclaration = ts.last(pendingDeclarations);
64937                 pendingDeclaration.pendingExpressions = ts.append(pendingDeclaration.pendingExpressions, ts.createAssignment(temp, pendingDeclaration.value));
64938                 ts.addRange(pendingDeclaration.pendingExpressions, pendingExpressions);
64939                 pendingDeclaration.value = temp;
64940             }
64941         }
64942         for (var _i = 0, pendingDeclarations_1 = pendingDeclarations; _i < pendingDeclarations_1.length; _i++) {
64943             var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name = _a.name, value = _a.value, location = _a.location, original = _a.original;
64944             var variable = ts.createVariableDeclaration(name, undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value);
64945             variable.original = original;
64946             ts.setTextRange(variable, location);
64947             ts.aggregateTransformFlags(variable);
64948             declarations.push(variable);
64949         }
64950         return declarations;
64951         function emitExpression(value) {
64952             pendingExpressions = ts.append(pendingExpressions, value);
64953         }
64954         function emitBindingOrAssignment(target, value, location, original) {
64955             ts.Debug.assertNode(target, ts.isBindingName);
64956             if (pendingExpressions) {
64957                 value = ts.inlineExpressions(ts.append(pendingExpressions, value));
64958                 pendingExpressions = undefined;
64959             }
64960             pendingDeclarations.push({ pendingExpressions: pendingExpressions, name: target, value: value, location: location, original: original });
64961         }
64962     }
64963     ts.flattenDestructuringBinding = flattenDestructuringBinding;
64964     function flattenBindingOrAssignmentElement(flattenContext, element, value, location, skipInitializer) {
64965         if (!skipInitializer) {
64966             var initializer = ts.visitNode(ts.getInitializerOfBindingOrAssignmentElement(element), flattenContext.visitor, ts.isExpression);
64967             if (initializer) {
64968                 value = value ? createDefaultValueCheck(flattenContext, value, initializer, location) : initializer;
64969             }
64970             else if (!value) {
64971                 value = ts.createVoidZero();
64972             }
64973         }
64974         var bindingTarget = ts.getTargetOfBindingOrAssignmentElement(element);
64975         if (ts.isObjectBindingOrAssignmentPattern(bindingTarget)) {
64976             flattenObjectBindingOrAssignmentPattern(flattenContext, element, bindingTarget, value, location);
64977         }
64978         else if (ts.isArrayBindingOrAssignmentPattern(bindingTarget)) {
64979             flattenArrayBindingOrAssignmentPattern(flattenContext, element, bindingTarget, value, location);
64980         }
64981         else {
64982             flattenContext.emitBindingOrAssignment(bindingTarget, value, location, element);
64983         }
64984     }
64985     function flattenObjectBindingOrAssignmentPattern(flattenContext, parent, pattern, value, location) {
64986         var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern);
64987         var numElements = elements.length;
64988         if (numElements !== 1) {
64989             var reuseIdentifierExpressions = !ts.isDeclarationBindingElement(parent) || numElements !== 0;
64990             value = ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location);
64991         }
64992         var bindingElements;
64993         var computedTempVariables;
64994         for (var i = 0; i < numElements; i++) {
64995             var element = elements[i];
64996             if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) {
64997                 var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(element);
64998                 if (flattenContext.level >= 1
64999                     && !(element.transformFlags & (8192 | 16384))
65000                     && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (8192 | 16384))
65001                     && !ts.isComputedPropertyName(propertyName)) {
65002                     bindingElements = ts.append(bindingElements, ts.visitNode(element, flattenContext.visitor));
65003                 }
65004                 else {
65005                     if (bindingElements) {
65006                         flattenContext.emitBindingOrAssignment(flattenContext.createObjectBindingOrAssignmentPattern(bindingElements), value, location, pattern);
65007                         bindingElements = undefined;
65008                     }
65009                     var rhsValue = createDestructuringPropertyAccess(flattenContext, value, propertyName);
65010                     if (ts.isComputedPropertyName(propertyName)) {
65011                         computedTempVariables = ts.append(computedTempVariables, rhsValue.argumentExpression);
65012                     }
65013                     flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element);
65014                 }
65015             }
65016             else if (i === numElements - 1) {
65017                 if (bindingElements) {
65018                     flattenContext.emitBindingOrAssignment(flattenContext.createObjectBindingOrAssignmentPattern(bindingElements), value, location, pattern);
65019                     bindingElements = undefined;
65020                 }
65021                 var rhsValue = createRestCall(flattenContext.context, value, elements, computedTempVariables, pattern);
65022                 flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element);
65023             }
65024         }
65025         if (bindingElements) {
65026             flattenContext.emitBindingOrAssignment(flattenContext.createObjectBindingOrAssignmentPattern(bindingElements), value, location, pattern);
65027         }
65028     }
65029     function flattenArrayBindingOrAssignmentPattern(flattenContext, parent, pattern, value, location) {
65030         var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern);
65031         var numElements = elements.length;
65032         if (flattenContext.level < 1 && flattenContext.downlevelIteration) {
65033             value = ensureIdentifier(flattenContext, ts.createReadHelper(flattenContext.context, value, numElements > 0 && ts.getRestIndicatorOfBindingOrAssignmentElement(elements[numElements - 1])
65034                 ? undefined
65035                 : numElements, location), false, location);
65036         }
65037         else if (numElements !== 1 && (flattenContext.level < 1 || numElements === 0)
65038             || ts.every(elements, ts.isOmittedExpression)) {
65039             var reuseIdentifierExpressions = !ts.isDeclarationBindingElement(parent) || numElements !== 0;
65040             value = ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location);
65041         }
65042         var bindingElements;
65043         var restContainingElements;
65044         for (var i = 0; i < numElements; i++) {
65045             var element = elements[i];
65046             if (flattenContext.level >= 1) {
65047                 if (element.transformFlags & 16384) {
65048                     var temp = ts.createTempVariable(undefined);
65049                     if (flattenContext.hoistTempVariables) {
65050                         flattenContext.context.hoistVariableDeclaration(temp);
65051                     }
65052                     restContainingElements = ts.append(restContainingElements, [temp, element]);
65053                     bindingElements = ts.append(bindingElements, flattenContext.createArrayBindingOrAssignmentElement(temp));
65054                 }
65055                 else {
65056                     bindingElements = ts.append(bindingElements, element);
65057                 }
65058             }
65059             else if (ts.isOmittedExpression(element)) {
65060                 continue;
65061             }
65062             else if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) {
65063                 var rhsValue = ts.createElementAccess(value, i);
65064                 flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element);
65065             }
65066             else if (i === numElements - 1) {
65067                 var rhsValue = ts.createArraySlice(value, i);
65068                 flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element);
65069             }
65070         }
65071         if (bindingElements) {
65072             flattenContext.emitBindingOrAssignment(flattenContext.createArrayBindingOrAssignmentPattern(bindingElements), value, location, pattern);
65073         }
65074         if (restContainingElements) {
65075             for (var _i = 0, restContainingElements_1 = restContainingElements; _i < restContainingElements_1.length; _i++) {
65076                 var _a = restContainingElements_1[_i], id = _a[0], element = _a[1];
65077                 flattenBindingOrAssignmentElement(flattenContext, element, id, element);
65078             }
65079         }
65080     }
65081     function createDefaultValueCheck(flattenContext, value, defaultValue, location) {
65082         value = ensureIdentifier(flattenContext, value, true, location);
65083         return ts.createConditional(ts.createTypeCheck(value, "undefined"), defaultValue, value);
65084     }
65085     function createDestructuringPropertyAccess(flattenContext, value, propertyName) {
65086         if (ts.isComputedPropertyName(propertyName)) {
65087             var argumentExpression = ensureIdentifier(flattenContext, ts.visitNode(propertyName.expression, flattenContext.visitor), false, propertyName);
65088             return ts.createElementAccess(value, argumentExpression);
65089         }
65090         else if (ts.isStringOrNumericLiteralLike(propertyName)) {
65091             var argumentExpression = ts.getSynthesizedClone(propertyName);
65092             argumentExpression.text = argumentExpression.text;
65093             return ts.createElementAccess(value, argumentExpression);
65094         }
65095         else {
65096             var name = ts.createIdentifier(ts.idText(propertyName));
65097             return ts.createPropertyAccess(value, name);
65098         }
65099     }
65100     function ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location) {
65101         if (ts.isIdentifier(value) && reuseIdentifierExpressions) {
65102             return value;
65103         }
65104         else {
65105             var temp = ts.createTempVariable(undefined);
65106             if (flattenContext.hoistTempVariables) {
65107                 flattenContext.context.hoistVariableDeclaration(temp);
65108                 flattenContext.emitExpression(ts.setTextRange(ts.createAssignment(temp, value), location));
65109             }
65110             else {
65111                 flattenContext.emitBindingOrAssignment(temp, value, location, undefined);
65112             }
65113             return temp;
65114         }
65115     }
65116     function makeArrayBindingPattern(elements) {
65117         ts.Debug.assertEachNode(elements, ts.isArrayBindingElement);
65118         return ts.createArrayBindingPattern(elements);
65119     }
65120     function makeArrayAssignmentPattern(elements) {
65121         return ts.createArrayLiteral(ts.map(elements, ts.convertToArrayAssignmentElement));
65122     }
65123     function makeObjectBindingPattern(elements) {
65124         ts.Debug.assertEachNode(elements, ts.isBindingElement);
65125         return ts.createObjectBindingPattern(elements);
65126     }
65127     function makeObjectAssignmentPattern(elements) {
65128         return ts.createObjectLiteral(ts.map(elements, ts.convertToObjectAssignmentElement));
65129     }
65130     function makeBindingElement(name) {
65131         return ts.createBindingElement(undefined, undefined, name);
65132     }
65133     function makeAssignmentElement(name) {
65134         return name;
65135     }
65136     ts.restHelper = {
65137         name: "typescript:rest",
65138         importName: "__rest",
65139         scoped: false,
65140         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            };"
65141     };
65142     function createRestCall(context, value, elements, computedTempVariables, location) {
65143         context.requestEmitHelper(ts.restHelper);
65144         var propertyNames = [];
65145         var computedTempVariableOffset = 0;
65146         for (var i = 0; i < elements.length - 1; i++) {
65147             var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(elements[i]);
65148             if (propertyName) {
65149                 if (ts.isComputedPropertyName(propertyName)) {
65150                     var temp = computedTempVariables[computedTempVariableOffset];
65151                     computedTempVariableOffset++;
65152                     propertyNames.push(ts.createConditional(ts.createTypeCheck(temp, "symbol"), temp, ts.createAdd(temp, ts.createLiteral(""))));
65153                 }
65154                 else {
65155                     propertyNames.push(ts.createLiteral(propertyName));
65156                 }
65157             }
65158         }
65159         return ts.createCall(ts.getUnscopedHelperName("__rest"), undefined, [
65160             value,
65161             ts.setTextRange(ts.createArrayLiteral(propertyNames), location)
65162         ]);
65163     }
65164 })(ts || (ts = {}));
65165 var ts;
65166 (function (ts) {
65167     var ProcessLevel;
65168     (function (ProcessLevel) {
65169         ProcessLevel[ProcessLevel["LiftRestriction"] = 0] = "LiftRestriction";
65170         ProcessLevel[ProcessLevel["All"] = 1] = "All";
65171     })(ProcessLevel = ts.ProcessLevel || (ts.ProcessLevel = {}));
65172     function processTaggedTemplateExpression(context, node, visitor, currentSourceFile, recordTaggedTemplateString, level) {
65173         var tag = ts.visitNode(node.tag, visitor, ts.isExpression);
65174         var templateArguments = [undefined];
65175         var cookedStrings = [];
65176         var rawStrings = [];
65177         var template = node.template;
65178         if (level === ProcessLevel.LiftRestriction && !ts.hasInvalidEscape(template))
65179             return node;
65180         if (ts.isNoSubstitutionTemplateLiteral(template)) {
65181             cookedStrings.push(createTemplateCooked(template));
65182             rawStrings.push(getRawLiteral(template, currentSourceFile));
65183         }
65184         else {
65185             cookedStrings.push(createTemplateCooked(template.head));
65186             rawStrings.push(getRawLiteral(template.head, currentSourceFile));
65187             for (var _i = 0, _a = template.templateSpans; _i < _a.length; _i++) {
65188                 var templateSpan = _a[_i];
65189                 cookedStrings.push(createTemplateCooked(templateSpan.literal));
65190                 rawStrings.push(getRawLiteral(templateSpan.literal, currentSourceFile));
65191                 templateArguments.push(ts.visitNode(templateSpan.expression, visitor, ts.isExpression));
65192             }
65193         }
65194         var helperCall = createTemplateObjectHelper(context, ts.createArrayLiteral(cookedStrings), ts.createArrayLiteral(rawStrings));
65195         if (ts.isExternalModule(currentSourceFile)) {
65196             var tempVar = ts.createUniqueName("templateObject");
65197             recordTaggedTemplateString(tempVar);
65198             templateArguments[0] = ts.createLogicalOr(tempVar, ts.createAssignment(tempVar, helperCall));
65199         }
65200         else {
65201             templateArguments[0] = helperCall;
65202         }
65203         return ts.createCall(tag, undefined, templateArguments);
65204     }
65205     ts.processTaggedTemplateExpression = processTaggedTemplateExpression;
65206     function createTemplateCooked(template) {
65207         return template.templateFlags ? ts.createIdentifier("undefined") : ts.createLiteral(template.text);
65208     }
65209     function getRawLiteral(node, currentSourceFile) {
65210         var text = node.rawText;
65211         if (text === undefined) {
65212             text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node);
65213             var isLast = node.kind === 14 || node.kind === 17;
65214             text = text.substring(1, text.length - (isLast ? 1 : 2));
65215         }
65216         text = text.replace(/\r\n?/g, "\n");
65217         return ts.setTextRange(ts.createLiteral(text), node);
65218     }
65219     function createTemplateObjectHelper(context, cooked, raw) {
65220         context.requestEmitHelper(ts.templateObjectHelper);
65221         return ts.createCall(ts.getUnscopedHelperName("__makeTemplateObject"), undefined, [
65222             cooked,
65223             raw
65224         ]);
65225     }
65226     ts.templateObjectHelper = {
65227         name: "typescript:makeTemplateObject",
65228         importName: "__makeTemplateObject",
65229         scoped: false,
65230         priority: 0,
65231         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            };"
65232     };
65233 })(ts || (ts = {}));
65234 var ts;
65235 (function (ts) {
65236     var USE_NEW_TYPE_METADATA_FORMAT = false;
65237     function transformTypeScript(context) {
65238         var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
65239         var resolver = context.getEmitResolver();
65240         var compilerOptions = context.getCompilerOptions();
65241         var strictNullChecks = ts.getStrictOptionValue(compilerOptions, "strictNullChecks");
65242         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
65243         var moduleKind = ts.getEmitModuleKind(compilerOptions);
65244         var previousOnEmitNode = context.onEmitNode;
65245         var previousOnSubstituteNode = context.onSubstituteNode;
65246         context.onEmitNode = onEmitNode;
65247         context.onSubstituteNode = onSubstituteNode;
65248         context.enableSubstitution(194);
65249         context.enableSubstitution(195);
65250         var currentSourceFile;
65251         var currentNamespace;
65252         var currentNamespaceContainerName;
65253         var currentLexicalScope;
65254         var currentNameScope;
65255         var currentScopeFirstDeclarationsOfName;
65256         var currentClassHasParameterProperties;
65257         var enabledSubstitutions;
65258         var classAliases;
65259         var applicableSubstitutions;
65260         return transformSourceFileOrBundle;
65261         function transformSourceFileOrBundle(node) {
65262             if (node.kind === 291) {
65263                 return transformBundle(node);
65264             }
65265             return transformSourceFile(node);
65266         }
65267         function transformBundle(node) {
65268             return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) {
65269                 if (prepend.kind === 293) {
65270                     return ts.createUnparsedSourceFile(prepend, "js");
65271                 }
65272                 return prepend;
65273             }));
65274         }
65275         function transformSourceFile(node) {
65276             if (node.isDeclarationFile) {
65277                 return node;
65278             }
65279             currentSourceFile = node;
65280             var visited = saveStateAndInvoke(node, visitSourceFile);
65281             ts.addEmitHelpers(visited, context.readEmitHelpers());
65282             currentSourceFile = undefined;
65283             return visited;
65284         }
65285         function saveStateAndInvoke(node, f) {
65286             var savedCurrentScope = currentLexicalScope;
65287             var savedCurrentNameScope = currentNameScope;
65288             var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName;
65289             var savedCurrentClassHasParameterProperties = currentClassHasParameterProperties;
65290             onBeforeVisitNode(node);
65291             var visited = f(node);
65292             if (currentLexicalScope !== savedCurrentScope) {
65293                 currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName;
65294             }
65295             currentLexicalScope = savedCurrentScope;
65296             currentNameScope = savedCurrentNameScope;
65297             currentClassHasParameterProperties = savedCurrentClassHasParameterProperties;
65298             return visited;
65299         }
65300         function onBeforeVisitNode(node) {
65301             switch (node.kind) {
65302                 case 290:
65303                 case 251:
65304                 case 250:
65305                 case 223:
65306                     currentLexicalScope = node;
65307                     currentNameScope = undefined;
65308                     currentScopeFirstDeclarationsOfName = undefined;
65309                     break;
65310                 case 245:
65311                 case 244:
65312                     if (ts.hasModifier(node, 2)) {
65313                         break;
65314                     }
65315                     if (node.name) {
65316                         recordEmittedDeclarationInScope(node);
65317                     }
65318                     else {
65319                         ts.Debug.assert(node.kind === 245 || ts.hasModifier(node, 512));
65320                     }
65321                     if (ts.isClassDeclaration(node)) {
65322                         currentNameScope = node;
65323                     }
65324                     break;
65325             }
65326         }
65327         function visitor(node) {
65328             return saveStateAndInvoke(node, visitorWorker);
65329         }
65330         function visitorWorker(node) {
65331             if (node.transformFlags & 1) {
65332                 return visitTypeScript(node);
65333             }
65334             return node;
65335         }
65336         function sourceElementVisitor(node) {
65337             return saveStateAndInvoke(node, sourceElementVisitorWorker);
65338         }
65339         function sourceElementVisitorWorker(node) {
65340             switch (node.kind) {
65341                 case 254:
65342                 case 253:
65343                 case 259:
65344                 case 260:
65345                     return visitEllidableStatement(node);
65346                 default:
65347                     return visitorWorker(node);
65348             }
65349         }
65350         function visitEllidableStatement(node) {
65351             var parsed = ts.getParseTreeNode(node);
65352             if (parsed !== node) {
65353                 if (node.transformFlags & 1) {
65354                     return ts.visitEachChild(node, visitor, context);
65355                 }
65356                 return node;
65357             }
65358             switch (node.kind) {
65359                 case 254:
65360                     return visitImportDeclaration(node);
65361                 case 253:
65362                     return visitImportEqualsDeclaration(node);
65363                 case 259:
65364                     return visitExportAssignment(node);
65365                 case 260:
65366                     return visitExportDeclaration(node);
65367                 default:
65368                     ts.Debug.fail("Unhandled ellided statement");
65369             }
65370         }
65371         function namespaceElementVisitor(node) {
65372             return saveStateAndInvoke(node, namespaceElementVisitorWorker);
65373         }
65374         function namespaceElementVisitorWorker(node) {
65375             if (node.kind === 260 ||
65376                 node.kind === 254 ||
65377                 node.kind === 255 ||
65378                 (node.kind === 253 &&
65379                     node.moduleReference.kind === 265)) {
65380                 return undefined;
65381             }
65382             else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) {
65383                 return visitTypeScript(node);
65384             }
65385             return node;
65386         }
65387         function classElementVisitor(node) {
65388             return saveStateAndInvoke(node, classElementVisitorWorker);
65389         }
65390         function classElementVisitorWorker(node) {
65391             switch (node.kind) {
65392                 case 162:
65393                     return visitConstructor(node);
65394                 case 159:
65395                     return visitPropertyDeclaration(node);
65396                 case 167:
65397                 case 163:
65398                 case 164:
65399                 case 161:
65400                     return visitorWorker(node);
65401                 case 222:
65402                     return node;
65403                 default:
65404                     return ts.Debug.failBadSyntaxKind(node);
65405             }
65406         }
65407         function modifierVisitor(node) {
65408             if (ts.modifierToFlag(node.kind) & 2270) {
65409                 return undefined;
65410             }
65411             else if (currentNamespace && node.kind === 89) {
65412                 return undefined;
65413             }
65414             return node;
65415         }
65416         function visitTypeScript(node) {
65417             if (ts.isStatement(node) && ts.hasModifier(node, 2)) {
65418                 return ts.createNotEmittedStatement(node);
65419             }
65420             switch (node.kind) {
65421                 case 89:
65422                 case 84:
65423                     return currentNamespace ? undefined : node;
65424                 case 119:
65425                 case 117:
65426                 case 118:
65427                 case 122:
65428                 case 81:
65429                 case 130:
65430                 case 138:
65431                 case 174:
65432                 case 175:
65433                 case 176:
65434                 case 177:
65435                 case 173:
65436                 case 168:
65437                 case 155:
65438                 case 125:
65439                 case 148:
65440                 case 128:
65441                 case 143:
65442                 case 140:
65443                 case 137:
65444                 case 110:
65445                 case 144:
65446                 case 171:
65447                 case 170:
65448                 case 172:
65449                 case 169:
65450                 case 178:
65451                 case 179:
65452                 case 180:
65453                 case 182:
65454                 case 183:
65455                 case 184:
65456                 case 185:
65457                 case 186:
65458                 case 187:
65459                 case 167:
65460                 case 157:
65461                 case 247:
65462                     return undefined;
65463                 case 159:
65464                     return visitPropertyDeclaration(node);
65465                 case 252:
65466                     return undefined;
65467                 case 162:
65468                     return visitConstructor(node);
65469                 case 246:
65470                     return ts.createNotEmittedStatement(node);
65471                 case 245:
65472                     return visitClassDeclaration(node);
65473                 case 214:
65474                     return visitClassExpression(node);
65475                 case 279:
65476                     return visitHeritageClause(node);
65477                 case 216:
65478                     return visitExpressionWithTypeArguments(node);
65479                 case 161:
65480                     return visitMethodDeclaration(node);
65481                 case 163:
65482                     return visitGetAccessor(node);
65483                 case 164:
65484                     return visitSetAccessor(node);
65485                 case 244:
65486                     return visitFunctionDeclaration(node);
65487                 case 201:
65488                     return visitFunctionExpression(node);
65489                 case 202:
65490                     return visitArrowFunction(node);
65491                 case 156:
65492                     return visitParameter(node);
65493                 case 200:
65494                     return visitParenthesizedExpression(node);
65495                 case 199:
65496                 case 217:
65497                     return visitAssertionExpression(node);
65498                 case 196:
65499                     return visitCallExpression(node);
65500                 case 197:
65501                     return visitNewExpression(node);
65502                 case 198:
65503                     return visitTaggedTemplateExpression(node);
65504                 case 218:
65505                     return visitNonNullExpression(node);
65506                 case 248:
65507                     return visitEnumDeclaration(node);
65508                 case 225:
65509                     return visitVariableStatement(node);
65510                 case 242:
65511                     return visitVariableDeclaration(node);
65512                 case 249:
65513                     return visitModuleDeclaration(node);
65514                 case 253:
65515                     return visitImportEqualsDeclaration(node);
65516                 case 267:
65517                     return visitJsxSelfClosingElement(node);
65518                 case 268:
65519                     return visitJsxJsxOpeningElement(node);
65520                 default:
65521                     return ts.visitEachChild(node, visitor, context);
65522             }
65523         }
65524         function visitSourceFile(node) {
65525             var alwaysStrict = ts.getStrictOptionValue(compilerOptions, "alwaysStrict") &&
65526                 !(ts.isExternalModule(node) && moduleKind >= ts.ModuleKind.ES2015) &&
65527                 !ts.isJsonSourceFile(node);
65528             return ts.updateSourceFileNode(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, 0, alwaysStrict));
65529         }
65530         function shouldEmitDecorateCallForClass(node) {
65531             if (node.decorators && node.decorators.length > 0) {
65532                 return true;
65533             }
65534             var constructor = ts.getFirstConstructorWithBody(node);
65535             if (constructor) {
65536                 return ts.forEach(constructor.parameters, shouldEmitDecorateCallForParameter);
65537             }
65538             return false;
65539         }
65540         function shouldEmitDecorateCallForParameter(parameter) {
65541             return parameter.decorators !== undefined && parameter.decorators.length > 0;
65542         }
65543         function getClassFacts(node, staticProperties) {
65544             var facts = 0;
65545             if (ts.some(staticProperties))
65546                 facts |= 1;
65547             var extendsClauseElement = ts.getEffectiveBaseTypeNode(node);
65548             if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 100)
65549                 facts |= 64;
65550             if (shouldEmitDecorateCallForClass(node))
65551                 facts |= 2;
65552             if (ts.childIsDecorated(node))
65553                 facts |= 4;
65554             if (isExportOfNamespace(node))
65555                 facts |= 8;
65556             else if (isDefaultExternalModuleExport(node))
65557                 facts |= 32;
65558             else if (isNamedExternalModuleExport(node))
65559                 facts |= 16;
65560             if (languageVersion <= 1 && (facts & 7))
65561                 facts |= 128;
65562             return facts;
65563         }
65564         function hasTypeScriptClassSyntax(node) {
65565             return !!(node.transformFlags & 2048);
65566         }
65567         function isClassLikeDeclarationWithTypeScriptSyntax(node) {
65568             return ts.some(node.decorators)
65569                 || ts.some(node.typeParameters)
65570                 || ts.some(node.heritageClauses, hasTypeScriptClassSyntax)
65571                 || ts.some(node.members, hasTypeScriptClassSyntax);
65572         }
65573         function visitClassDeclaration(node) {
65574             if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasModifier(node, 1))) {
65575                 return ts.visitEachChild(node, visitor, context);
65576             }
65577             var staticProperties = ts.getProperties(node, true, true);
65578             var facts = getClassFacts(node, staticProperties);
65579             if (facts & 128) {
65580                 context.startLexicalEnvironment();
65581             }
65582             var name = node.name || (facts & 5 ? ts.getGeneratedNameForNode(node) : undefined);
65583             var classStatement = facts & 2
65584                 ? createClassDeclarationHeadWithDecorators(node, name)
65585                 : createClassDeclarationHeadWithoutDecorators(node, name, facts);
65586             var statements = [classStatement];
65587             addClassElementDecorationStatements(statements, node, false);
65588             addClassElementDecorationStatements(statements, node, true);
65589             addConstructorDecorationStatement(statements, node);
65590             if (facts & 128) {
65591                 var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 19);
65592                 var localName = ts.getInternalName(node);
65593                 var outer = ts.createPartiallyEmittedExpression(localName);
65594                 outer.end = closingBraceLocation.end;
65595                 ts.setEmitFlags(outer, 1536);
65596                 var statement = ts.createReturn(outer);
65597                 statement.pos = closingBraceLocation.pos;
65598                 ts.setEmitFlags(statement, 1536 | 384);
65599                 statements.push(statement);
65600                 ts.insertStatementsAfterStandardPrologue(statements, context.endLexicalEnvironment());
65601                 var iife = ts.createImmediatelyInvokedArrowFunction(statements);
65602                 ts.setEmitFlags(iife, 33554432);
65603                 var varStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
65604                     ts.createVariableDeclaration(ts.getLocalName(node, false, false), undefined, iife)
65605                 ]));
65606                 ts.setOriginalNode(varStatement, node);
65607                 ts.setCommentRange(varStatement, node);
65608                 ts.setSourceMapRange(varStatement, ts.moveRangePastDecorators(node));
65609                 ts.startOnNewLine(varStatement);
65610                 statements = [varStatement];
65611             }
65612             if (facts & 8) {
65613                 addExportMemberAssignment(statements, node);
65614             }
65615             else if (facts & 128 || facts & 2) {
65616                 if (facts & 32) {
65617                     statements.push(ts.createExportDefault(ts.getLocalName(node, false, true)));
65618                 }
65619                 else if (facts & 16) {
65620                     statements.push(ts.createExternalModuleExport(ts.getLocalName(node, false, true)));
65621                 }
65622             }
65623             if (statements.length > 1) {
65624                 statements.push(ts.createEndOfDeclarationMarker(node));
65625                 ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304);
65626             }
65627             return ts.singleOrMany(statements);
65628         }
65629         function createClassDeclarationHeadWithoutDecorators(node, name, facts) {
65630             var modifiers = !(facts & 128)
65631                 ? ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier)
65632                 : undefined;
65633             var classDeclaration = ts.createClassDeclaration(undefined, modifiers, name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node));
65634             var emitFlags = ts.getEmitFlags(node);
65635             if (facts & 1) {
65636                 emitFlags |= 32;
65637             }
65638             ts.aggregateTransformFlags(classDeclaration);
65639             ts.setTextRange(classDeclaration, node);
65640             ts.setOriginalNode(classDeclaration, node);
65641             ts.setEmitFlags(classDeclaration, emitFlags);
65642             return classDeclaration;
65643         }
65644         function createClassDeclarationHeadWithDecorators(node, name) {
65645             var location = ts.moveRangePastDecorators(node);
65646             var classAlias = getClassAliasIfNeeded(node);
65647             var declName = ts.getLocalName(node, false, true);
65648             var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause);
65649             var members = transformClassMembers(node);
65650             var classExpression = ts.createClassExpression(undefined, name, undefined, heritageClauses, members);
65651             ts.aggregateTransformFlags(classExpression);
65652             ts.setOriginalNode(classExpression, node);
65653             ts.setTextRange(classExpression, location);
65654             var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
65655                 ts.createVariableDeclaration(declName, undefined, classAlias ? ts.createAssignment(classAlias, classExpression) : classExpression)
65656             ], 1));
65657             ts.setOriginalNode(statement, node);
65658             ts.setTextRange(statement, location);
65659             ts.setCommentRange(statement, node);
65660             return statement;
65661         }
65662         function visitClassExpression(node) {
65663             if (!isClassLikeDeclarationWithTypeScriptSyntax(node)) {
65664                 return ts.visitEachChild(node, visitor, context);
65665             }
65666             var classExpression = ts.createClassExpression(undefined, node.name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node));
65667             ts.aggregateTransformFlags(classExpression);
65668             ts.setOriginalNode(classExpression, node);
65669             ts.setTextRange(classExpression, node);
65670             return classExpression;
65671         }
65672         function transformClassMembers(node) {
65673             var members = [];
65674             var constructor = ts.getFirstConstructorWithBody(node);
65675             var parametersWithPropertyAssignments = constructor &&
65676                 ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); });
65677             if (parametersWithPropertyAssignments) {
65678                 for (var _i = 0, parametersWithPropertyAssignments_1 = parametersWithPropertyAssignments; _i < parametersWithPropertyAssignments_1.length; _i++) {
65679                     var parameter = parametersWithPropertyAssignments_1[_i];
65680                     if (ts.isIdentifier(parameter.name)) {
65681                         members.push(ts.setOriginalNode(ts.aggregateTransformFlags(ts.createProperty(undefined, undefined, parameter.name, undefined, undefined, undefined)), parameter));
65682                     }
65683                 }
65684             }
65685             ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement));
65686             return ts.setTextRange(ts.createNodeArray(members), node.members);
65687         }
65688         function getDecoratedClassElements(node, isStatic) {
65689             return ts.filter(node.members, isStatic ? function (m) { return isStaticDecoratedClassElement(m, node); } : function (m) { return isInstanceDecoratedClassElement(m, node); });
65690         }
65691         function isStaticDecoratedClassElement(member, parent) {
65692             return isDecoratedClassElement(member, true, parent);
65693         }
65694         function isInstanceDecoratedClassElement(member, parent) {
65695             return isDecoratedClassElement(member, false, parent);
65696         }
65697         function isDecoratedClassElement(member, isStatic, parent) {
65698             return ts.nodeOrChildIsDecorated(member, parent)
65699                 && isStatic === ts.hasModifier(member, 32);
65700         }
65701         function getDecoratorsOfParameters(node) {
65702             var decorators;
65703             if (node) {
65704                 var parameters = node.parameters;
65705                 var firstParameterIsThis = parameters.length > 0 && ts.parameterIsThisKeyword(parameters[0]);
65706                 var firstParameterOffset = firstParameterIsThis ? 1 : 0;
65707                 var numParameters = firstParameterIsThis ? parameters.length - 1 : parameters.length;
65708                 for (var i = 0; i < numParameters; i++) {
65709                     var parameter = parameters[i + firstParameterOffset];
65710                     if (decorators || parameter.decorators) {
65711                         if (!decorators) {
65712                             decorators = new Array(numParameters);
65713                         }
65714                         decorators[i] = parameter.decorators;
65715                     }
65716                 }
65717             }
65718             return decorators;
65719         }
65720         function getAllDecoratorsOfConstructor(node) {
65721             var decorators = node.decorators;
65722             var parameters = getDecoratorsOfParameters(ts.getFirstConstructorWithBody(node));
65723             if (!decorators && !parameters) {
65724                 return undefined;
65725             }
65726             return {
65727                 decorators: decorators,
65728                 parameters: parameters
65729             };
65730         }
65731         function getAllDecoratorsOfClassElement(node, member) {
65732             switch (member.kind) {
65733                 case 163:
65734                 case 164:
65735                     return getAllDecoratorsOfAccessors(node, member);
65736                 case 161:
65737                     return getAllDecoratorsOfMethod(member);
65738                 case 159:
65739                     return getAllDecoratorsOfProperty(member);
65740                 default:
65741                     return undefined;
65742             }
65743         }
65744         function getAllDecoratorsOfAccessors(node, accessor) {
65745             if (!accessor.body) {
65746                 return undefined;
65747             }
65748             var _a = ts.getAllAccessorDeclarations(node.members, accessor), firstAccessor = _a.firstAccessor, secondAccessor = _a.secondAccessor, setAccessor = _a.setAccessor;
65749             var firstAccessorWithDecorators = firstAccessor.decorators ? firstAccessor : secondAccessor && secondAccessor.decorators ? secondAccessor : undefined;
65750             if (!firstAccessorWithDecorators || accessor !== firstAccessorWithDecorators) {
65751                 return undefined;
65752             }
65753             var decorators = firstAccessorWithDecorators.decorators;
65754             var parameters = getDecoratorsOfParameters(setAccessor);
65755             if (!decorators && !parameters) {
65756                 return undefined;
65757             }
65758             return { decorators: decorators, parameters: parameters };
65759         }
65760         function getAllDecoratorsOfMethod(method) {
65761             if (!method.body) {
65762                 return undefined;
65763             }
65764             var decorators = method.decorators;
65765             var parameters = getDecoratorsOfParameters(method);
65766             if (!decorators && !parameters) {
65767                 return undefined;
65768             }
65769             return { decorators: decorators, parameters: parameters };
65770         }
65771         function getAllDecoratorsOfProperty(property) {
65772             var decorators = property.decorators;
65773             if (!decorators) {
65774                 return undefined;
65775             }
65776             return { decorators: decorators };
65777         }
65778         function transformAllDecoratorsOfDeclaration(node, container, allDecorators) {
65779             if (!allDecorators) {
65780                 return undefined;
65781             }
65782             var decoratorExpressions = [];
65783             ts.addRange(decoratorExpressions, ts.map(allDecorators.decorators, transformDecorator));
65784             ts.addRange(decoratorExpressions, ts.flatMap(allDecorators.parameters, transformDecoratorsOfParameter));
65785             addTypeMetadata(node, container, decoratorExpressions);
65786             return decoratorExpressions;
65787         }
65788         function addClassElementDecorationStatements(statements, node, isStatic) {
65789             ts.addRange(statements, ts.map(generateClassElementDecorationExpressions(node, isStatic), expressionToStatement));
65790         }
65791         function generateClassElementDecorationExpressions(node, isStatic) {
65792             var members = getDecoratedClassElements(node, isStatic);
65793             var expressions;
65794             for (var _i = 0, members_6 = members; _i < members_6.length; _i++) {
65795                 var member = members_6[_i];
65796                 var expression = generateClassElementDecorationExpression(node, member);
65797                 if (expression) {
65798                     if (!expressions) {
65799                         expressions = [expression];
65800                     }
65801                     else {
65802                         expressions.push(expression);
65803                     }
65804                 }
65805             }
65806             return expressions;
65807         }
65808         function generateClassElementDecorationExpression(node, member) {
65809             var allDecorators = getAllDecoratorsOfClassElement(node, member);
65810             var decoratorExpressions = transformAllDecoratorsOfDeclaration(member, node, allDecorators);
65811             if (!decoratorExpressions) {
65812                 return undefined;
65813             }
65814             var prefix = getClassMemberPrefix(node, member);
65815             var memberName = getExpressionForPropertyName(member, true);
65816             var descriptor = languageVersion > 0
65817                 ? member.kind === 159
65818                     ? ts.createVoidZero()
65819                     : ts.createNull()
65820                 : undefined;
65821             var helper = createDecorateHelper(context, decoratorExpressions, prefix, memberName, descriptor, ts.moveRangePastDecorators(member));
65822             ts.setEmitFlags(helper, 1536);
65823             return helper;
65824         }
65825         function addConstructorDecorationStatement(statements, node) {
65826             var expression = generateConstructorDecorationExpression(node);
65827             if (expression) {
65828                 statements.push(ts.setOriginalNode(ts.createExpressionStatement(expression), node));
65829             }
65830         }
65831         function generateConstructorDecorationExpression(node) {
65832             var allDecorators = getAllDecoratorsOfConstructor(node);
65833             var decoratorExpressions = transformAllDecoratorsOfDeclaration(node, node, allDecorators);
65834             if (!decoratorExpressions) {
65835                 return undefined;
65836             }
65837             var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)];
65838             var localName = ts.getLocalName(node, false, true);
65839             var decorate = createDecorateHelper(context, decoratorExpressions, localName);
65840             var expression = ts.createAssignment(localName, classAlias ? ts.createAssignment(classAlias, decorate) : decorate);
65841             ts.setEmitFlags(expression, 1536);
65842             ts.setSourceMapRange(expression, ts.moveRangePastDecorators(node));
65843             return expression;
65844         }
65845         function transformDecorator(decorator) {
65846             return ts.visitNode(decorator.expression, visitor, ts.isExpression);
65847         }
65848         function transformDecoratorsOfParameter(decorators, parameterOffset) {
65849             var expressions;
65850             if (decorators) {
65851                 expressions = [];
65852                 for (var _i = 0, decorators_1 = decorators; _i < decorators_1.length; _i++) {
65853                     var decorator = decorators_1[_i];
65854                     var helper = createParamHelper(context, transformDecorator(decorator), parameterOffset, decorator.expression);
65855                     ts.setEmitFlags(helper, 1536);
65856                     expressions.push(helper);
65857                 }
65858             }
65859             return expressions;
65860         }
65861         function addTypeMetadata(node, container, decoratorExpressions) {
65862             if (USE_NEW_TYPE_METADATA_FORMAT) {
65863                 addNewTypeMetadata(node, container, decoratorExpressions);
65864             }
65865             else {
65866                 addOldTypeMetadata(node, container, decoratorExpressions);
65867             }
65868         }
65869         function addOldTypeMetadata(node, container, decoratorExpressions) {
65870             if (compilerOptions.emitDecoratorMetadata) {
65871                 if (shouldAddTypeMetadata(node)) {
65872                     decoratorExpressions.push(createMetadataHelper(context, "design:type", serializeTypeOfNode(node)));
65873                 }
65874                 if (shouldAddParamTypesMetadata(node)) {
65875                     decoratorExpressions.push(createMetadataHelper(context, "design:paramtypes", serializeParameterTypesOfNode(node, container)));
65876                 }
65877                 if (shouldAddReturnTypeMetadata(node)) {
65878                     decoratorExpressions.push(createMetadataHelper(context, "design:returntype", serializeReturnTypeOfNode(node)));
65879                 }
65880             }
65881         }
65882         function addNewTypeMetadata(node, container, decoratorExpressions) {
65883             if (compilerOptions.emitDecoratorMetadata) {
65884                 var properties = void 0;
65885                 if (shouldAddTypeMetadata(node)) {
65886                     (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(38), serializeTypeOfNode(node))));
65887                 }
65888                 if (shouldAddParamTypesMetadata(node)) {
65889                     (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(38), serializeParameterTypesOfNode(node, container))));
65890                 }
65891                 if (shouldAddReturnTypeMetadata(node)) {
65892                     (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(38), serializeReturnTypeOfNode(node))));
65893                 }
65894                 if (properties) {
65895                     decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, true)));
65896                 }
65897             }
65898         }
65899         function shouldAddTypeMetadata(node) {
65900             var kind = node.kind;
65901             return kind === 161
65902                 || kind === 163
65903                 || kind === 164
65904                 || kind === 159;
65905         }
65906         function shouldAddReturnTypeMetadata(node) {
65907             return node.kind === 161;
65908         }
65909         function shouldAddParamTypesMetadata(node) {
65910             switch (node.kind) {
65911                 case 245:
65912                 case 214:
65913                     return ts.getFirstConstructorWithBody(node) !== undefined;
65914                 case 161:
65915                 case 163:
65916                 case 164:
65917                     return true;
65918             }
65919             return false;
65920         }
65921         function getAccessorTypeNode(node) {
65922             var accessors = resolver.getAllAccessorDeclarations(node);
65923             return accessors.setAccessor && ts.getSetAccessorTypeAnnotationNode(accessors.setAccessor)
65924                 || accessors.getAccessor && ts.getEffectiveReturnTypeNode(accessors.getAccessor);
65925         }
65926         function serializeTypeOfNode(node) {
65927             switch (node.kind) {
65928                 case 159:
65929                 case 156:
65930                     return serializeTypeNode(node.type);
65931                 case 164:
65932                 case 163:
65933                     return serializeTypeNode(getAccessorTypeNode(node));
65934                 case 245:
65935                 case 214:
65936                 case 161:
65937                     return ts.createIdentifier("Function");
65938                 default:
65939                     return ts.createVoidZero();
65940             }
65941         }
65942         function serializeParameterTypesOfNode(node, container) {
65943             var valueDeclaration = ts.isClassLike(node)
65944                 ? ts.getFirstConstructorWithBody(node)
65945                 : ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)
65946                     ? node
65947                     : undefined;
65948             var expressions = [];
65949             if (valueDeclaration) {
65950                 var parameters = getParametersOfDecoratedDeclaration(valueDeclaration, container);
65951                 var numParameters = parameters.length;
65952                 for (var i = 0; i < numParameters; i++) {
65953                     var parameter = parameters[i];
65954                     if (i === 0 && ts.isIdentifier(parameter.name) && parameter.name.escapedText === "this") {
65955                         continue;
65956                     }
65957                     if (parameter.dotDotDotToken) {
65958                         expressions.push(serializeTypeNode(ts.getRestParameterElementType(parameter.type)));
65959                     }
65960                     else {
65961                         expressions.push(serializeTypeOfNode(parameter));
65962                     }
65963                 }
65964             }
65965             return ts.createArrayLiteral(expressions);
65966         }
65967         function getParametersOfDecoratedDeclaration(node, container) {
65968             if (container && node.kind === 163) {
65969                 var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor;
65970                 if (setAccessor) {
65971                     return setAccessor.parameters;
65972                 }
65973             }
65974             return node.parameters;
65975         }
65976         function serializeReturnTypeOfNode(node) {
65977             if (ts.isFunctionLike(node) && node.type) {
65978                 return serializeTypeNode(node.type);
65979             }
65980             else if (ts.isAsyncFunction(node)) {
65981                 return ts.createIdentifier("Promise");
65982             }
65983             return ts.createVoidZero();
65984         }
65985         function serializeTypeNode(node) {
65986             if (node === undefined) {
65987                 return ts.createIdentifier("Object");
65988             }
65989             switch (node.kind) {
65990                 case 110:
65991                 case 146:
65992                 case 100:
65993                 case 137:
65994                     return ts.createVoidZero();
65995                 case 182:
65996                     return serializeTypeNode(node.type);
65997                 case 170:
65998                 case 171:
65999                     return ts.createIdentifier("Function");
66000                 case 174:
66001                 case 175:
66002                     return ts.createIdentifier("Array");
66003                 case 168:
66004                 case 128:
66005                     return ts.createIdentifier("Boolean");
66006                 case 143:
66007                     return ts.createIdentifier("String");
66008                 case 141:
66009                     return ts.createIdentifier("Object");
66010                 case 187:
66011                     switch (node.literal.kind) {
66012                         case 10:
66013                             return ts.createIdentifier("String");
66014                         case 207:
66015                         case 8:
66016                             return ts.createIdentifier("Number");
66017                         case 9:
66018                             return getGlobalBigIntNameWithFallback();
66019                         case 106:
66020                         case 91:
66021                             return ts.createIdentifier("Boolean");
66022                         default:
66023                             return ts.Debug.failBadSyntaxKind(node.literal);
66024                     }
66025                 case 140:
66026                     return ts.createIdentifier("Number");
66027                 case 151:
66028                     return getGlobalBigIntNameWithFallback();
66029                 case 144:
66030                     return languageVersion < 2
66031                         ? getGlobalSymbolNameWithFallback()
66032                         : ts.createIdentifier("Symbol");
66033                 case 169:
66034                     return serializeTypeReferenceNode(node);
66035                 case 179:
66036                 case 178:
66037                     return serializeTypeList(node.types);
66038                 case 180:
66039                     return serializeTypeList([node.trueType, node.falseType]);
66040                 case 184:
66041                     if (node.operator === 138) {
66042                         return serializeTypeNode(node.type);
66043                     }
66044                     break;
66045                 case 172:
66046                 case 185:
66047                 case 186:
66048                 case 173:
66049                 case 125:
66050                 case 148:
66051                 case 183:
66052                 case 188:
66053                     break;
66054                 case 295:
66055                 case 296:
66056                 case 300:
66057                 case 301:
66058                 case 302:
66059                     break;
66060                 case 297:
66061                 case 298:
66062                 case 299:
66063                     return serializeTypeNode(node.type);
66064                 default:
66065                     return ts.Debug.failBadSyntaxKind(node);
66066             }
66067             return ts.createIdentifier("Object");
66068         }
66069         function serializeTypeList(types) {
66070             var serializedUnion;
66071             for (var _i = 0, types_21 = types; _i < types_21.length; _i++) {
66072                 var typeNode = types_21[_i];
66073                 while (typeNode.kind === 182) {
66074                     typeNode = typeNode.type;
66075                 }
66076                 if (typeNode.kind === 137) {
66077                     continue;
66078                 }
66079                 if (!strictNullChecks && (typeNode.kind === 100 || typeNode.kind === 146)) {
66080                     continue;
66081                 }
66082                 var serializedIndividual = serializeTypeNode(typeNode);
66083                 if (ts.isIdentifier(serializedIndividual) && serializedIndividual.escapedText === "Object") {
66084                     return serializedIndividual;
66085                 }
66086                 else if (serializedUnion) {
66087                     if (!ts.isIdentifier(serializedUnion) ||
66088                         !ts.isIdentifier(serializedIndividual) ||
66089                         serializedUnion.escapedText !== serializedIndividual.escapedText) {
66090                         return ts.createIdentifier("Object");
66091                     }
66092                 }
66093                 else {
66094                     serializedUnion = serializedIndividual;
66095                 }
66096             }
66097             return serializedUnion || ts.createVoidZero();
66098         }
66099         function serializeTypeReferenceNode(node) {
66100             var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope || currentLexicalScope);
66101             switch (kind) {
66102                 case ts.TypeReferenceSerializationKind.Unknown:
66103                     if (ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && (n.parent.trueType === n || n.parent.falseType === n); })) {
66104                         return ts.createIdentifier("Object");
66105                     }
66106                     var serialized = serializeEntityNameAsExpressionFallback(node.typeName);
66107                     var temp = ts.createTempVariable(hoistVariableDeclaration);
66108                     return ts.createConditional(ts.createTypeCheck(ts.createAssignment(temp, serialized), "function"), temp, ts.createIdentifier("Object"));
66109                 case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue:
66110                     return serializeEntityNameAsExpression(node.typeName);
66111                 case ts.TypeReferenceSerializationKind.VoidNullableOrNeverType:
66112                     return ts.createVoidZero();
66113                 case ts.TypeReferenceSerializationKind.BigIntLikeType:
66114                     return getGlobalBigIntNameWithFallback();
66115                 case ts.TypeReferenceSerializationKind.BooleanType:
66116                     return ts.createIdentifier("Boolean");
66117                 case ts.TypeReferenceSerializationKind.NumberLikeType:
66118                     return ts.createIdentifier("Number");
66119                 case ts.TypeReferenceSerializationKind.StringLikeType:
66120                     return ts.createIdentifier("String");
66121                 case ts.TypeReferenceSerializationKind.ArrayLikeType:
66122                     return ts.createIdentifier("Array");
66123                 case ts.TypeReferenceSerializationKind.ESSymbolType:
66124                     return languageVersion < 2
66125                         ? getGlobalSymbolNameWithFallback()
66126                         : ts.createIdentifier("Symbol");
66127                 case ts.TypeReferenceSerializationKind.TypeWithCallSignature:
66128                     return ts.createIdentifier("Function");
66129                 case ts.TypeReferenceSerializationKind.Promise:
66130                     return ts.createIdentifier("Promise");
66131                 case ts.TypeReferenceSerializationKind.ObjectType:
66132                     return ts.createIdentifier("Object");
66133                 default:
66134                     return ts.Debug.assertNever(kind);
66135             }
66136         }
66137         function createCheckedValue(left, right) {
66138             return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(left), ts.createLiteral("undefined")), right);
66139         }
66140         function serializeEntityNameAsExpressionFallback(node) {
66141             if (node.kind === 75) {
66142                 var copied = serializeEntityNameAsExpression(node);
66143                 return createCheckedValue(copied, copied);
66144             }
66145             if (node.left.kind === 75) {
66146                 return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node));
66147             }
66148             var left = serializeEntityNameAsExpressionFallback(node.left);
66149             var temp = ts.createTempVariable(hoistVariableDeclaration);
66150             return ts.createLogicalAnd(ts.createLogicalAnd(left.left, ts.createStrictInequality(ts.createAssignment(temp, left.right), ts.createVoidZero())), ts.createPropertyAccess(temp, node.right));
66151         }
66152         function serializeEntityNameAsExpression(node) {
66153             switch (node.kind) {
66154                 case 75:
66155                     var name = ts.getMutableClone(node);
66156                     name.flags &= ~8;
66157                     name.original = undefined;
66158                     name.parent = ts.getParseTreeNode(currentLexicalScope);
66159                     return name;
66160                 case 153:
66161                     return serializeQualifiedNameAsExpression(node);
66162             }
66163         }
66164         function serializeQualifiedNameAsExpression(node) {
66165             return ts.createPropertyAccess(serializeEntityNameAsExpression(node.left), node.right);
66166         }
66167         function getGlobalSymbolNameWithFallback() {
66168             return ts.createConditional(ts.createTypeCheck(ts.createIdentifier("Symbol"), "function"), ts.createIdentifier("Symbol"), ts.createIdentifier("Object"));
66169         }
66170         function getGlobalBigIntNameWithFallback() {
66171             return languageVersion < 99
66172                 ? ts.createConditional(ts.createTypeCheck(ts.createIdentifier("BigInt"), "function"), ts.createIdentifier("BigInt"), ts.createIdentifier("Object"))
66173                 : ts.createIdentifier("BigInt");
66174         }
66175         function getExpressionForPropertyName(member, generateNameForComputedPropertyName) {
66176             var name = member.name;
66177             if (ts.isPrivateIdentifier(name)) {
66178                 return ts.createIdentifier("");
66179             }
66180             else if (ts.isComputedPropertyName(name)) {
66181                 return generateNameForComputedPropertyName && !ts.isSimpleInlineableExpression(name.expression)
66182                     ? ts.getGeneratedNameForNode(name)
66183                     : name.expression;
66184             }
66185             else if (ts.isIdentifier(name)) {
66186                 return ts.createLiteral(ts.idText(name));
66187             }
66188             else {
66189                 return ts.getSynthesizedClone(name);
66190             }
66191         }
66192         function visitPropertyNameOfClassElement(member) {
66193             var name = member.name;
66194             if (ts.isComputedPropertyName(name) && ((!ts.hasStaticModifier(member) && currentClassHasParameterProperties) || ts.some(member.decorators))) {
66195                 var expression = ts.visitNode(name.expression, visitor, ts.isExpression);
66196                 var innerExpression = ts.skipPartiallyEmittedExpressions(expression);
66197                 if (!ts.isSimpleInlineableExpression(innerExpression)) {
66198                     var generatedName = ts.getGeneratedNameForNode(name);
66199                     hoistVariableDeclaration(generatedName);
66200                     return ts.updateComputedPropertyName(name, ts.createAssignment(generatedName, expression));
66201                 }
66202             }
66203             return ts.visitNode(name, visitor, ts.isPropertyName);
66204         }
66205         function visitHeritageClause(node) {
66206             if (node.token === 113) {
66207                 return undefined;
66208             }
66209             return ts.visitEachChild(node, visitor, context);
66210         }
66211         function visitExpressionWithTypeArguments(node) {
66212             return ts.updateExpressionWithTypeArguments(node, undefined, ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression));
66213         }
66214         function shouldEmitFunctionLikeDeclaration(node) {
66215             return !ts.nodeIsMissing(node.body);
66216         }
66217         function visitPropertyDeclaration(node) {
66218             if (node.flags & 8388608) {
66219                 return undefined;
66220             }
66221             var updated = ts.updateProperty(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node), undefined, undefined, ts.visitNode(node.initializer, visitor));
66222             if (updated !== node) {
66223                 ts.setCommentRange(updated, node);
66224                 ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
66225             }
66226             return updated;
66227         }
66228         function visitConstructor(node) {
66229             if (!shouldEmitFunctionLikeDeclaration(node)) {
66230                 return undefined;
66231             }
66232             return ts.updateConstructor(node, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), transformConstructorBody(node.body, node));
66233         }
66234         function transformConstructorBody(body, constructor) {
66235             var parametersWithPropertyAssignments = constructor &&
66236                 ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); });
66237             if (!ts.some(parametersWithPropertyAssignments)) {
66238                 return ts.visitFunctionBody(body, visitor, context);
66239             }
66240             var statements = [];
66241             var indexOfFirstStatement = 0;
66242             resumeLexicalEnvironment();
66243             indexOfFirstStatement = ts.addPrologueDirectivesAndInitialSuperCall(constructor, statements, visitor);
66244             ts.addRange(statements, ts.map(parametersWithPropertyAssignments, transformParameterWithPropertyAssignment));
66245             ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, indexOfFirstStatement));
66246             statements = ts.mergeLexicalEnvironment(statements, endLexicalEnvironment());
66247             var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), body.statements), true);
66248             ts.setTextRange(block, body);
66249             ts.setOriginalNode(block, body);
66250             return block;
66251         }
66252         function transformParameterWithPropertyAssignment(node) {
66253             var name = node.name;
66254             if (!ts.isIdentifier(name)) {
66255                 return undefined;
66256             }
66257             var propertyName = ts.getMutableClone(name);
66258             ts.setEmitFlags(propertyName, 1536 | 48);
66259             var localName = ts.getMutableClone(name);
66260             ts.setEmitFlags(localName, 1536);
66261             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))));
66262         }
66263         function visitMethodDeclaration(node) {
66264             if (!shouldEmitFunctionLikeDeclaration(node)) {
66265                 return undefined;
66266             }
66267             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));
66268             if (updated !== node) {
66269                 ts.setCommentRange(updated, node);
66270                 ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
66271             }
66272             return updated;
66273         }
66274         function shouldEmitAccessorDeclaration(node) {
66275             return !(ts.nodeIsMissing(node.body) && ts.hasModifier(node, 128));
66276         }
66277         function visitGetAccessor(node) {
66278             if (!shouldEmitAccessorDeclaration(node)) {
66279                 return undefined;
66280             }
66281             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([]));
66282             if (updated !== node) {
66283                 ts.setCommentRange(updated, node);
66284                 ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
66285             }
66286             return updated;
66287         }
66288         function visitSetAccessor(node) {
66289             if (!shouldEmitAccessorDeclaration(node)) {
66290                 return undefined;
66291             }
66292             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([]));
66293             if (updated !== node) {
66294                 ts.setCommentRange(updated, node);
66295                 ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
66296             }
66297             return updated;
66298         }
66299         function visitFunctionDeclaration(node) {
66300             if (!shouldEmitFunctionLikeDeclaration(node)) {
66301                 return ts.createNotEmittedStatement(node);
66302             }
66303             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([]));
66304             if (isExportOfNamespace(node)) {
66305                 var statements = [updated];
66306                 addExportMemberAssignment(statements, node);
66307                 return statements;
66308             }
66309             return updated;
66310         }
66311         function visitFunctionExpression(node) {
66312             if (!shouldEmitFunctionLikeDeclaration(node)) {
66313                 return ts.createOmittedExpression();
66314             }
66315             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([]));
66316             return updated;
66317         }
66318         function visitArrowFunction(node) {
66319             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));
66320             return updated;
66321         }
66322         function visitParameter(node) {
66323             if (ts.parameterIsThisKeyword(node)) {
66324                 return undefined;
66325             }
66326             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));
66327             if (updated !== node) {
66328                 ts.setCommentRange(updated, node);
66329                 ts.setTextRange(updated, ts.moveRangePastModifiers(node));
66330                 ts.setSourceMapRange(updated, ts.moveRangePastModifiers(node));
66331                 ts.setEmitFlags(updated.name, 32);
66332             }
66333             return updated;
66334         }
66335         function visitVariableStatement(node) {
66336             if (isExportOfNamespace(node)) {
66337                 var variables = ts.getInitializedVariables(node.declarationList);
66338                 if (variables.length === 0) {
66339                     return undefined;
66340                 }
66341                 return ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node);
66342             }
66343             else {
66344                 return ts.visitEachChild(node, visitor, context);
66345             }
66346         }
66347         function transformInitializedVariable(node) {
66348             var name = node.name;
66349             if (ts.isBindingPattern(name)) {
66350                 return ts.flattenDestructuringAssignment(node, visitor, context, 0, false, createNamespaceExportExpression);
66351             }
66352             else {
66353                 return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression)), node);
66354             }
66355         }
66356         function visitVariableDeclaration(node) {
66357             return ts.updateTypeScriptVariableDeclaration(node, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression));
66358         }
66359         function visitParenthesizedExpression(node) {
66360             var innerExpression = ts.skipOuterExpressions(node.expression, ~6);
66361             if (ts.isAssertionExpression(innerExpression)) {
66362                 var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
66363                 if (ts.length(ts.getLeadingCommentRangesOfNode(expression, currentSourceFile))) {
66364                     return ts.updateParen(node, expression);
66365                 }
66366                 return ts.createPartiallyEmittedExpression(expression, node);
66367             }
66368             return ts.visitEachChild(node, visitor, context);
66369         }
66370         function visitAssertionExpression(node) {
66371             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
66372             return ts.createPartiallyEmittedExpression(expression, node);
66373         }
66374         function visitNonNullExpression(node) {
66375             var expression = ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression);
66376             return ts.createPartiallyEmittedExpression(expression, node);
66377         }
66378         function visitCallExpression(node) {
66379             return ts.updateCall(node, ts.visitNode(node.expression, visitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression));
66380         }
66381         function visitNewExpression(node) {
66382             return ts.updateNew(node, ts.visitNode(node.expression, visitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression));
66383         }
66384         function visitTaggedTemplateExpression(node) {
66385             return ts.updateTaggedTemplate(node, ts.visitNode(node.tag, visitor, ts.isExpression), undefined, ts.visitNode(node.template, visitor, ts.isExpression));
66386         }
66387         function visitJsxSelfClosingElement(node) {
66388             return ts.updateJsxSelfClosingElement(node, ts.visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), undefined, ts.visitNode(node.attributes, visitor, ts.isJsxAttributes));
66389         }
66390         function visitJsxJsxOpeningElement(node) {
66391             return ts.updateJsxOpeningElement(node, ts.visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), undefined, ts.visitNode(node.attributes, visitor, ts.isJsxAttributes));
66392         }
66393         function shouldEmitEnumDeclaration(node) {
66394             return !ts.isEnumConst(node)
66395                 || compilerOptions.preserveConstEnums
66396                 || compilerOptions.isolatedModules;
66397         }
66398         function visitEnumDeclaration(node) {
66399             if (!shouldEmitEnumDeclaration(node)) {
66400                 return ts.createNotEmittedStatement(node);
66401             }
66402             var statements = [];
66403             var emitFlags = 2;
66404             var varAdded = addVarForEnumOrModuleDeclaration(statements, node);
66405             if (varAdded) {
66406                 if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) {
66407                     emitFlags |= 512;
66408                 }
66409             }
66410             var parameterName = getNamespaceParameterName(node);
66411             var containerName = getNamespaceContainerName(node);
66412             var exportName = ts.hasModifier(node, 1)
66413                 ? ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true)
66414                 : ts.getLocalName(node, false, true);
66415             var moduleArg = ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral()));
66416             if (hasNamespaceQualifiedExportName(node)) {
66417                 var localName = ts.getLocalName(node, false, true);
66418                 moduleArg = ts.createAssignment(localName, moduleArg);
66419             }
66420             var enumStatement = ts.createExpressionStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [moduleArg]));
66421             ts.setOriginalNode(enumStatement, node);
66422             if (varAdded) {
66423                 ts.setSyntheticLeadingComments(enumStatement, undefined);
66424                 ts.setSyntheticTrailingComments(enumStatement, undefined);
66425             }
66426             ts.setTextRange(enumStatement, node);
66427             ts.addEmitFlags(enumStatement, emitFlags);
66428             statements.push(enumStatement);
66429             statements.push(ts.createEndOfDeclarationMarker(node));
66430             return statements;
66431         }
66432         function transformEnumBody(node, localName) {
66433             var savedCurrentNamespaceLocalName = currentNamespaceContainerName;
66434             currentNamespaceContainerName = localName;
66435             var statements = [];
66436             startLexicalEnvironment();
66437             var members = ts.map(node.members, transformEnumMember);
66438             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
66439             ts.addRange(statements, members);
66440             currentNamespaceContainerName = savedCurrentNamespaceLocalName;
66441             return ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), node.members), true);
66442         }
66443         function transformEnumMember(member) {
66444             var name = getExpressionForPropertyName(member, false);
66445             var valueExpression = transformEnumMemberDeclarationValue(member);
66446             var innerAssignment = ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, name), valueExpression);
66447             var outerAssignment = valueExpression.kind === 10 ?
66448                 innerAssignment :
66449                 ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, innerAssignment), name);
66450             return ts.setTextRange(ts.createExpressionStatement(ts.setTextRange(outerAssignment, member)), member);
66451         }
66452         function transformEnumMemberDeclarationValue(member) {
66453             var value = resolver.getConstantValue(member);
66454             if (value !== undefined) {
66455                 return ts.createLiteral(value);
66456             }
66457             else {
66458                 enableSubstitutionForNonQualifiedEnumMembers();
66459                 if (member.initializer) {
66460                     return ts.visitNode(member.initializer, visitor, ts.isExpression);
66461                 }
66462                 else {
66463                     return ts.createVoidZero();
66464                 }
66465             }
66466         }
66467         function shouldEmitModuleDeclaration(nodeIn) {
66468             var node = ts.getParseTreeNode(nodeIn, ts.isModuleDeclaration);
66469             if (!node) {
66470                 return true;
66471             }
66472             return ts.isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules);
66473         }
66474         function hasNamespaceQualifiedExportName(node) {
66475             return isExportOfNamespace(node)
66476                 || (isExternalModuleExport(node)
66477                     && moduleKind !== ts.ModuleKind.ES2015
66478                     && moduleKind !== ts.ModuleKind.ES2020
66479                     && moduleKind !== ts.ModuleKind.ESNext
66480                     && moduleKind !== ts.ModuleKind.System);
66481         }
66482         function recordEmittedDeclarationInScope(node) {
66483             if (!currentScopeFirstDeclarationsOfName) {
66484                 currentScopeFirstDeclarationsOfName = ts.createUnderscoreEscapedMap();
66485             }
66486             var name = declaredNameInScope(node);
66487             if (!currentScopeFirstDeclarationsOfName.has(name)) {
66488                 currentScopeFirstDeclarationsOfName.set(name, node);
66489             }
66490         }
66491         function isFirstEmittedDeclarationInScope(node) {
66492             if (currentScopeFirstDeclarationsOfName) {
66493                 var name = declaredNameInScope(node);
66494                 return currentScopeFirstDeclarationsOfName.get(name) === node;
66495             }
66496             return true;
66497         }
66498         function declaredNameInScope(node) {
66499             ts.Debug.assertNode(node.name, ts.isIdentifier);
66500             return node.name.escapedText;
66501         }
66502         function addVarForEnumOrModuleDeclaration(statements, node) {
66503             var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([
66504                 ts.createVariableDeclaration(ts.getLocalName(node, false, true))
66505             ], currentLexicalScope.kind === 290 ? 0 : 1));
66506             ts.setOriginalNode(statement, node);
66507             recordEmittedDeclarationInScope(node);
66508             if (isFirstEmittedDeclarationInScope(node)) {
66509                 if (node.kind === 248) {
66510                     ts.setSourceMapRange(statement.declarationList, node);
66511                 }
66512                 else {
66513                     ts.setSourceMapRange(statement, node);
66514                 }
66515                 ts.setCommentRange(statement, node);
66516                 ts.addEmitFlags(statement, 1024 | 4194304);
66517                 statements.push(statement);
66518                 return true;
66519             }
66520             else {
66521                 var mergeMarker = ts.createMergeDeclarationMarker(statement);
66522                 ts.setEmitFlags(mergeMarker, 1536 | 4194304);
66523                 statements.push(mergeMarker);
66524                 return false;
66525             }
66526         }
66527         function visitModuleDeclaration(node) {
66528             if (!shouldEmitModuleDeclaration(node)) {
66529                 return ts.createNotEmittedStatement(node);
66530             }
66531             ts.Debug.assertNode(node.name, ts.isIdentifier, "A TypeScript namespace should have an Identifier name.");
66532             enableSubstitutionForNamespaceExports();
66533             var statements = [];
66534             var emitFlags = 2;
66535             var varAdded = addVarForEnumOrModuleDeclaration(statements, node);
66536             if (varAdded) {
66537                 if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) {
66538                     emitFlags |= 512;
66539                 }
66540             }
66541             var parameterName = getNamespaceParameterName(node);
66542             var containerName = getNamespaceContainerName(node);
66543             var exportName = ts.hasModifier(node, 1)
66544                 ? ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true)
66545                 : ts.getLocalName(node, false, true);
66546             var moduleArg = ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral()));
66547             if (hasNamespaceQualifiedExportName(node)) {
66548                 var localName = ts.getLocalName(node, false, true);
66549                 moduleArg = ts.createAssignment(localName, moduleArg);
66550             }
66551             var moduleStatement = ts.createExpressionStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg]));
66552             ts.setOriginalNode(moduleStatement, node);
66553             if (varAdded) {
66554                 ts.setSyntheticLeadingComments(moduleStatement, undefined);
66555                 ts.setSyntheticTrailingComments(moduleStatement, undefined);
66556             }
66557             ts.setTextRange(moduleStatement, node);
66558             ts.addEmitFlags(moduleStatement, emitFlags);
66559             statements.push(moduleStatement);
66560             statements.push(ts.createEndOfDeclarationMarker(node));
66561             return statements;
66562         }
66563         function transformModuleBody(node, namespaceLocalName) {
66564             var savedCurrentNamespaceContainerName = currentNamespaceContainerName;
66565             var savedCurrentNamespace = currentNamespace;
66566             var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName;
66567             currentNamespaceContainerName = namespaceLocalName;
66568             currentNamespace = node;
66569             currentScopeFirstDeclarationsOfName = undefined;
66570             var statements = [];
66571             startLexicalEnvironment();
66572             var statementsLocation;
66573             var blockLocation;
66574             if (node.body) {
66575                 if (node.body.kind === 250) {
66576                     saveStateAndInvoke(node.body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); });
66577                     statementsLocation = node.body.statements;
66578                     blockLocation = node.body;
66579                 }
66580                 else {
66581                     var result = visitModuleDeclaration(node.body);
66582                     if (result) {
66583                         if (ts.isArray(result)) {
66584                             ts.addRange(statements, result);
66585                         }
66586                         else {
66587                             statements.push(result);
66588                         }
66589                     }
66590                     var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body;
66591                     statementsLocation = ts.moveRangePos(moduleBlock.statements, -1);
66592                 }
66593             }
66594             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
66595             currentNamespaceContainerName = savedCurrentNamespaceContainerName;
66596             currentNamespace = savedCurrentNamespace;
66597             currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName;
66598             var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true);
66599             ts.setTextRange(block, blockLocation);
66600             if (!node.body || node.body.kind !== 250) {
66601                 ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536);
66602             }
66603             return block;
66604         }
66605         function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) {
66606             if (moduleDeclaration.body.kind === 249) {
66607                 var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body);
66608                 return recursiveInnerModule || moduleDeclaration.body;
66609             }
66610         }
66611         function visitImportDeclaration(node) {
66612             if (!node.importClause) {
66613                 return node;
66614             }
66615             if (node.importClause.isTypeOnly) {
66616                 return undefined;
66617             }
66618             var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause);
66619             return importClause ||
66620                 compilerOptions.importsNotUsedAsValues === 1 ||
66621                 compilerOptions.importsNotUsedAsValues === 2
66622                 ? ts.updateImportDeclaration(node, undefined, undefined, importClause, node.moduleSpecifier)
66623                 : undefined;
66624         }
66625         function visitImportClause(node) {
66626             if (node.isTypeOnly) {
66627                 return undefined;
66628             }
66629             var name = resolver.isReferencedAliasDeclaration(node) ? node.name : undefined;
66630             var namedBindings = ts.visitNode(node.namedBindings, visitNamedImportBindings, ts.isNamedImportBindings);
66631             return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings, false) : undefined;
66632         }
66633         function visitNamedImportBindings(node) {
66634             if (node.kind === 256) {
66635                 return resolver.isReferencedAliasDeclaration(node) ? node : undefined;
66636             }
66637             else {
66638                 var elements = ts.visitNodes(node.elements, visitImportSpecifier, ts.isImportSpecifier);
66639                 return ts.some(elements) ? ts.updateNamedImports(node, elements) : undefined;
66640             }
66641         }
66642         function visitImportSpecifier(node) {
66643             return resolver.isReferencedAliasDeclaration(node) ? node : undefined;
66644         }
66645         function visitExportAssignment(node) {
66646             return resolver.isValueAliasDeclaration(node)
66647                 ? ts.visitEachChild(node, visitor, context)
66648                 : undefined;
66649         }
66650         function visitExportDeclaration(node) {
66651             if (node.isTypeOnly) {
66652                 return undefined;
66653             }
66654             if (!node.exportClause || ts.isNamespaceExport(node.exportClause)) {
66655                 return node;
66656             }
66657             if (!resolver.isValueAliasDeclaration(node)) {
66658                 return undefined;
66659             }
66660             var exportClause = ts.visitNode(node.exportClause, visitNamedExportBindings, ts.isNamedExportBindings);
66661             return exportClause
66662                 ? ts.updateExportDeclaration(node, undefined, undefined, exportClause, node.moduleSpecifier, node.isTypeOnly)
66663                 : undefined;
66664         }
66665         function visitNamedExports(node) {
66666             var elements = ts.visitNodes(node.elements, visitExportSpecifier, ts.isExportSpecifier);
66667             return ts.some(elements) ? ts.updateNamedExports(node, elements) : undefined;
66668         }
66669         function visitNamespaceExports(node) {
66670             return ts.updateNamespaceExport(node, ts.visitNode(node.name, visitor, ts.isIdentifier));
66671         }
66672         function visitNamedExportBindings(node) {
66673             return ts.isNamespaceExport(node) ? visitNamespaceExports(node) : visitNamedExports(node);
66674         }
66675         function visitExportSpecifier(node) {
66676             return resolver.isValueAliasDeclaration(node) ? node : undefined;
66677         }
66678         function shouldEmitImportEqualsDeclaration(node) {
66679             return resolver.isReferencedAliasDeclaration(node)
66680                 || (!ts.isExternalModule(currentSourceFile)
66681                     && resolver.isTopLevelValueImportEqualsWithEntityName(node));
66682         }
66683         function visitImportEqualsDeclaration(node) {
66684             if (ts.isExternalModuleImportEqualsDeclaration(node)) {
66685                 var isReferenced = resolver.isReferencedAliasDeclaration(node);
66686                 if (!isReferenced && compilerOptions.importsNotUsedAsValues === 1) {
66687                     return ts.setOriginalNode(ts.setTextRange(ts.createImportDeclaration(undefined, undefined, undefined, node.moduleReference.expression), node), node);
66688                 }
66689                 return isReferenced ? ts.visitEachChild(node, visitor, context) : undefined;
66690             }
66691             if (!shouldEmitImportEqualsDeclaration(node)) {
66692                 return undefined;
66693             }
66694             var moduleReference = ts.createExpressionFromEntityName(node.moduleReference);
66695             ts.setEmitFlags(moduleReference, 1536 | 2048);
66696             if (isNamedExternalModuleExport(node) || !isExportOfNamespace(node)) {
66697                 return ts.setOriginalNode(ts.setTextRange(ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([
66698                     ts.setOriginalNode(ts.createVariableDeclaration(node.name, undefined, moduleReference), node)
66699                 ])), node), node);
66700             }
66701             else {
66702                 return ts.setOriginalNode(createNamespaceExport(node.name, moduleReference, node), node);
66703             }
66704         }
66705         function isExportOfNamespace(node) {
66706             return currentNamespace !== undefined && ts.hasModifier(node, 1);
66707         }
66708         function isExternalModuleExport(node) {
66709             return currentNamespace === undefined && ts.hasModifier(node, 1);
66710         }
66711         function isNamedExternalModuleExport(node) {
66712             return isExternalModuleExport(node)
66713                 && !ts.hasModifier(node, 512);
66714         }
66715         function isDefaultExternalModuleExport(node) {
66716             return isExternalModuleExport(node)
66717                 && ts.hasModifier(node, 512);
66718         }
66719         function expressionToStatement(expression) {
66720             return ts.createExpressionStatement(expression);
66721         }
66722         function addExportMemberAssignment(statements, node) {
66723             var expression = ts.createAssignment(ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true), ts.getLocalName(node));
66724             ts.setSourceMapRange(expression, ts.createRange(node.name ? node.name.pos : node.pos, node.end));
66725             var statement = ts.createExpressionStatement(expression);
66726             ts.setSourceMapRange(statement, ts.createRange(-1, node.end));
66727             statements.push(statement);
66728         }
66729         function createNamespaceExport(exportName, exportValue, location) {
66730             return ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, false, true), exportValue)), location);
66731         }
66732         function createNamespaceExportExpression(exportName, exportValue, location) {
66733             return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue), location);
66734         }
66735         function getNamespaceMemberNameWithSourceMapsAndWithoutComments(name) {
66736             return ts.getNamespaceMemberName(currentNamespaceContainerName, name, false, true);
66737         }
66738         function getNamespaceParameterName(node) {
66739             var name = ts.getGeneratedNameForNode(node);
66740             ts.setSourceMapRange(name, node.name);
66741             return name;
66742         }
66743         function getNamespaceContainerName(node) {
66744             return ts.getGeneratedNameForNode(node);
66745         }
66746         function getClassAliasIfNeeded(node) {
66747             if (resolver.getNodeCheckFlags(node) & 16777216) {
66748                 enableSubstitutionForClassAliases();
66749                 var classAlias = ts.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.idText(node.name) : "default");
66750                 classAliases[ts.getOriginalNodeId(node)] = classAlias;
66751                 hoistVariableDeclaration(classAlias);
66752                 return classAlias;
66753             }
66754         }
66755         function getClassPrototype(node) {
66756             return ts.createPropertyAccess(ts.getDeclarationName(node), "prototype");
66757         }
66758         function getClassMemberPrefix(node, member) {
66759             return ts.hasModifier(member, 32)
66760                 ? ts.getDeclarationName(node)
66761                 : getClassPrototype(node);
66762         }
66763         function enableSubstitutionForNonQualifiedEnumMembers() {
66764             if ((enabledSubstitutions & 8) === 0) {
66765                 enabledSubstitutions |= 8;
66766                 context.enableSubstitution(75);
66767             }
66768         }
66769         function enableSubstitutionForClassAliases() {
66770             if ((enabledSubstitutions & 1) === 0) {
66771                 enabledSubstitutions |= 1;
66772                 context.enableSubstitution(75);
66773                 classAliases = [];
66774             }
66775         }
66776         function enableSubstitutionForNamespaceExports() {
66777             if ((enabledSubstitutions & 2) === 0) {
66778                 enabledSubstitutions |= 2;
66779                 context.enableSubstitution(75);
66780                 context.enableSubstitution(282);
66781                 context.enableEmitNotification(249);
66782             }
66783         }
66784         function isTransformedModuleDeclaration(node) {
66785             return ts.getOriginalNode(node).kind === 249;
66786         }
66787         function isTransformedEnumDeclaration(node) {
66788             return ts.getOriginalNode(node).kind === 248;
66789         }
66790         function onEmitNode(hint, node, emitCallback) {
66791             var savedApplicableSubstitutions = applicableSubstitutions;
66792             var savedCurrentSourceFile = currentSourceFile;
66793             if (ts.isSourceFile(node)) {
66794                 currentSourceFile = node;
66795             }
66796             if (enabledSubstitutions & 2 && isTransformedModuleDeclaration(node)) {
66797                 applicableSubstitutions |= 2;
66798             }
66799             if (enabledSubstitutions & 8 && isTransformedEnumDeclaration(node)) {
66800                 applicableSubstitutions |= 8;
66801             }
66802             previousOnEmitNode(hint, node, emitCallback);
66803             applicableSubstitutions = savedApplicableSubstitutions;
66804             currentSourceFile = savedCurrentSourceFile;
66805         }
66806         function onSubstituteNode(hint, node) {
66807             node = previousOnSubstituteNode(hint, node);
66808             if (hint === 1) {
66809                 return substituteExpression(node);
66810             }
66811             else if (ts.isShorthandPropertyAssignment(node)) {
66812                 return substituteShorthandPropertyAssignment(node);
66813             }
66814             return node;
66815         }
66816         function substituteShorthandPropertyAssignment(node) {
66817             if (enabledSubstitutions & 2) {
66818                 var name = node.name;
66819                 var exportedName = trySubstituteNamespaceExportedName(name);
66820                 if (exportedName) {
66821                     if (node.objectAssignmentInitializer) {
66822                         var initializer = ts.createAssignment(exportedName, node.objectAssignmentInitializer);
66823                         return ts.setTextRange(ts.createPropertyAssignment(name, initializer), node);
66824                     }
66825                     return ts.setTextRange(ts.createPropertyAssignment(name, exportedName), node);
66826                 }
66827             }
66828             return node;
66829         }
66830         function substituteExpression(node) {
66831             switch (node.kind) {
66832                 case 75:
66833                     return substituteExpressionIdentifier(node);
66834                 case 194:
66835                     return substitutePropertyAccessExpression(node);
66836                 case 195:
66837                     return substituteElementAccessExpression(node);
66838             }
66839             return node;
66840         }
66841         function substituteExpressionIdentifier(node) {
66842             return trySubstituteClassAlias(node)
66843                 || trySubstituteNamespaceExportedName(node)
66844                 || node;
66845         }
66846         function trySubstituteClassAlias(node) {
66847             if (enabledSubstitutions & 1) {
66848                 if (resolver.getNodeCheckFlags(node) & 33554432) {
66849                     var declaration = resolver.getReferencedValueDeclaration(node);
66850                     if (declaration) {
66851                         var classAlias = classAliases[declaration.id];
66852                         if (classAlias) {
66853                             var clone_1 = ts.getSynthesizedClone(classAlias);
66854                             ts.setSourceMapRange(clone_1, node);
66855                             ts.setCommentRange(clone_1, node);
66856                             return clone_1;
66857                         }
66858                     }
66859                 }
66860             }
66861             return undefined;
66862         }
66863         function trySubstituteNamespaceExportedName(node) {
66864             if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) {
66865                 var container = resolver.getReferencedExportContainer(node, false);
66866                 if (container && container.kind !== 290) {
66867                     var substitute = (applicableSubstitutions & 2 && container.kind === 249) ||
66868                         (applicableSubstitutions & 8 && container.kind === 248);
66869                     if (substitute) {
66870                         return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), node);
66871                     }
66872                 }
66873             }
66874             return undefined;
66875         }
66876         function substitutePropertyAccessExpression(node) {
66877             return substituteConstantValue(node);
66878         }
66879         function substituteElementAccessExpression(node) {
66880             return substituteConstantValue(node);
66881         }
66882         function substituteConstantValue(node) {
66883             var constantValue = tryGetConstEnumValue(node);
66884             if (constantValue !== undefined) {
66885                 ts.setConstantValue(node, constantValue);
66886                 var substitute = ts.createLiteral(constantValue);
66887                 if (!compilerOptions.removeComments) {
66888                     var originalNode = ts.getOriginalNode(node, ts.isAccessExpression);
66889                     var propertyName = ts.isPropertyAccessExpression(originalNode)
66890                         ? ts.declarationNameToString(originalNode.name)
66891                         : ts.getTextOfNode(originalNode.argumentExpression);
66892                     ts.addSyntheticTrailingComment(substitute, 3, " " + propertyName + " ");
66893                 }
66894                 return substitute;
66895             }
66896             return node;
66897         }
66898         function tryGetConstEnumValue(node) {
66899             if (compilerOptions.isolatedModules) {
66900                 return undefined;
66901             }
66902             return ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node) ? resolver.getConstantValue(node) : undefined;
66903         }
66904     }
66905     ts.transformTypeScript = transformTypeScript;
66906     function createDecorateHelper(context, decoratorExpressions, target, memberName, descriptor, location) {
66907         var argumentsArray = [];
66908         argumentsArray.push(ts.createArrayLiteral(decoratorExpressions, true));
66909         argumentsArray.push(target);
66910         if (memberName) {
66911             argumentsArray.push(memberName);
66912             if (descriptor) {
66913                 argumentsArray.push(descriptor);
66914             }
66915         }
66916         context.requestEmitHelper(ts.decorateHelper);
66917         return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__decorate"), undefined, argumentsArray), location);
66918     }
66919     ts.decorateHelper = {
66920         name: "typescript:decorate",
66921         importName: "__decorate",
66922         scoped: false,
66923         priority: 2,
66924         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            };"
66925     };
66926     function createMetadataHelper(context, metadataKey, metadataValue) {
66927         context.requestEmitHelper(ts.metadataHelper);
66928         return ts.createCall(ts.getUnscopedHelperName("__metadata"), undefined, [
66929             ts.createLiteral(metadataKey),
66930             metadataValue
66931         ]);
66932     }
66933     ts.metadataHelper = {
66934         name: "typescript:metadata",
66935         importName: "__metadata",
66936         scoped: false,
66937         priority: 3,
66938         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            };"
66939     };
66940     function createParamHelper(context, expression, parameterOffset, location) {
66941         context.requestEmitHelper(ts.paramHelper);
66942         return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__param"), undefined, [
66943             ts.createLiteral(parameterOffset),
66944             expression
66945         ]), location);
66946     }
66947     ts.paramHelper = {
66948         name: "typescript:param",
66949         importName: "__param",
66950         scoped: false,
66951         priority: 4,
66952         text: "\n            var __param = (this && this.__param) || function (paramIndex, decorator) {\n                return function (target, key) { decorator(target, key, paramIndex); }\n            };"
66953     };
66954 })(ts || (ts = {}));
66955 var ts;
66956 (function (ts) {
66957     function transformClassFields(context) {
66958         var hoistVariableDeclaration = context.hoistVariableDeclaration, endLexicalEnvironment = context.endLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment;
66959         var resolver = context.getEmitResolver();
66960         var compilerOptions = context.getCompilerOptions();
66961         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
66962         var shouldTransformPrivateFields = languageVersion < 99;
66963         var previousOnSubstituteNode = context.onSubstituteNode;
66964         context.onSubstituteNode = onSubstituteNode;
66965         var enabledSubstitutions;
66966         var classAliases;
66967         var pendingExpressions;
66968         var pendingStatements;
66969         var privateIdentifierEnvironmentStack = [];
66970         var currentPrivateIdentifierEnvironment;
66971         return ts.chainBundle(transformSourceFile);
66972         function transformSourceFile(node) {
66973             var options = context.getCompilerOptions();
66974             if (node.isDeclarationFile
66975                 || options.useDefineForClassFields && options.target === 99) {
66976                 return node;
66977             }
66978             var visited = ts.visitEachChild(node, visitor, context);
66979             ts.addEmitHelpers(visited, context.readEmitHelpers());
66980             return visited;
66981         }
66982         function visitor(node) {
66983             if (!(node.transformFlags & 4194304))
66984                 return node;
66985             switch (node.kind) {
66986                 case 214:
66987                 case 245:
66988                     return visitClassLike(node);
66989                 case 159:
66990                     return visitPropertyDeclaration(node);
66991                 case 225:
66992                     return visitVariableStatement(node);
66993                 case 154:
66994                     return visitComputedPropertyName(node);
66995                 case 194:
66996                     return visitPropertyAccessExpression(node);
66997                 case 207:
66998                     return visitPrefixUnaryExpression(node);
66999                 case 208:
67000                     return visitPostfixUnaryExpression(node, false);
67001                 case 196:
67002                     return visitCallExpression(node);
67003                 case 209:
67004                     return visitBinaryExpression(node);
67005                 case 76:
67006                     return visitPrivateIdentifier(node);
67007                 case 226:
67008                     return visitExpressionStatement(node);
67009                 case 230:
67010                     return visitForStatement(node);
67011                 case 198:
67012                     return visitTaggedTemplateExpression(node);
67013             }
67014             return ts.visitEachChild(node, visitor, context);
67015         }
67016         function visitorDestructuringTarget(node) {
67017             switch (node.kind) {
67018                 case 193:
67019                 case 192:
67020                     return visitAssignmentPattern(node);
67021                 default:
67022                     return visitor(node);
67023             }
67024         }
67025         function visitPrivateIdentifier(node) {
67026             if (!shouldTransformPrivateFields) {
67027                 return node;
67028             }
67029             return ts.setOriginalNode(ts.createIdentifier(""), node);
67030         }
67031         function classElementVisitor(node) {
67032             switch (node.kind) {
67033                 case 162:
67034                     return undefined;
67035                 case 163:
67036                 case 164:
67037                 case 161:
67038                     return ts.visitEachChild(node, classElementVisitor, context);
67039                 case 159:
67040                     return visitPropertyDeclaration(node);
67041                 case 154:
67042                     return visitComputedPropertyName(node);
67043                 case 222:
67044                     return node;
67045                 default:
67046                     return visitor(node);
67047             }
67048         }
67049         function visitVariableStatement(node) {
67050             var savedPendingStatements = pendingStatements;
67051             pendingStatements = [];
67052             var visitedNode = ts.visitEachChild(node, visitor, context);
67053             var statement = ts.some(pendingStatements) ? __spreadArrays([visitedNode], pendingStatements) :
67054                 visitedNode;
67055             pendingStatements = savedPendingStatements;
67056             return statement;
67057         }
67058         function visitComputedPropertyName(name) {
67059             var node = ts.visitEachChild(name, visitor, context);
67060             if (ts.some(pendingExpressions)) {
67061                 var expressions = pendingExpressions;
67062                 expressions.push(name.expression);
67063                 pendingExpressions = [];
67064                 node = ts.updateComputedPropertyName(node, ts.inlineExpressions(expressions));
67065             }
67066             return node;
67067         }
67068         function visitPropertyDeclaration(node) {
67069             ts.Debug.assert(!ts.some(node.decorators));
67070             if (!shouldTransformPrivateFields && ts.isPrivateIdentifier(node.name)) {
67071                 return ts.updateProperty(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, undefined, undefined, undefined);
67072             }
67073             var expr = getPropertyNameExpressionIfNeeded(node.name, !!node.initializer || !!context.getCompilerOptions().useDefineForClassFields);
67074             if (expr && !ts.isSimpleInlineableExpression(expr)) {
67075                 (pendingExpressions || (pendingExpressions = [])).push(expr);
67076             }
67077             return undefined;
67078         }
67079         function createPrivateIdentifierAccess(info, receiver) {
67080             receiver = ts.visitNode(receiver, visitor, ts.isExpression);
67081             switch (info.placement) {
67082                 case 0:
67083                     return createClassPrivateFieldGetHelper(context, ts.nodeIsSynthesized(receiver) ? receiver : ts.getSynthesizedClone(receiver), info.weakMapName);
67084                 default: return ts.Debug.fail("Unexpected private identifier placement");
67085             }
67086         }
67087         function visitPropertyAccessExpression(node) {
67088             if (shouldTransformPrivateFields && ts.isPrivateIdentifier(node.name)) {
67089                 var privateIdentifierInfo = accessPrivateIdentifier(node.name);
67090                 if (privateIdentifierInfo) {
67091                     return ts.setOriginalNode(createPrivateIdentifierAccess(privateIdentifierInfo, node.expression), node);
67092                 }
67093             }
67094             return ts.visitEachChild(node, visitor, context);
67095         }
67096         function visitPrefixUnaryExpression(node) {
67097             if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) {
67098                 var operator = node.operator === 45 ?
67099                     39 : node.operator === 46 ?
67100                     40 : undefined;
67101                 var info = void 0;
67102                 if (operator && (info = accessPrivateIdentifier(node.operand.name))) {
67103                     var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression);
67104                     var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression;
67105                     var existingValue = ts.createPrefix(39, createPrivateIdentifierAccess(info, readExpression));
67106                     return ts.setOriginalNode(createPrivateIdentifierAssignment(info, initializeExpression || readExpression, ts.createBinary(existingValue, operator, ts.createLiteral(1)), 62), node);
67107                 }
67108             }
67109             return ts.visitEachChild(node, visitor, context);
67110         }
67111         function visitPostfixUnaryExpression(node, valueIsDiscarded) {
67112             if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) {
67113                 var operator = node.operator === 45 ?
67114                     39 : node.operator === 46 ?
67115                     40 : undefined;
67116                 var info = void 0;
67117                 if (operator && (info = accessPrivateIdentifier(node.operand.name))) {
67118                     var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression);
67119                     var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression;
67120                     var existingValue = ts.createPrefix(39, createPrivateIdentifierAccess(info, readExpression));
67121                     var returnValue = valueIsDiscarded ? undefined : ts.createTempVariable(hoistVariableDeclaration);
67122                     return ts.setOriginalNode(ts.inlineExpressions(ts.compact([
67123                         createPrivateIdentifierAssignment(info, initializeExpression || readExpression, ts.createBinary(returnValue ? ts.createAssignment(returnValue, existingValue) : existingValue, operator, ts.createLiteral(1)), 62),
67124                         returnValue
67125                     ])), node);
67126                 }
67127             }
67128             return ts.visitEachChild(node, visitor, context);
67129         }
67130         function visitForStatement(node) {
67131             if (node.incrementor && ts.isPostfixUnaryExpression(node.incrementor)) {
67132                 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));
67133             }
67134             return ts.visitEachChild(node, visitor, context);
67135         }
67136         function visitExpressionStatement(node) {
67137             if (ts.isPostfixUnaryExpression(node.expression)) {
67138                 return ts.updateExpressionStatement(node, visitPostfixUnaryExpression(node.expression, true));
67139             }
67140             return ts.visitEachChild(node, visitor, context);
67141         }
67142         function createCopiableReceiverExpr(receiver) {
67143             var clone = ts.nodeIsSynthesized(receiver) ? receiver : ts.getSynthesizedClone(receiver);
67144             if (ts.isSimpleInlineableExpression(receiver)) {
67145                 return { readExpression: clone, initializeExpression: undefined };
67146             }
67147             var readExpression = ts.createTempVariable(hoistVariableDeclaration);
67148             var initializeExpression = ts.createAssignment(readExpression, clone);
67149             return { readExpression: readExpression, initializeExpression: initializeExpression };
67150         }
67151         function visitCallExpression(node) {
67152             if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.expression)) {
67153                 var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration, languageVersion), thisArg = _a.thisArg, target = _a.target;
67154                 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)));
67155             }
67156             return ts.visitEachChild(node, visitor, context);
67157         }
67158         function visitTaggedTemplateExpression(node) {
67159             if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.tag)) {
67160                 var _a = ts.createCallBinding(node.tag, hoistVariableDeclaration, languageVersion), thisArg = _a.thisArg, target = _a.target;
67161                 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));
67162             }
67163             return ts.visitEachChild(node, visitor, context);
67164         }
67165         function visitBinaryExpression(node) {
67166             if (shouldTransformPrivateFields) {
67167                 if (ts.isDestructuringAssignment(node)) {
67168                     var savedPendingExpressions = pendingExpressions;
67169                     pendingExpressions = undefined;
67170                     node = ts.updateBinary(node, ts.visitNode(node.left, visitorDestructuringTarget), ts.visitNode(node.right, visitor), node.operatorToken);
67171                     var expr = ts.some(pendingExpressions) ?
67172                         ts.inlineExpressions(ts.compact(__spreadArrays(pendingExpressions, [node]))) :
67173                         node;
67174                     pendingExpressions = savedPendingExpressions;
67175                     return expr;
67176                 }
67177                 if (ts.isAssignmentExpression(node) && ts.isPrivateIdentifierPropertyAccessExpression(node.left)) {
67178                     var info = accessPrivateIdentifier(node.left.name);
67179                     if (info) {
67180                         return ts.setOriginalNode(createPrivateIdentifierAssignment(info, node.left.expression, node.right, node.operatorToken.kind), node);
67181                     }
67182                 }
67183             }
67184             return ts.visitEachChild(node, visitor, context);
67185         }
67186         function createPrivateIdentifierAssignment(info, receiver, right, operator) {
67187             switch (info.placement) {
67188                 case 0: {
67189                     return createPrivateIdentifierInstanceFieldAssignment(info, receiver, right, operator);
67190                 }
67191                 default: return ts.Debug.fail("Unexpected private identifier placement");
67192             }
67193         }
67194         function createPrivateIdentifierInstanceFieldAssignment(info, receiver, right, operator) {
67195             receiver = ts.visitNode(receiver, visitor, ts.isExpression);
67196             right = ts.visitNode(right, visitor, ts.isExpression);
67197             if (ts.isCompoundAssignment(operator)) {
67198                 var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression;
67199                 return createClassPrivateFieldSetHelper(context, initializeExpression || readExpression, info.weakMapName, ts.createBinary(createClassPrivateFieldGetHelper(context, readExpression, info.weakMapName), ts.getNonAssignmentOperatorForCompoundAssignment(operator), right));
67200             }
67201             else {
67202                 return createClassPrivateFieldSetHelper(context, receiver, info.weakMapName, right);
67203             }
67204         }
67205         function visitClassLike(node) {
67206             var savedPendingExpressions = pendingExpressions;
67207             pendingExpressions = undefined;
67208             if (shouldTransformPrivateFields) {
67209                 startPrivateIdentifierEnvironment();
67210             }
67211             var result = ts.isClassDeclaration(node) ?
67212                 visitClassDeclaration(node) :
67213                 visitClassExpression(node);
67214             if (shouldTransformPrivateFields) {
67215                 endPrivateIdentifierEnvironment();
67216             }
67217             pendingExpressions = savedPendingExpressions;
67218             return result;
67219         }
67220         function doesClassElementNeedTransform(node) {
67221             return ts.isPropertyDeclaration(node) || (shouldTransformPrivateFields && node.name && ts.isPrivateIdentifier(node.name));
67222         }
67223         function visitClassDeclaration(node) {
67224             if (!ts.forEach(node.members, doesClassElementNeedTransform)) {
67225                 return ts.visitEachChild(node, visitor, context);
67226             }
67227             var extendsClauseElement = ts.getEffectiveBaseTypeNode(node);
67228             var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 100);
67229             var statements = [
67230                 ts.updateClassDeclaration(node, undefined, node.modifiers, node.name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass))
67231             ];
67232             if (ts.some(pendingExpressions)) {
67233                 statements.push(ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions)));
67234             }
67235             var staticProperties = ts.getProperties(node, true, true);
67236             if (ts.some(staticProperties)) {
67237                 addPropertyStatements(statements, staticProperties, ts.getInternalName(node));
67238             }
67239             return statements;
67240         }
67241         function visitClassExpression(node) {
67242             if (!ts.forEach(node.members, doesClassElementNeedTransform)) {
67243                 return ts.visitEachChild(node, visitor, context);
67244             }
67245             var isDecoratedClassDeclaration = ts.isClassDeclaration(ts.getOriginalNode(node));
67246             var staticProperties = ts.getProperties(node, true, true);
67247             var extendsClauseElement = ts.getEffectiveBaseTypeNode(node);
67248             var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 100);
67249             var classExpression = ts.updateClassExpression(node, node.modifiers, node.name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass));
67250             if (ts.some(staticProperties) || ts.some(pendingExpressions)) {
67251                 if (isDecoratedClassDeclaration) {
67252                     ts.Debug.assertIsDefined(pendingStatements, "Decorated classes transformed by TypeScript are expected to be within a variable declaration.");
67253                     if (pendingStatements && pendingExpressions && ts.some(pendingExpressions)) {
67254                         pendingStatements.push(ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions)));
67255                     }
67256                     if (pendingStatements && ts.some(staticProperties)) {
67257                         addPropertyStatements(pendingStatements, staticProperties, ts.getInternalName(node));
67258                     }
67259                     return classExpression;
67260                 }
67261                 else {
67262                     var expressions = [];
67263                     var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216;
67264                     var temp = ts.createTempVariable(hoistVariableDeclaration, !!isClassWithConstructorReference);
67265                     if (isClassWithConstructorReference) {
67266                         enableSubstitutionForClassAliases();
67267                         var alias = ts.getSynthesizedClone(temp);
67268                         alias.autoGenerateFlags &= ~8;
67269                         classAliases[ts.getOriginalNodeId(node)] = alias;
67270                     }
67271                     ts.setEmitFlags(classExpression, 65536 | ts.getEmitFlags(classExpression));
67272                     expressions.push(ts.startOnNewLine(ts.createAssignment(temp, classExpression)));
67273                     ts.addRange(expressions, ts.map(pendingExpressions, ts.startOnNewLine));
67274                     ts.addRange(expressions, generateInitializedPropertyExpressions(staticProperties, temp));
67275                     expressions.push(ts.startOnNewLine(temp));
67276                     return ts.inlineExpressions(expressions);
67277                 }
67278             }
67279             return classExpression;
67280         }
67281         function transformClassMembers(node, isDerivedClass) {
67282             if (shouldTransformPrivateFields) {
67283                 for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
67284                     var member = _a[_i];
67285                     if (ts.isPrivateIdentifierPropertyDeclaration(member)) {
67286                         addPrivateIdentifierToEnvironment(member.name);
67287                     }
67288                 }
67289             }
67290             var members = [];
67291             var constructor = transformConstructor(node, isDerivedClass);
67292             if (constructor) {
67293                 members.push(constructor);
67294             }
67295             ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement));
67296             return ts.setTextRange(ts.createNodeArray(members), node.members);
67297         }
67298         function isPropertyDeclarationThatRequiresConstructorStatement(member) {
67299             if (!ts.isPropertyDeclaration(member) || ts.hasStaticModifier(member)) {
67300                 return false;
67301             }
67302             if (context.getCompilerOptions().useDefineForClassFields) {
67303                 return languageVersion < 99;
67304             }
67305             return ts.isInitializedProperty(member) || shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyDeclaration(member);
67306         }
67307         function transformConstructor(node, isDerivedClass) {
67308             var constructor = ts.visitNode(ts.getFirstConstructorWithBody(node), visitor, ts.isConstructorDeclaration);
67309             var properties = node.members.filter(isPropertyDeclarationThatRequiresConstructorStatement);
67310             if (!ts.some(properties)) {
67311                 return constructor;
67312             }
67313             var parameters = ts.visitParameterList(constructor ? constructor.parameters : undefined, visitor, context);
67314             var body = transformConstructorBody(node, constructor, isDerivedClass);
67315             if (!body) {
67316                 return undefined;
67317             }
67318             return ts.startOnNewLine(ts.setOriginalNode(ts.setTextRange(ts.createConstructor(undefined, undefined, parameters !== null && parameters !== void 0 ? parameters : [], body), constructor || node), constructor));
67319         }
67320         function transformConstructorBody(node, constructor, isDerivedClass) {
67321             var useDefineForClassFields = context.getCompilerOptions().useDefineForClassFields;
67322             var properties = ts.getProperties(node, false, false);
67323             if (!useDefineForClassFields) {
67324                 properties = ts.filter(properties, function (property) { return !!property.initializer || ts.isPrivateIdentifier(property.name); });
67325             }
67326             if (!constructor && !ts.some(properties)) {
67327                 return ts.visitFunctionBody(undefined, visitor, context);
67328             }
67329             resumeLexicalEnvironment();
67330             var indexOfFirstStatement = 0;
67331             var statements = [];
67332             if (!constructor && isDerivedClass) {
67333                 statements.push(ts.createExpressionStatement(ts.createCall(ts.createSuper(), undefined, [ts.createSpread(ts.createIdentifier("arguments"))])));
67334             }
67335             if (constructor) {
67336                 indexOfFirstStatement = ts.addPrologueDirectivesAndInitialSuperCall(constructor, statements, visitor);
67337             }
67338             if (constructor === null || constructor === void 0 ? void 0 : constructor.body) {
67339                 var afterParameterProperties = ts.findIndex(constructor.body.statements, function (s) { return !ts.isParameterPropertyDeclaration(ts.getOriginalNode(s), constructor); }, indexOfFirstStatement);
67340                 if (afterParameterProperties === -1) {
67341                     afterParameterProperties = constructor.body.statements.length;
67342                 }
67343                 if (afterParameterProperties > indexOfFirstStatement) {
67344                     if (!useDefineForClassFields) {
67345                         ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement, afterParameterProperties - indexOfFirstStatement));
67346                     }
67347                     indexOfFirstStatement = afterParameterProperties;
67348                 }
67349             }
67350             addPropertyStatements(statements, properties, ts.createThis());
67351             if (constructor) {
67352                 ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement));
67353             }
67354             statements = ts.mergeLexicalEnvironment(statements, endLexicalEnvironment());
67355             return ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), constructor ? constructor.body.statements : node.members), true), constructor ? constructor.body : undefined);
67356         }
67357         function addPropertyStatements(statements, properties, receiver) {
67358             for (var _i = 0, properties_8 = properties; _i < properties_8.length; _i++) {
67359                 var property = properties_8[_i];
67360                 var expression = transformProperty(property, receiver);
67361                 if (!expression) {
67362                     continue;
67363                 }
67364                 var statement = ts.createExpressionStatement(expression);
67365                 ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
67366                 ts.setCommentRange(statement, property);
67367                 ts.setOriginalNode(statement, property);
67368                 statements.push(statement);
67369             }
67370         }
67371         function generateInitializedPropertyExpressions(properties, receiver) {
67372             var expressions = [];
67373             for (var _i = 0, properties_9 = properties; _i < properties_9.length; _i++) {
67374                 var property = properties_9[_i];
67375                 var expression = transformProperty(property, receiver);
67376                 if (!expression) {
67377                     continue;
67378                 }
67379                 ts.startOnNewLine(expression);
67380                 ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property));
67381                 ts.setCommentRange(expression, property);
67382                 ts.setOriginalNode(expression, property);
67383                 expressions.push(expression);
67384             }
67385             return expressions;
67386         }
67387         function transformProperty(property, receiver) {
67388             var emitAssignment = !context.getCompilerOptions().useDefineForClassFields;
67389             var propertyName = ts.isComputedPropertyName(property.name) && !ts.isSimpleInlineableExpression(property.name.expression)
67390                 ? ts.updateComputedPropertyName(property.name, ts.getGeneratedNameForNode(property.name))
67391                 : property.name;
67392             if (shouldTransformPrivateFields && ts.isPrivateIdentifier(propertyName)) {
67393                 var privateIdentifierInfo = accessPrivateIdentifier(propertyName);
67394                 if (privateIdentifierInfo) {
67395                     switch (privateIdentifierInfo.placement) {
67396                         case 0: {
67397                             return createPrivateInstanceFieldInitializer(receiver, ts.visitNode(property.initializer, visitor, ts.isExpression), privateIdentifierInfo.weakMapName);
67398                         }
67399                     }
67400                 }
67401                 else {
67402                     ts.Debug.fail("Undeclared private name for property declaration.");
67403                 }
67404             }
67405             if (ts.isPrivateIdentifier(propertyName) && !property.initializer) {
67406                 return undefined;
67407             }
67408             if (ts.isPrivateIdentifier(propertyName) && !property.initializer) {
67409                 return undefined;
67410             }
67411             var propertyOriginalNode = ts.getOriginalNode(property);
67412             var initializer = property.initializer || emitAssignment ? ts.visitNode(property.initializer, visitor, ts.isExpression)
67413                 : ts.isParameterPropertyDeclaration(propertyOriginalNode, propertyOriginalNode.parent) && ts.isIdentifier(propertyName) ? propertyName
67414                     : ts.createVoidZero();
67415             if (emitAssignment || ts.isPrivateIdentifier(propertyName)) {
67416                 var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, propertyName);
67417                 return ts.createAssignment(memberAccess, initializer);
67418             }
67419             else {
67420                 var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression
67421                     : ts.isIdentifier(propertyName) ? ts.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText))
67422                         : propertyName;
67423                 var descriptor = ts.createPropertyDescriptor({ value: initializer, configurable: true, writable: true, enumerable: true });
67424                 return ts.createObjectDefinePropertyCall(receiver, name, descriptor);
67425             }
67426         }
67427         function enableSubstitutionForClassAliases() {
67428             if ((enabledSubstitutions & 1) === 0) {
67429                 enabledSubstitutions |= 1;
67430                 context.enableSubstitution(75);
67431                 classAliases = [];
67432             }
67433         }
67434         function onSubstituteNode(hint, node) {
67435             node = previousOnSubstituteNode(hint, node);
67436             if (hint === 1) {
67437                 return substituteExpression(node);
67438             }
67439             return node;
67440         }
67441         function substituteExpression(node) {
67442             switch (node.kind) {
67443                 case 75:
67444                     return substituteExpressionIdentifier(node);
67445             }
67446             return node;
67447         }
67448         function substituteExpressionIdentifier(node) {
67449             return trySubstituteClassAlias(node) || node;
67450         }
67451         function trySubstituteClassAlias(node) {
67452             if (enabledSubstitutions & 1) {
67453                 if (resolver.getNodeCheckFlags(node) & 33554432) {
67454                     var declaration = resolver.getReferencedValueDeclaration(node);
67455                     if (declaration) {
67456                         var classAlias = classAliases[declaration.id];
67457                         if (classAlias) {
67458                             var clone_2 = ts.getSynthesizedClone(classAlias);
67459                             ts.setSourceMapRange(clone_2, node);
67460                             ts.setCommentRange(clone_2, node);
67461                             return clone_2;
67462                         }
67463                     }
67464                 }
67465             }
67466             return undefined;
67467         }
67468         function getPropertyNameExpressionIfNeeded(name, shouldHoist) {
67469             if (ts.isComputedPropertyName(name)) {
67470                 var expression = ts.visitNode(name.expression, visitor, ts.isExpression);
67471                 var innerExpression = ts.skipPartiallyEmittedExpressions(expression);
67472                 var inlinable = ts.isSimpleInlineableExpression(innerExpression);
67473                 var alreadyTransformed = ts.isAssignmentExpression(innerExpression) && ts.isGeneratedIdentifier(innerExpression.left);
67474                 if (!alreadyTransformed && !inlinable && shouldHoist) {
67475                     var generatedName = ts.getGeneratedNameForNode(name);
67476                     hoistVariableDeclaration(generatedName);
67477                     return ts.createAssignment(generatedName, expression);
67478                 }
67479                 return (inlinable || ts.isIdentifier(innerExpression)) ? undefined : expression;
67480             }
67481         }
67482         function startPrivateIdentifierEnvironment() {
67483             privateIdentifierEnvironmentStack.push(currentPrivateIdentifierEnvironment);
67484             currentPrivateIdentifierEnvironment = undefined;
67485         }
67486         function endPrivateIdentifierEnvironment() {
67487             currentPrivateIdentifierEnvironment = privateIdentifierEnvironmentStack.pop();
67488         }
67489         function addPrivateIdentifierToEnvironment(name) {
67490             var text = ts.getTextOfPropertyName(name);
67491             var weakMapName = ts.createOptimisticUniqueName("_" + text.substring(1));
67492             weakMapName.autoGenerateFlags |= 8;
67493             hoistVariableDeclaration(weakMapName);
67494             (currentPrivateIdentifierEnvironment || (currentPrivateIdentifierEnvironment = ts.createUnderscoreEscapedMap()))
67495                 .set(name.escapedText, { placement: 0, weakMapName: weakMapName });
67496             (pendingExpressions || (pendingExpressions = [])).push(ts.createAssignment(weakMapName, ts.createNew(ts.createIdentifier("WeakMap"), undefined, [])));
67497         }
67498         function accessPrivateIdentifier(name) {
67499             if (currentPrivateIdentifierEnvironment) {
67500                 var info = currentPrivateIdentifierEnvironment.get(name.escapedText);
67501                 if (info) {
67502                     return info;
67503                 }
67504             }
67505             for (var i = privateIdentifierEnvironmentStack.length - 1; i >= 0; --i) {
67506                 var env = privateIdentifierEnvironmentStack[i];
67507                 if (!env) {
67508                     continue;
67509                 }
67510                 var info = env.get(name.escapedText);
67511                 if (info) {
67512                     return info;
67513                 }
67514             }
67515             return undefined;
67516         }
67517         function wrapPrivateIdentifierForDestructuringTarget(node) {
67518             var parameter = ts.getGeneratedNameForNode(node);
67519             var info = accessPrivateIdentifier(node.name);
67520             if (!info) {
67521                 return ts.visitEachChild(node, visitor, context);
67522             }
67523             var receiver = node.expression;
67524             if (ts.isThisProperty(node) || ts.isSuperProperty(node) || !ts.isSimpleCopiableExpression(node.expression)) {
67525                 receiver = ts.createTempVariable(hoistVariableDeclaration);
67526                 receiver.autoGenerateFlags |= 8;
67527                 (pendingExpressions || (pendingExpressions = [])).push(ts.createBinary(receiver, 62, node.expression));
67528             }
67529             return ts.createPropertyAccess(ts.createParen(ts.createObjectLiteral([
67530                 ts.createSetAccessor(undefined, undefined, "value", [ts.createParameter(undefined, undefined, undefined, parameter, undefined, undefined, undefined)], ts.createBlock([ts.createExpressionStatement(createPrivateIdentifierAssignment(info, receiver, parameter, 62))]))
67531             ])), "value");
67532         }
67533         function visitArrayAssignmentTarget(node) {
67534             var target = ts.getTargetOfBindingOrAssignmentElement(node);
67535             if (target && ts.isPrivateIdentifierPropertyAccessExpression(target)) {
67536                 var wrapped = wrapPrivateIdentifierForDestructuringTarget(target);
67537                 if (ts.isAssignmentExpression(node)) {
67538                     return ts.updateBinary(node, wrapped, ts.visitNode(node.right, visitor, ts.isExpression), node.operatorToken);
67539                 }
67540                 else if (ts.isSpreadElement(node)) {
67541                     return ts.updateSpread(node, wrapped);
67542                 }
67543                 else {
67544                     return wrapped;
67545                 }
67546             }
67547             return ts.visitNode(node, visitorDestructuringTarget);
67548         }
67549         function visitObjectAssignmentTarget(node) {
67550             if (ts.isPropertyAssignment(node)) {
67551                 var target = ts.getTargetOfBindingOrAssignmentElement(node);
67552                 if (target && ts.isPrivateIdentifierPropertyAccessExpression(target)) {
67553                     var initializer = ts.getInitializerOfBindingOrAssignmentElement(node);
67554                     var wrapped = wrapPrivateIdentifierForDestructuringTarget(target);
67555                     return ts.updatePropertyAssignment(node, ts.visitNode(node.name, visitor), initializer ? ts.createAssignment(wrapped, ts.visitNode(initializer, visitor)) : wrapped);
67556                 }
67557                 return ts.updatePropertyAssignment(node, ts.visitNode(node.name, visitor), ts.visitNode(node.initializer, visitorDestructuringTarget));
67558             }
67559             return ts.visitNode(node, visitor);
67560         }
67561         function visitAssignmentPattern(node) {
67562             if (ts.isArrayLiteralExpression(node)) {
67563                 return ts.updateArrayLiteral(node, ts.visitNodes(node.elements, visitArrayAssignmentTarget, ts.isExpression));
67564             }
67565             else {
67566                 return ts.updateObjectLiteral(node, ts.visitNodes(node.properties, visitObjectAssignmentTarget, ts.isObjectLiteralElementLike));
67567             }
67568         }
67569     }
67570     ts.transformClassFields = transformClassFields;
67571     function createPrivateInstanceFieldInitializer(receiver, initializer, weakMapName) {
67572         return ts.createCall(ts.createPropertyAccess(weakMapName, "set"), undefined, [receiver, initializer || ts.createVoidZero()]);
67573     }
67574     ts.classPrivateFieldGetHelper = {
67575         name: "typescript:classPrivateFieldGet",
67576         scoped: false,
67577         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            };"
67578     };
67579     function createClassPrivateFieldGetHelper(context, receiver, privateField) {
67580         context.requestEmitHelper(ts.classPrivateFieldGetHelper);
67581         return ts.createCall(ts.getUnscopedHelperName("__classPrivateFieldGet"), undefined, [receiver, privateField]);
67582     }
67583     ts.classPrivateFieldSetHelper = {
67584         name: "typescript:classPrivateFieldSet",
67585         scoped: false,
67586         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            };"
67587     };
67588     function createClassPrivateFieldSetHelper(context, receiver, privateField, value) {
67589         context.requestEmitHelper(ts.classPrivateFieldSetHelper);
67590         return ts.createCall(ts.getUnscopedHelperName("__classPrivateFieldSet"), undefined, [receiver, privateField, value]);
67591     }
67592 })(ts || (ts = {}));
67593 var ts;
67594 (function (ts) {
67595     function transformES2017(context) {
67596         var resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
67597         var resolver = context.getEmitResolver();
67598         var compilerOptions = context.getCompilerOptions();
67599         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
67600         var enabledSubstitutions;
67601         var enclosingSuperContainerFlags = 0;
67602         var enclosingFunctionParameterNames;
67603         var capturedSuperProperties;
67604         var hasSuperElementAccess;
67605         var substitutedSuperAccessors = [];
67606         var contextFlags = 0;
67607         var previousOnEmitNode = context.onEmitNode;
67608         var previousOnSubstituteNode = context.onSubstituteNode;
67609         context.onEmitNode = onEmitNode;
67610         context.onSubstituteNode = onSubstituteNode;
67611         return ts.chainBundle(transformSourceFile);
67612         function transformSourceFile(node) {
67613             if (node.isDeclarationFile) {
67614                 return node;
67615             }
67616             setContextFlag(1, false);
67617             setContextFlag(2, !ts.isEffectiveStrictModeSourceFile(node, compilerOptions));
67618             var visited = ts.visitEachChild(node, visitor, context);
67619             ts.addEmitHelpers(visited, context.readEmitHelpers());
67620             return visited;
67621         }
67622         function setContextFlag(flag, val) {
67623             contextFlags = val ? contextFlags | flag : contextFlags & ~flag;
67624         }
67625         function inContext(flags) {
67626             return (contextFlags & flags) !== 0;
67627         }
67628         function inTopLevelContext() {
67629             return !inContext(1);
67630         }
67631         function inHasLexicalThisContext() {
67632             return inContext(2);
67633         }
67634         function doWithContext(flags, cb, value) {
67635             var contextFlagsToSet = flags & ~contextFlags;
67636             if (contextFlagsToSet) {
67637                 setContextFlag(contextFlagsToSet, true);
67638                 var result = cb(value);
67639                 setContextFlag(contextFlagsToSet, false);
67640                 return result;
67641             }
67642             return cb(value);
67643         }
67644         function visitDefault(node) {
67645             return ts.visitEachChild(node, visitor, context);
67646         }
67647         function visitor(node) {
67648             if ((node.transformFlags & 64) === 0) {
67649                 return node;
67650             }
67651             switch (node.kind) {
67652                 case 126:
67653                     return undefined;
67654                 case 206:
67655                     return visitAwaitExpression(node);
67656                 case 161:
67657                     return doWithContext(1 | 2, visitMethodDeclaration, node);
67658                 case 244:
67659                     return doWithContext(1 | 2, visitFunctionDeclaration, node);
67660                 case 201:
67661                     return doWithContext(1 | 2, visitFunctionExpression, node);
67662                 case 202:
67663                     return doWithContext(1, visitArrowFunction, node);
67664                 case 194:
67665                     if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 102) {
67666                         capturedSuperProperties.set(node.name.escapedText, true);
67667                     }
67668                     return ts.visitEachChild(node, visitor, context);
67669                 case 195:
67670                     if (capturedSuperProperties && node.expression.kind === 102) {
67671                         hasSuperElementAccess = true;
67672                     }
67673                     return ts.visitEachChild(node, visitor, context);
67674                 case 163:
67675                 case 164:
67676                 case 162:
67677                 case 245:
67678                 case 214:
67679                     return doWithContext(1 | 2, visitDefault, node);
67680                 default:
67681                     return ts.visitEachChild(node, visitor, context);
67682             }
67683         }
67684         function asyncBodyVisitor(node) {
67685             if (ts.isNodeWithPossibleHoistedDeclaration(node)) {
67686                 switch (node.kind) {
67687                     case 225:
67688                         return visitVariableStatementInAsyncBody(node);
67689                     case 230:
67690                         return visitForStatementInAsyncBody(node);
67691                     case 231:
67692                         return visitForInStatementInAsyncBody(node);
67693                     case 232:
67694                         return visitForOfStatementInAsyncBody(node);
67695                     case 280:
67696                         return visitCatchClauseInAsyncBody(node);
67697                     case 223:
67698                     case 237:
67699                     case 251:
67700                     case 277:
67701                     case 278:
67702                     case 240:
67703                     case 228:
67704                     case 229:
67705                     case 227:
67706                     case 236:
67707                     case 238:
67708                         return ts.visitEachChild(node, asyncBodyVisitor, context);
67709                     default:
67710                         return ts.Debug.assertNever(node, "Unhandled node.");
67711                 }
67712             }
67713             return visitor(node);
67714         }
67715         function visitCatchClauseInAsyncBody(node) {
67716             var catchClauseNames = ts.createUnderscoreEscapedMap();
67717             recordDeclarationName(node.variableDeclaration, catchClauseNames);
67718             var catchClauseUnshadowedNames;
67719             catchClauseNames.forEach(function (_, escapedName) {
67720                 if (enclosingFunctionParameterNames.has(escapedName)) {
67721                     if (!catchClauseUnshadowedNames) {
67722                         catchClauseUnshadowedNames = ts.cloneMap(enclosingFunctionParameterNames);
67723                     }
67724                     catchClauseUnshadowedNames.delete(escapedName);
67725                 }
67726             });
67727             if (catchClauseUnshadowedNames) {
67728                 var savedEnclosingFunctionParameterNames = enclosingFunctionParameterNames;
67729                 enclosingFunctionParameterNames = catchClauseUnshadowedNames;
67730                 var result = ts.visitEachChild(node, asyncBodyVisitor, context);
67731                 enclosingFunctionParameterNames = savedEnclosingFunctionParameterNames;
67732                 return result;
67733             }
67734             else {
67735                 return ts.visitEachChild(node, asyncBodyVisitor, context);
67736             }
67737         }
67738         function visitVariableStatementInAsyncBody(node) {
67739             if (isVariableDeclarationListWithCollidingName(node.declarationList)) {
67740                 var expression = visitVariableDeclarationListWithCollidingNames(node.declarationList, false);
67741                 return expression ? ts.createExpressionStatement(expression) : undefined;
67742             }
67743             return ts.visitEachChild(node, visitor, context);
67744         }
67745         function visitForInStatementInAsyncBody(node) {
67746             return ts.updateForIn(node, isVariableDeclarationListWithCollidingName(node.initializer)
67747                 ? visitVariableDeclarationListWithCollidingNames(node.initializer, true)
67748                 : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, ts.liftToBlock));
67749         }
67750         function visitForOfStatementInAsyncBody(node) {
67751             return ts.updateForOf(node, ts.visitNode(node.awaitModifier, visitor, ts.isToken), isVariableDeclarationListWithCollidingName(node.initializer)
67752                 ? visitVariableDeclarationListWithCollidingNames(node.initializer, true)
67753                 : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, ts.liftToBlock));
67754         }
67755         function visitForStatementInAsyncBody(node) {
67756             var initializer = node.initializer;
67757             return ts.updateFor(node, isVariableDeclarationListWithCollidingName(initializer)
67758                 ? visitVariableDeclarationListWithCollidingNames(initializer, false)
67759                 : 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));
67760         }
67761         function visitAwaitExpression(node) {
67762             if (inTopLevelContext()) {
67763                 return ts.visitEachChild(node, visitor, context);
67764             }
67765             return ts.setOriginalNode(ts.setTextRange(ts.createYield(undefined, ts.visitNode(node.expression, visitor, ts.isExpression)), node), node);
67766         }
67767         function visitMethodDeclaration(node) {
67768             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
67769                 ? transformAsyncFunctionBody(node)
67770                 : ts.visitFunctionBody(node.body, visitor, context));
67771         }
67772         function visitFunctionDeclaration(node) {
67773             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
67774                 ? transformAsyncFunctionBody(node)
67775                 : ts.visitFunctionBody(node.body, visitor, context));
67776         }
67777         function visitFunctionExpression(node) {
67778             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
67779                 ? transformAsyncFunctionBody(node)
67780                 : ts.visitFunctionBody(node.body, visitor, context));
67781         }
67782         function visitArrowFunction(node) {
67783             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
67784                 ? transformAsyncFunctionBody(node)
67785                 : ts.visitFunctionBody(node.body, visitor, context));
67786         }
67787         function recordDeclarationName(_a, names) {
67788             var name = _a.name;
67789             if (ts.isIdentifier(name)) {
67790                 names.set(name.escapedText, true);
67791             }
67792             else {
67793                 for (var _i = 0, _b = name.elements; _i < _b.length; _i++) {
67794                     var element = _b[_i];
67795                     if (!ts.isOmittedExpression(element)) {
67796                         recordDeclarationName(element, names);
67797                     }
67798                 }
67799             }
67800         }
67801         function isVariableDeclarationListWithCollidingName(node) {
67802             return !!node
67803                 && ts.isVariableDeclarationList(node)
67804                 && !(node.flags & 3)
67805                 && node.declarations.some(collidesWithParameterName);
67806         }
67807         function visitVariableDeclarationListWithCollidingNames(node, hasReceiver) {
67808             hoistVariableDeclarationList(node);
67809             var variables = ts.getInitializedVariables(node);
67810             if (variables.length === 0) {
67811                 if (hasReceiver) {
67812                     return ts.visitNode(ts.convertToAssignmentElementTarget(node.declarations[0].name), visitor, ts.isExpression);
67813                 }
67814                 return undefined;
67815             }
67816             return ts.inlineExpressions(ts.map(variables, transformInitializedVariable));
67817         }
67818         function hoistVariableDeclarationList(node) {
67819             ts.forEach(node.declarations, hoistVariable);
67820         }
67821         function hoistVariable(_a) {
67822             var name = _a.name;
67823             if (ts.isIdentifier(name)) {
67824                 hoistVariableDeclaration(name);
67825             }
67826             else {
67827                 for (var _i = 0, _b = name.elements; _i < _b.length; _i++) {
67828                     var element = _b[_i];
67829                     if (!ts.isOmittedExpression(element)) {
67830                         hoistVariable(element);
67831                     }
67832                 }
67833             }
67834         }
67835         function transformInitializedVariable(node) {
67836             var converted = ts.setSourceMapRange(ts.createAssignment(ts.convertToAssignmentElementTarget(node.name), node.initializer), node);
67837             return ts.visitNode(converted, visitor, ts.isExpression);
67838         }
67839         function collidesWithParameterName(_a) {
67840             var name = _a.name;
67841             if (ts.isIdentifier(name)) {
67842                 return enclosingFunctionParameterNames.has(name.escapedText);
67843             }
67844             else {
67845                 for (var _i = 0, _b = name.elements; _i < _b.length; _i++) {
67846                     var element = _b[_i];
67847                     if (!ts.isOmittedExpression(element) && collidesWithParameterName(element)) {
67848                         return true;
67849                     }
67850                 }
67851             }
67852             return false;
67853         }
67854         function transformAsyncFunctionBody(node) {
67855             resumeLexicalEnvironment();
67856             var original = ts.getOriginalNode(node, ts.isFunctionLike);
67857             var nodeType = original.type;
67858             var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(nodeType) : undefined;
67859             var isArrowFunction = node.kind === 202;
67860             var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0;
67861             var savedEnclosingFunctionParameterNames = enclosingFunctionParameterNames;
67862             enclosingFunctionParameterNames = ts.createUnderscoreEscapedMap();
67863             for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
67864                 var parameter = _a[_i];
67865                 recordDeclarationName(parameter, enclosingFunctionParameterNames);
67866             }
67867             var savedCapturedSuperProperties = capturedSuperProperties;
67868             var savedHasSuperElementAccess = hasSuperElementAccess;
67869             if (!isArrowFunction) {
67870                 capturedSuperProperties = ts.createUnderscoreEscapedMap();
67871                 hasSuperElementAccess = false;
67872             }
67873             var result;
67874             if (!isArrowFunction) {
67875                 var statements = [];
67876                 var statementOffset = ts.addPrologue(statements, node.body.statements, false, visitor);
67877                 statements.push(ts.createReturn(createAwaiterHelper(context, inHasLexicalThisContext(), hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body, statementOffset))));
67878                 ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
67879                 var emitSuperHelpers = languageVersion >= 2 && resolver.getNodeCheckFlags(node) & (4096 | 2048);
67880                 if (emitSuperHelpers) {
67881                     enableSubstitutionForAsyncMethodsWithSuper();
67882                     if (ts.hasEntries(capturedSuperProperties)) {
67883                         var variableStatement = createSuperAccessVariableStatement(resolver, node, capturedSuperProperties);
67884                         substitutedSuperAccessors[ts.getNodeId(variableStatement)] = true;
67885                         ts.insertStatementsAfterStandardPrologue(statements, [variableStatement]);
67886                     }
67887                 }
67888                 var block = ts.createBlock(statements, true);
67889                 ts.setTextRange(block, node.body);
67890                 if (emitSuperHelpers && hasSuperElementAccess) {
67891                     if (resolver.getNodeCheckFlags(node) & 4096) {
67892                         ts.addEmitHelper(block, ts.advancedAsyncSuperHelper);
67893                     }
67894                     else if (resolver.getNodeCheckFlags(node) & 2048) {
67895                         ts.addEmitHelper(block, ts.asyncSuperHelper);
67896                     }
67897                 }
67898                 result = block;
67899             }
67900             else {
67901                 var expression = createAwaiterHelper(context, inHasLexicalThisContext(), hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body));
67902                 var declarations = endLexicalEnvironment();
67903                 if (ts.some(declarations)) {
67904                     var block = ts.convertToFunctionBody(expression);
67905                     result = ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(declarations, block.statements)), block.statements));
67906                 }
67907                 else {
67908                     result = expression;
67909                 }
67910             }
67911             enclosingFunctionParameterNames = savedEnclosingFunctionParameterNames;
67912             if (!isArrowFunction) {
67913                 capturedSuperProperties = savedCapturedSuperProperties;
67914                 hasSuperElementAccess = savedHasSuperElementAccess;
67915             }
67916             return result;
67917         }
67918         function transformAsyncFunctionBodyWorker(body, start) {
67919             if (ts.isBlock(body)) {
67920                 return ts.updateBlock(body, ts.visitNodes(body.statements, asyncBodyVisitor, ts.isStatement, start));
67921             }
67922             else {
67923                 return ts.convertToFunctionBody(ts.visitNode(body, asyncBodyVisitor, ts.isConciseBody));
67924             }
67925         }
67926         function getPromiseConstructor(type) {
67927             var typeName = type && ts.getEntityNameFromTypeNode(type);
67928             if (typeName && ts.isEntityName(typeName)) {
67929                 var serializationKind = resolver.getTypeReferenceSerializationKind(typeName);
67930                 if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue
67931                     || serializationKind === ts.TypeReferenceSerializationKind.Unknown) {
67932                     return typeName;
67933                 }
67934             }
67935             return undefined;
67936         }
67937         function enableSubstitutionForAsyncMethodsWithSuper() {
67938             if ((enabledSubstitutions & 1) === 0) {
67939                 enabledSubstitutions |= 1;
67940                 context.enableSubstitution(196);
67941                 context.enableSubstitution(194);
67942                 context.enableSubstitution(195);
67943                 context.enableEmitNotification(245);
67944                 context.enableEmitNotification(161);
67945                 context.enableEmitNotification(163);
67946                 context.enableEmitNotification(164);
67947                 context.enableEmitNotification(162);
67948                 context.enableEmitNotification(225);
67949             }
67950         }
67951         function onEmitNode(hint, node, emitCallback) {
67952             if (enabledSubstitutions & 1 && isSuperContainer(node)) {
67953                 var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 | 4096);
67954                 if (superContainerFlags !== enclosingSuperContainerFlags) {
67955                     var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
67956                     enclosingSuperContainerFlags = superContainerFlags;
67957                     previousOnEmitNode(hint, node, emitCallback);
67958                     enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags;
67959                     return;
67960                 }
67961             }
67962             else if (enabledSubstitutions && substitutedSuperAccessors[ts.getNodeId(node)]) {
67963                 var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
67964                 enclosingSuperContainerFlags = 0;
67965                 previousOnEmitNode(hint, node, emitCallback);
67966                 enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags;
67967                 return;
67968             }
67969             previousOnEmitNode(hint, node, emitCallback);
67970         }
67971         function onSubstituteNode(hint, node) {
67972             node = previousOnSubstituteNode(hint, node);
67973             if (hint === 1 && enclosingSuperContainerFlags) {
67974                 return substituteExpression(node);
67975             }
67976             return node;
67977         }
67978         function substituteExpression(node) {
67979             switch (node.kind) {
67980                 case 194:
67981                     return substitutePropertyAccessExpression(node);
67982                 case 195:
67983                     return substituteElementAccessExpression(node);
67984                 case 196:
67985                     return substituteCallExpression(node);
67986             }
67987             return node;
67988         }
67989         function substitutePropertyAccessExpression(node) {
67990             if (node.expression.kind === 102) {
67991                 return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node);
67992             }
67993             return node;
67994         }
67995         function substituteElementAccessExpression(node) {
67996             if (node.expression.kind === 102) {
67997                 return createSuperElementAccessInAsyncMethod(node.argumentExpression, node);
67998             }
67999             return node;
68000         }
68001         function substituteCallExpression(node) {
68002             var expression = node.expression;
68003             if (ts.isSuperProperty(expression)) {
68004                 var argumentExpression = ts.isPropertyAccessExpression(expression)
68005                     ? substitutePropertyAccessExpression(expression)
68006                     : substituteElementAccessExpression(expression);
68007                 return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, __spreadArrays([
68008                     ts.createThis()
68009                 ], node.arguments));
68010             }
68011             return node;
68012         }
68013         function isSuperContainer(node) {
68014             var kind = node.kind;
68015             return kind === 245
68016                 || kind === 162
68017                 || kind === 161
68018                 || kind === 163
68019                 || kind === 164;
68020         }
68021         function createSuperElementAccessInAsyncMethod(argumentExpression, location) {
68022             if (enclosingSuperContainerFlags & 4096) {
68023                 return ts.setTextRange(ts.createPropertyAccess(ts.createCall(ts.createFileLevelUniqueName("_superIndex"), undefined, [argumentExpression]), "value"), location);
68024             }
68025             else {
68026                 return ts.setTextRange(ts.createCall(ts.createFileLevelUniqueName("_superIndex"), undefined, [argumentExpression]), location);
68027             }
68028         }
68029     }
68030     ts.transformES2017 = transformES2017;
68031     function createSuperAccessVariableStatement(resolver, node, names) {
68032         var hasBinding = (resolver.getNodeCheckFlags(node) & 4096) !== 0;
68033         var accessors = [];
68034         names.forEach(function (_, key) {
68035             var name = ts.unescapeLeadingUnderscores(key);
68036             var getterAndSetter = [];
68037             getterAndSetter.push(ts.createPropertyAssignment("get", ts.createArrowFunction(undefined, undefined, [], undefined, undefined, ts.setEmitFlags(ts.createPropertyAccess(ts.setEmitFlags(ts.createSuper(), 4), name), 4))));
68038             if (hasBinding) {
68039                 getterAndSetter.push(ts.createPropertyAssignment("set", ts.createArrowFunction(undefined, undefined, [
68040                     ts.createParameter(undefined, undefined, undefined, "v", undefined, undefined, undefined)
68041                 ], undefined, undefined, ts.createAssignment(ts.setEmitFlags(ts.createPropertyAccess(ts.setEmitFlags(ts.createSuper(), 4), name), 4), ts.createIdentifier("v")))));
68042             }
68043             accessors.push(ts.createPropertyAssignment(name, ts.createObjectLiteral(getterAndSetter)));
68044         });
68045         return ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
68046             ts.createVariableDeclaration(ts.createFileLevelUniqueName("_super"), undefined, ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "create"), undefined, [
68047                 ts.createNull(),
68048                 ts.createObjectLiteral(accessors, true)
68049             ]))
68050         ], 2));
68051     }
68052     ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement;
68053     ts.awaiterHelper = {
68054         name: "typescript:awaiter",
68055         importName: "__awaiter",
68056         scoped: false,
68057         priority: 5,
68058         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            };"
68059     };
68060     function createAwaiterHelper(context, hasLexicalThis, hasLexicalArguments, promiseConstructor, body) {
68061         context.requestEmitHelper(ts.awaiterHelper);
68062         var generatorFunc = ts.createFunctionExpression(undefined, ts.createToken(41), undefined, undefined, [], undefined, body);
68063         (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 | 524288;
68064         return ts.createCall(ts.getUnscopedHelperName("__awaiter"), undefined, [
68065             hasLexicalThis ? ts.createThis() : ts.createVoidZero(),
68066             hasLexicalArguments ? ts.createIdentifier("arguments") : ts.createVoidZero(),
68067             promiseConstructor ? ts.createExpressionFromEntityName(promiseConstructor) : ts.createVoidZero(),
68068             generatorFunc
68069         ]);
68070     }
68071     ts.asyncSuperHelper = {
68072         name: "typescript:async-super",
68073         scoped: true,
68074         text: ts.helperString(__makeTemplateObject(["\n            const ", " = name => super[name];"], ["\n            const ", " = name => super[name];"]), "_superIndex")
68075     };
68076     ts.advancedAsyncSuperHelper = {
68077         name: "typescript:advanced-async-super",
68078         scoped: true,
68079         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")
68080     };
68081 })(ts || (ts = {}));
68082 var ts;
68083 (function (ts) {
68084     function transformES2018(context) {
68085         var resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
68086         var resolver = context.getEmitResolver();
68087         var compilerOptions = context.getCompilerOptions();
68088         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
68089         var previousOnEmitNode = context.onEmitNode;
68090         context.onEmitNode = onEmitNode;
68091         var previousOnSubstituteNode = context.onSubstituteNode;
68092         context.onSubstituteNode = onSubstituteNode;
68093         var exportedVariableStatement = false;
68094         var enabledSubstitutions;
68095         var enclosingFunctionFlags;
68096         var enclosingSuperContainerFlags = 0;
68097         var hierarchyFacts = 0;
68098         var currentSourceFile;
68099         var taggedTemplateStringDeclarations;
68100         var capturedSuperProperties;
68101         var hasSuperElementAccess;
68102         var substitutedSuperAccessors = [];
68103         return ts.chainBundle(transformSourceFile);
68104         function affectsSubtree(excludeFacts, includeFacts) {
68105             return hierarchyFacts !== (hierarchyFacts & ~excludeFacts | includeFacts);
68106         }
68107         function enterSubtree(excludeFacts, includeFacts) {
68108             var ancestorFacts = hierarchyFacts;
68109             hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 3;
68110             return ancestorFacts;
68111         }
68112         function exitSubtree(ancestorFacts) {
68113             hierarchyFacts = ancestorFacts;
68114         }
68115         function recordTaggedTemplateString(temp) {
68116             taggedTemplateStringDeclarations = ts.append(taggedTemplateStringDeclarations, ts.createVariableDeclaration(temp));
68117         }
68118         function transformSourceFile(node) {
68119             if (node.isDeclarationFile) {
68120                 return node;
68121             }
68122             currentSourceFile = node;
68123             var visited = visitSourceFile(node);
68124             ts.addEmitHelpers(visited, context.readEmitHelpers());
68125             currentSourceFile = undefined;
68126             taggedTemplateStringDeclarations = undefined;
68127             return visited;
68128         }
68129         function visitor(node) {
68130             return visitorWorker(node, false);
68131         }
68132         function visitorNoDestructuringValue(node) {
68133             return visitorWorker(node, true);
68134         }
68135         function visitorNoAsyncModifier(node) {
68136             if (node.kind === 126) {
68137                 return undefined;
68138             }
68139             return node;
68140         }
68141         function doWithHierarchyFacts(cb, value, excludeFacts, includeFacts) {
68142             if (affectsSubtree(excludeFacts, includeFacts)) {
68143                 var ancestorFacts = enterSubtree(excludeFacts, includeFacts);
68144                 var result = cb(value);
68145                 exitSubtree(ancestorFacts);
68146                 return result;
68147             }
68148             return cb(value);
68149         }
68150         function visitDefault(node) {
68151             return ts.visitEachChild(node, visitor, context);
68152         }
68153         function visitorWorker(node, noDestructuringValue) {
68154             if ((node.transformFlags & 32) === 0) {
68155                 return node;
68156             }
68157             switch (node.kind) {
68158                 case 206:
68159                     return visitAwaitExpression(node);
68160                 case 212:
68161                     return visitYieldExpression(node);
68162                 case 235:
68163                     return visitReturnStatement(node);
68164                 case 238:
68165                     return visitLabeledStatement(node);
68166                 case 193:
68167                     return visitObjectLiteralExpression(node);
68168                 case 209:
68169                     return visitBinaryExpression(node, noDestructuringValue);
68170                 case 280:
68171                     return visitCatchClause(node);
68172                 case 225:
68173                     return visitVariableStatement(node);
68174                 case 242:
68175                     return visitVariableDeclaration(node);
68176                 case 228:
68177                 case 229:
68178                 case 231:
68179                     return doWithHierarchyFacts(visitDefault, node, 0, 2);
68180                 case 232:
68181                     return visitForOfStatement(node, undefined);
68182                 case 230:
68183                     return doWithHierarchyFacts(visitForStatement, node, 0, 2);
68184                 case 205:
68185                     return visitVoidExpression(node);
68186                 case 162:
68187                     return doWithHierarchyFacts(visitConstructorDeclaration, node, 2, 1);
68188                 case 161:
68189                     return doWithHierarchyFacts(visitMethodDeclaration, node, 2, 1);
68190                 case 163:
68191                     return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2, 1);
68192                 case 164:
68193                     return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2, 1);
68194                 case 244:
68195                     return doWithHierarchyFacts(visitFunctionDeclaration, node, 2, 1);
68196                 case 201:
68197                     return doWithHierarchyFacts(visitFunctionExpression, node, 2, 1);
68198                 case 202:
68199                     return doWithHierarchyFacts(visitArrowFunction, node, 2, 0);
68200                 case 156:
68201                     return visitParameter(node);
68202                 case 226:
68203                     return visitExpressionStatement(node);
68204                 case 200:
68205                     return visitParenthesizedExpression(node, noDestructuringValue);
68206                 case 198:
68207                     return visitTaggedTemplateExpression(node);
68208                 case 194:
68209                     if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 102) {
68210                         capturedSuperProperties.set(node.name.escapedText, true);
68211                     }
68212                     return ts.visitEachChild(node, visitor, context);
68213                 case 195:
68214                     if (capturedSuperProperties && node.expression.kind === 102) {
68215                         hasSuperElementAccess = true;
68216                     }
68217                     return ts.visitEachChild(node, visitor, context);
68218                 case 245:
68219                 case 214:
68220                     return doWithHierarchyFacts(visitDefault, node, 2, 1);
68221                 default:
68222                     return ts.visitEachChild(node, visitor, context);
68223             }
68224         }
68225         function visitAwaitExpression(node) {
68226             if (enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1) {
68227                 return ts.setOriginalNode(ts.setTextRange(ts.createYield(createAwaitHelper(context, ts.visitNode(node.expression, visitor, ts.isExpression))), node), node);
68228             }
68229             return ts.visitEachChild(node, visitor, context);
68230         }
68231         function visitYieldExpression(node) {
68232             if (enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1) {
68233                 if (node.asteriskToken) {
68234                     var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
68235                     return ts.setOriginalNode(ts.setTextRange(ts.createYield(createAwaitHelper(context, ts.updateYield(node, node.asteriskToken, createAsyncDelegatorHelper(context, createAsyncValuesHelper(context, expression, expression), expression)))), node), node);
68236                 }
68237                 return ts.setOriginalNode(ts.setTextRange(ts.createYield(createDownlevelAwait(node.expression
68238                     ? ts.visitNode(node.expression, visitor, ts.isExpression)
68239                     : ts.createVoidZero())), node), node);
68240             }
68241             return ts.visitEachChild(node, visitor, context);
68242         }
68243         function visitReturnStatement(node) {
68244             if (enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1) {
68245                 return ts.updateReturn(node, createDownlevelAwait(node.expression ? ts.visitNode(node.expression, visitor, ts.isExpression) : ts.createVoidZero()));
68246             }
68247             return ts.visitEachChild(node, visitor, context);
68248         }
68249         function visitLabeledStatement(node) {
68250             if (enclosingFunctionFlags & 2) {
68251                 var statement = ts.unwrapInnermostStatementOfLabel(node);
68252                 if (statement.kind === 232 && statement.awaitModifier) {
68253                     return visitForOfStatement(statement, node);
68254                 }
68255                 return ts.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement, ts.liftToBlock), node);
68256             }
68257             return ts.visitEachChild(node, visitor, context);
68258         }
68259         function chunkObjectLiteralElements(elements) {
68260             var chunkObject;
68261             var objects = [];
68262             for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) {
68263                 var e = elements_4[_i];
68264                 if (e.kind === 283) {
68265                     if (chunkObject) {
68266                         objects.push(ts.createObjectLiteral(chunkObject));
68267                         chunkObject = undefined;
68268                     }
68269                     var target = e.expression;
68270                     objects.push(ts.visitNode(target, visitor, ts.isExpression));
68271                 }
68272                 else {
68273                     chunkObject = ts.append(chunkObject, e.kind === 281
68274                         ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression))
68275                         : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike));
68276                 }
68277             }
68278             if (chunkObject) {
68279                 objects.push(ts.createObjectLiteral(chunkObject));
68280             }
68281             return objects;
68282         }
68283         function visitObjectLiteralExpression(node) {
68284             if (node.transformFlags & 16384) {
68285                 var objects = chunkObjectLiteralElements(node.properties);
68286                 if (objects.length && objects[0].kind !== 193) {
68287                     objects.unshift(ts.createObjectLiteral());
68288                 }
68289                 var expression = objects[0];
68290                 if (objects.length > 1) {
68291                     for (var i = 1; i < objects.length; i++) {
68292                         expression = createAssignHelper(context, [expression, objects[i]]);
68293                     }
68294                     return expression;
68295                 }
68296                 else {
68297                     return createAssignHelper(context, objects);
68298                 }
68299             }
68300             return ts.visitEachChild(node, visitor, context);
68301         }
68302         function visitExpressionStatement(node) {
68303             return ts.visitEachChild(node, visitorNoDestructuringValue, context);
68304         }
68305         function visitParenthesizedExpression(node, noDestructuringValue) {
68306             return ts.visitEachChild(node, noDestructuringValue ? visitorNoDestructuringValue : visitor, context);
68307         }
68308         function visitSourceFile(node) {
68309             var ancestorFacts = enterSubtree(2, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ?
68310                 0 :
68311                 1);
68312             exportedVariableStatement = false;
68313             var visited = ts.visitEachChild(node, visitor, context);
68314             var statement = ts.concatenate(visited.statements, taggedTemplateStringDeclarations && [
68315                 ts.createVariableStatement(undefined, ts.createVariableDeclarationList(taggedTemplateStringDeclarations))
68316             ]);
68317             var result = ts.updateSourceFileNode(visited, ts.setTextRange(ts.createNodeArray(statement), node.statements));
68318             exitSubtree(ancestorFacts);
68319             return result;
68320         }
68321         function visitTaggedTemplateExpression(node) {
68322             return ts.processTaggedTemplateExpression(context, node, visitor, currentSourceFile, recordTaggedTemplateString, ts.ProcessLevel.LiftRestriction);
68323         }
68324         function visitBinaryExpression(node, noDestructuringValue) {
68325             if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 16384) {
68326                 return ts.flattenDestructuringAssignment(node, visitor, context, 1, !noDestructuringValue);
68327             }
68328             else if (node.operatorToken.kind === 27) {
68329                 return ts.updateBinary(node, ts.visitNode(node.left, visitorNoDestructuringValue, ts.isExpression), ts.visitNode(node.right, noDestructuringValue ? visitorNoDestructuringValue : visitor, ts.isExpression));
68330             }
68331             return ts.visitEachChild(node, visitor, context);
68332         }
68333         function visitCatchClause(node) {
68334             if (node.variableDeclaration &&
68335                 ts.isBindingPattern(node.variableDeclaration.name) &&
68336                 node.variableDeclaration.name.transformFlags & 16384) {
68337                 var name = ts.getGeneratedNameForNode(node.variableDeclaration.name);
68338                 var updatedDecl = ts.updateVariableDeclaration(node.variableDeclaration, node.variableDeclaration.name, undefined, name);
68339                 var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1);
68340                 var block = ts.visitNode(node.block, visitor, ts.isBlock);
68341                 if (ts.some(visitedBindings)) {
68342                     block = ts.updateBlock(block, __spreadArrays([
68343                         ts.createVariableStatement(undefined, visitedBindings)
68344                     ], block.statements));
68345                 }
68346                 return ts.updateCatchClause(node, ts.updateVariableDeclaration(node.variableDeclaration, name, undefined, undefined), block);
68347             }
68348             return ts.visitEachChild(node, visitor, context);
68349         }
68350         function visitVariableStatement(node) {
68351             if (ts.hasModifier(node, 1)) {
68352                 var savedExportedVariableStatement = exportedVariableStatement;
68353                 exportedVariableStatement = true;
68354                 var visited = ts.visitEachChild(node, visitor, context);
68355                 exportedVariableStatement = savedExportedVariableStatement;
68356                 return visited;
68357             }
68358             return ts.visitEachChild(node, visitor, context);
68359         }
68360         function visitVariableDeclaration(node) {
68361             if (exportedVariableStatement) {
68362                 var savedExportedVariableStatement = exportedVariableStatement;
68363                 exportedVariableStatement = false;
68364                 var visited = visitVariableDeclarationWorker(node, true);
68365                 exportedVariableStatement = savedExportedVariableStatement;
68366                 return visited;
68367             }
68368             return visitVariableDeclarationWorker(node, false);
68369         }
68370         function visitVariableDeclarationWorker(node, exportedVariableStatement) {
68371             if (ts.isBindingPattern(node.name) && node.name.transformFlags & 16384) {
68372                 return ts.flattenDestructuringBinding(node, visitor, context, 1, undefined, exportedVariableStatement);
68373             }
68374             return ts.visitEachChild(node, visitor, context);
68375         }
68376         function visitForStatement(node) {
68377             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));
68378         }
68379         function visitVoidExpression(node) {
68380             return ts.visitEachChild(node, visitorNoDestructuringValue, context);
68381         }
68382         function visitForOfStatement(node, outermostLabeledStatement) {
68383             var ancestorFacts = enterSubtree(0, 2);
68384             if (node.initializer.transformFlags & 16384) {
68385                 node = transformForOfStatementWithObjectRest(node);
68386             }
68387             var result = node.awaitModifier ?
68388                 transformForAwaitOfStatement(node, outermostLabeledStatement, ancestorFacts) :
68389                 ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement);
68390             exitSubtree(ancestorFacts);
68391             return result;
68392         }
68393         function transformForOfStatementWithObjectRest(node) {
68394             var initializerWithoutParens = ts.skipParentheses(node.initializer);
68395             if (ts.isVariableDeclarationList(initializerWithoutParens) || ts.isAssignmentPattern(initializerWithoutParens)) {
68396                 var bodyLocation = void 0;
68397                 var statementsLocation = void 0;
68398                 var temp = ts.createTempVariable(undefined);
68399                 var statements = [ts.createForOfBindingStatement(initializerWithoutParens, temp)];
68400                 if (ts.isBlock(node.statement)) {
68401                     ts.addRange(statements, node.statement.statements);
68402                     bodyLocation = node.statement;
68403                     statementsLocation = node.statement.statements;
68404                 }
68405                 else if (node.statement) {
68406                     ts.append(statements, node.statement);
68407                     bodyLocation = node.statement;
68408                     statementsLocation = node.statement;
68409                 }
68410                 return ts.updateForOf(node, node.awaitModifier, ts.setTextRange(ts.createVariableDeclarationList([
68411                     ts.setTextRange(ts.createVariableDeclaration(temp), node.initializer)
68412                 ], 1), node.initializer), node.expression, ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true), bodyLocation));
68413             }
68414             return node;
68415         }
68416         function convertForOfStatementHead(node, boundValue) {
68417             var binding = ts.createForOfBindingStatement(node.initializer, boundValue);
68418             var bodyLocation;
68419             var statementsLocation;
68420             var statements = [ts.visitNode(binding, visitor, ts.isStatement)];
68421             var statement = ts.visitNode(node.statement, visitor, ts.isStatement);
68422             if (ts.isBlock(statement)) {
68423                 ts.addRange(statements, statement.statements);
68424                 bodyLocation = statement;
68425                 statementsLocation = statement.statements;
68426             }
68427             else {
68428                 statements.push(statement);
68429             }
68430             return ts.setEmitFlags(ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true), bodyLocation), 48 | 384);
68431         }
68432         function createDownlevelAwait(expression) {
68433             return enclosingFunctionFlags & 1
68434                 ? ts.createYield(undefined, createAwaitHelper(context, expression))
68435                 : ts.createAwait(expression);
68436         }
68437         function transformForAwaitOfStatement(node, outermostLabeledStatement, ancestorFacts) {
68438             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
68439             var iterator = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(expression) : ts.createTempVariable(undefined);
68440             var result = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(iterator) : ts.createTempVariable(undefined);
68441             var errorRecord = ts.createUniqueName("e");
68442             var catchVariable = ts.getGeneratedNameForNode(errorRecord);
68443             var returnMethod = ts.createTempVariable(undefined);
68444             var callValues = createAsyncValuesHelper(context, expression, node.expression);
68445             var callNext = ts.createCall(ts.createPropertyAccess(iterator, "next"), undefined, []);
68446             var getDone = ts.createPropertyAccess(result, "done");
68447             var getValue = ts.createPropertyAccess(result, "value");
68448             var callReturn = ts.createFunctionCall(returnMethod, iterator, []);
68449             hoistVariableDeclaration(errorRecord);
68450             hoistVariableDeclaration(returnMethod);
68451             var initializer = ancestorFacts & 2 ?
68452                 ts.inlineExpressions([ts.createAssignment(errorRecord, ts.createVoidZero()), callValues]) :
68453                 callValues;
68454             var forStatement = ts.setEmitFlags(ts.setTextRange(ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([
68455                 ts.setTextRange(ts.createVariableDeclaration(iterator, undefined, initializer), node.expression),
68456                 ts.createVariableDeclaration(result)
68457             ]), node.expression), 2097152), ts.createComma(ts.createAssignment(result, createDownlevelAwait(callNext)), ts.createLogicalNot(getDone)), undefined, convertForOfStatementHead(node, getValue)), node), 256);
68458             return ts.createTry(ts.createBlock([
68459                 ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement)
68460             ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([
68461                 ts.createExpressionStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([
68462                     ts.createPropertyAssignment("error", catchVariable)
68463                 ])))
68464             ]), 1)), ts.createBlock([
68465                 ts.createTry(ts.createBlock([
68466                     ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(getDone)), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createExpressionStatement(createDownlevelAwait(callReturn))), 1)
68467                 ]), undefined, ts.setEmitFlags(ts.createBlock([
68468                     ts.setEmitFlags(ts.createIf(errorRecord, ts.createThrow(ts.createPropertyAccess(errorRecord, "error"))), 1)
68469                 ]), 1))
68470             ]));
68471         }
68472         function visitParameter(node) {
68473             if (node.transformFlags & 16384) {
68474                 return ts.updateParameter(node, undefined, undefined, node.dotDotDotToken, ts.getGeneratedNameForNode(node), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression));
68475             }
68476             return ts.visitEachChild(node, visitor, context);
68477         }
68478         function visitConstructorDeclaration(node) {
68479             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
68480             enclosingFunctionFlags = 0;
68481             var updated = ts.updateConstructor(node, undefined, node.modifiers, ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node));
68482             enclosingFunctionFlags = savedEnclosingFunctionFlags;
68483             return updated;
68484         }
68485         function visitGetAccessorDeclaration(node) {
68486             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
68487             enclosingFunctionFlags = 0;
68488             var updated = ts.updateGetAccessor(node, undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node));
68489             enclosingFunctionFlags = savedEnclosingFunctionFlags;
68490             return updated;
68491         }
68492         function visitSetAccessorDeclaration(node) {
68493             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
68494             enclosingFunctionFlags = 0;
68495             var updated = ts.updateSetAccessor(node, undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node));
68496             enclosingFunctionFlags = savedEnclosingFunctionFlags;
68497             return updated;
68498         }
68499         function visitMethodDeclaration(node) {
68500             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
68501             enclosingFunctionFlags = ts.getFunctionFlags(node);
68502             var updated = ts.updateMethod(node, undefined, enclosingFunctionFlags & 1
68503                 ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
68504                 : node.modifiers, enclosingFunctionFlags & 2
68505                 ? undefined
68506                 : 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
68507                 ? transformAsyncGeneratorFunctionBody(node)
68508                 : transformFunctionBody(node));
68509             enclosingFunctionFlags = savedEnclosingFunctionFlags;
68510             return updated;
68511         }
68512         function visitFunctionDeclaration(node) {
68513             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
68514             enclosingFunctionFlags = ts.getFunctionFlags(node);
68515             var updated = ts.updateFunctionDeclaration(node, undefined, enclosingFunctionFlags & 1
68516                 ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
68517                 : node.modifiers, enclosingFunctionFlags & 2
68518                 ? undefined
68519                 : node.asteriskToken, node.name, 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 visitArrowFunction(node) {
68526             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
68527             enclosingFunctionFlags = ts.getFunctionFlags(node);
68528             var updated = ts.updateArrowFunction(node, node.modifiers, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.equalsGreaterThanToken, transformFunctionBody(node));
68529             enclosingFunctionFlags = savedEnclosingFunctionFlags;
68530             return updated;
68531         }
68532         function visitFunctionExpression(node) {
68533             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
68534             enclosingFunctionFlags = ts.getFunctionFlags(node);
68535             var updated = ts.updateFunctionExpression(node, enclosingFunctionFlags & 1
68536                 ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
68537                 : node.modifiers, enclosingFunctionFlags & 2
68538                 ? undefined
68539                 : node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1
68540                 ? transformAsyncGeneratorFunctionBody(node)
68541                 : transformFunctionBody(node));
68542             enclosingFunctionFlags = savedEnclosingFunctionFlags;
68543             return updated;
68544         }
68545         function transformAsyncGeneratorFunctionBody(node) {
68546             resumeLexicalEnvironment();
68547             var statements = [];
68548             var statementOffset = ts.addPrologue(statements, node.body.statements, false, visitor);
68549             appendObjectRestAssignmentsIfNeeded(statements, node);
68550             var savedCapturedSuperProperties = capturedSuperProperties;
68551             var savedHasSuperElementAccess = hasSuperElementAccess;
68552             capturedSuperProperties = ts.createUnderscoreEscapedMap();
68553             hasSuperElementAccess = false;
68554             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)));
68555             var emitSuperHelpers = languageVersion >= 2 && resolver.getNodeCheckFlags(node) & (4096 | 2048);
68556             if (emitSuperHelpers) {
68557                 enableSubstitutionForAsyncMethodsWithSuper();
68558                 var variableStatement = ts.createSuperAccessVariableStatement(resolver, node, capturedSuperProperties);
68559                 substitutedSuperAccessors[ts.getNodeId(variableStatement)] = true;
68560                 ts.insertStatementsAfterStandardPrologue(statements, [variableStatement]);
68561             }
68562             statements.push(returnStatement);
68563             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
68564             var block = ts.updateBlock(node.body, statements);
68565             if (emitSuperHelpers && hasSuperElementAccess) {
68566                 if (resolver.getNodeCheckFlags(node) & 4096) {
68567                     ts.addEmitHelper(block, ts.advancedAsyncSuperHelper);
68568                 }
68569                 else if (resolver.getNodeCheckFlags(node) & 2048) {
68570                     ts.addEmitHelper(block, ts.asyncSuperHelper);
68571                 }
68572             }
68573             capturedSuperProperties = savedCapturedSuperProperties;
68574             hasSuperElementAccess = savedHasSuperElementAccess;
68575             return block;
68576         }
68577         function transformFunctionBody(node) {
68578             resumeLexicalEnvironment();
68579             var statementOffset = 0;
68580             var statements = [];
68581             var body = ts.visitNode(node.body, visitor, ts.isConciseBody);
68582             if (ts.isBlock(body)) {
68583                 statementOffset = ts.addPrologue(statements, body.statements, false, visitor);
68584             }
68585             ts.addRange(statements, appendObjectRestAssignmentsIfNeeded(undefined, node));
68586             var leadingStatements = endLexicalEnvironment();
68587             if (statementOffset > 0 || ts.some(statements) || ts.some(leadingStatements)) {
68588                 var block = ts.convertToFunctionBody(body, true);
68589                 ts.insertStatementsAfterStandardPrologue(statements, leadingStatements);
68590                 ts.addRange(statements, block.statements.slice(statementOffset));
68591                 return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(statements), block.statements));
68592             }
68593             return body;
68594         }
68595         function appendObjectRestAssignmentsIfNeeded(statements, node) {
68596             for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
68597                 var parameter = _a[_i];
68598                 if (parameter.transformFlags & 16384) {
68599                     var temp = ts.getGeneratedNameForNode(parameter);
68600                     var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1, temp, false, true);
68601                     if (ts.some(declarations)) {
68602                         var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList(declarations));
68603                         ts.setEmitFlags(statement, 1048576);
68604                         statements = ts.append(statements, statement);
68605                     }
68606                 }
68607             }
68608             return statements;
68609         }
68610         function enableSubstitutionForAsyncMethodsWithSuper() {
68611             if ((enabledSubstitutions & 1) === 0) {
68612                 enabledSubstitutions |= 1;
68613                 context.enableSubstitution(196);
68614                 context.enableSubstitution(194);
68615                 context.enableSubstitution(195);
68616                 context.enableEmitNotification(245);
68617                 context.enableEmitNotification(161);
68618                 context.enableEmitNotification(163);
68619                 context.enableEmitNotification(164);
68620                 context.enableEmitNotification(162);
68621                 context.enableEmitNotification(225);
68622             }
68623         }
68624         function onEmitNode(hint, node, emitCallback) {
68625             if (enabledSubstitutions & 1 && isSuperContainer(node)) {
68626                 var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 | 4096);
68627                 if (superContainerFlags !== enclosingSuperContainerFlags) {
68628                     var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
68629                     enclosingSuperContainerFlags = superContainerFlags;
68630                     previousOnEmitNode(hint, node, emitCallback);
68631                     enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags;
68632                     return;
68633                 }
68634             }
68635             else if (enabledSubstitutions && substitutedSuperAccessors[ts.getNodeId(node)]) {
68636                 var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
68637                 enclosingSuperContainerFlags = 0;
68638                 previousOnEmitNode(hint, node, emitCallback);
68639                 enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags;
68640                 return;
68641             }
68642             previousOnEmitNode(hint, node, emitCallback);
68643         }
68644         function onSubstituteNode(hint, node) {
68645             node = previousOnSubstituteNode(hint, node);
68646             if (hint === 1 && enclosingSuperContainerFlags) {
68647                 return substituteExpression(node);
68648             }
68649             return node;
68650         }
68651         function substituteExpression(node) {
68652             switch (node.kind) {
68653                 case 194:
68654                     return substitutePropertyAccessExpression(node);
68655                 case 195:
68656                     return substituteElementAccessExpression(node);
68657                 case 196:
68658                     return substituteCallExpression(node);
68659             }
68660             return node;
68661         }
68662         function substitutePropertyAccessExpression(node) {
68663             if (node.expression.kind === 102) {
68664                 return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node);
68665             }
68666             return node;
68667         }
68668         function substituteElementAccessExpression(node) {
68669             if (node.expression.kind === 102) {
68670                 return createSuperElementAccessInAsyncMethod(node.argumentExpression, node);
68671             }
68672             return node;
68673         }
68674         function substituteCallExpression(node) {
68675             var expression = node.expression;
68676             if (ts.isSuperProperty(expression)) {
68677                 var argumentExpression = ts.isPropertyAccessExpression(expression)
68678                     ? substitutePropertyAccessExpression(expression)
68679                     : substituteElementAccessExpression(expression);
68680                 return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, __spreadArrays([
68681                     ts.createThis()
68682                 ], node.arguments));
68683             }
68684             return node;
68685         }
68686         function isSuperContainer(node) {
68687             var kind = node.kind;
68688             return kind === 245
68689                 || kind === 162
68690                 || kind === 161
68691                 || kind === 163
68692                 || kind === 164;
68693         }
68694         function createSuperElementAccessInAsyncMethod(argumentExpression, location) {
68695             if (enclosingSuperContainerFlags & 4096) {
68696                 return ts.setTextRange(ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_superIndex"), undefined, [argumentExpression]), "value"), location);
68697             }
68698             else {
68699                 return ts.setTextRange(ts.createCall(ts.createIdentifier("_superIndex"), undefined, [argumentExpression]), location);
68700             }
68701         }
68702     }
68703     ts.transformES2018 = transformES2018;
68704     ts.assignHelper = {
68705         name: "typescript:assign",
68706         importName: "__assign",
68707         scoped: false,
68708         priority: 1,
68709         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            };"
68710     };
68711     function createAssignHelper(context, attributesSegments) {
68712         if (context.getCompilerOptions().target >= 2) {
68713             return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), undefined, attributesSegments);
68714         }
68715         context.requestEmitHelper(ts.assignHelper);
68716         return ts.createCall(ts.getUnscopedHelperName("__assign"), undefined, attributesSegments);
68717     }
68718     ts.createAssignHelper = createAssignHelper;
68719     ts.awaitHelper = {
68720         name: "typescript:await",
68721         importName: "__await",
68722         scoped: false,
68723         text: "\n            var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }"
68724     };
68725     function createAwaitHelper(context, expression) {
68726         context.requestEmitHelper(ts.awaitHelper);
68727         return ts.createCall(ts.getUnscopedHelperName("__await"), undefined, [expression]);
68728     }
68729     ts.asyncGeneratorHelper = {
68730         name: "typescript:asyncGenerator",
68731         importName: "__asyncGenerator",
68732         scoped: false,
68733         dependencies: [ts.awaitHelper],
68734         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            };"
68735     };
68736     function createAsyncGeneratorHelper(context, generatorFunc, hasLexicalThis) {
68737         context.requestEmitHelper(ts.asyncGeneratorHelper);
68738         (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 | 524288;
68739         return ts.createCall(ts.getUnscopedHelperName("__asyncGenerator"), undefined, [
68740             hasLexicalThis ? ts.createThis() : ts.createVoidZero(),
68741             ts.createIdentifier("arguments"),
68742             generatorFunc
68743         ]);
68744     }
68745     ts.asyncDelegator = {
68746         name: "typescript:asyncDelegator",
68747         importName: "__asyncDelegator",
68748         scoped: false,
68749         dependencies: [ts.awaitHelper],
68750         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            };"
68751     };
68752     function createAsyncDelegatorHelper(context, expression, location) {
68753         context.requestEmitHelper(ts.asyncDelegator);
68754         return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__asyncDelegator"), undefined, [expression]), location);
68755     }
68756     ts.asyncValues = {
68757         name: "typescript:asyncValues",
68758         importName: "__asyncValues",
68759         scoped: false,
68760         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            };"
68761     };
68762     function createAsyncValuesHelper(context, expression, location) {
68763         context.requestEmitHelper(ts.asyncValues);
68764         return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__asyncValues"), undefined, [expression]), location);
68765     }
68766 })(ts || (ts = {}));
68767 var ts;
68768 (function (ts) {
68769     function transformES2019(context) {
68770         return ts.chainBundle(transformSourceFile);
68771         function transformSourceFile(node) {
68772             if (node.isDeclarationFile) {
68773                 return node;
68774             }
68775             return ts.visitEachChild(node, visitor, context);
68776         }
68777         function visitor(node) {
68778             if ((node.transformFlags & 16) === 0) {
68779                 return node;
68780             }
68781             switch (node.kind) {
68782                 case 280:
68783                     return visitCatchClause(node);
68784                 default:
68785                     return ts.visitEachChild(node, visitor, context);
68786             }
68787         }
68788         function visitCatchClause(node) {
68789             if (!node.variableDeclaration) {
68790                 return ts.updateCatchClause(node, ts.createVariableDeclaration(ts.createTempVariable(undefined)), ts.visitNode(node.block, visitor, ts.isBlock));
68791             }
68792             return ts.visitEachChild(node, visitor, context);
68793         }
68794     }
68795     ts.transformES2019 = transformES2019;
68796 })(ts || (ts = {}));
68797 var ts;
68798 (function (ts) {
68799     function transformES2020(context) {
68800         var hoistVariableDeclaration = context.hoistVariableDeclaration;
68801         return ts.chainBundle(transformSourceFile);
68802         function transformSourceFile(node) {
68803             if (node.isDeclarationFile) {
68804                 return node;
68805             }
68806             return ts.visitEachChild(node, visitor, context);
68807         }
68808         function visitor(node) {
68809             if ((node.transformFlags & 8) === 0) {
68810                 return node;
68811             }
68812             switch (node.kind) {
68813                 case 194:
68814                 case 195:
68815                 case 196:
68816                     if (node.flags & 32) {
68817                         var updated = visitOptionalExpression(node, false, false);
68818                         ts.Debug.assertNotNode(updated, ts.isSyntheticReference);
68819                         return updated;
68820                     }
68821                     return ts.visitEachChild(node, visitor, context);
68822                 case 209:
68823                     if (node.operatorToken.kind === 60) {
68824                         return transformNullishCoalescingExpression(node);
68825                     }
68826                     return ts.visitEachChild(node, visitor, context);
68827                 case 203:
68828                     return visitDeleteExpression(node);
68829                 default:
68830                     return ts.visitEachChild(node, visitor, context);
68831             }
68832         }
68833         function flattenChain(chain) {
68834             ts.Debug.assertNotNode(chain, ts.isNonNullChain);
68835             var links = [chain];
68836             while (!chain.questionDotToken && !ts.isTaggedTemplateExpression(chain)) {
68837                 chain = ts.cast(ts.skipPartiallyEmittedExpressions(chain.expression), ts.isOptionalChain);
68838                 ts.Debug.assertNotNode(chain, ts.isNonNullChain);
68839                 links.unshift(chain);
68840             }
68841             return { expression: chain.expression, chain: links };
68842         }
68843         function visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete) {
68844             var expression = visitNonOptionalExpression(node.expression, captureThisArg, isDelete);
68845             if (ts.isSyntheticReference(expression)) {
68846                 return ts.createSyntheticReferenceExpression(ts.updateParen(node, expression.expression), expression.thisArg);
68847             }
68848             return ts.updateParen(node, expression);
68849         }
68850         function visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete) {
68851             if (ts.isOptionalChain(node)) {
68852                 return visitOptionalExpression(node, captureThisArg, isDelete);
68853             }
68854             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
68855             ts.Debug.assertNotNode(expression, ts.isSyntheticReference);
68856             var thisArg;
68857             if (captureThisArg) {
68858                 if (shouldCaptureInTempVariable(expression)) {
68859                     thisArg = ts.createTempVariable(hoistVariableDeclaration);
68860                     expression = ts.createAssignment(thisArg, expression);
68861                 }
68862                 else {
68863                     thisArg = expression;
68864                 }
68865             }
68866             expression = node.kind === 194
68867                 ? ts.updatePropertyAccess(node, expression, ts.visitNode(node.name, visitor, ts.isIdentifier))
68868                 : ts.updateElementAccess(node, expression, ts.visitNode(node.argumentExpression, visitor, ts.isExpression));
68869             return thisArg ? ts.createSyntheticReferenceExpression(expression, thisArg) : expression;
68870         }
68871         function visitNonOptionalCallExpression(node, captureThisArg) {
68872             if (ts.isOptionalChain(node)) {
68873                 return visitOptionalExpression(node, captureThisArg, false);
68874             }
68875             return ts.visitEachChild(node, visitor, context);
68876         }
68877         function visitNonOptionalExpression(node, captureThisArg, isDelete) {
68878             switch (node.kind) {
68879                 case 200: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete);
68880                 case 194:
68881                 case 195: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete);
68882                 case 196: return visitNonOptionalCallExpression(node, captureThisArg);
68883                 default: return ts.visitNode(node, visitor, ts.isExpression);
68884             }
68885         }
68886         function visitOptionalExpression(node, captureThisArg, isDelete) {
68887             var _a = flattenChain(node), expression = _a.expression, chain = _a.chain;
68888             var left = visitNonOptionalExpression(expression, ts.isCallChain(chain[0]), false);
68889             var leftThisArg = ts.isSyntheticReference(left) ? left.thisArg : undefined;
68890             var leftExpression = ts.isSyntheticReference(left) ? left.expression : left;
68891             var capturedLeft = leftExpression;
68892             if (shouldCaptureInTempVariable(leftExpression)) {
68893                 capturedLeft = ts.createTempVariable(hoistVariableDeclaration);
68894                 leftExpression = ts.createAssignment(capturedLeft, leftExpression);
68895             }
68896             var rightExpression = capturedLeft;
68897             var thisArg;
68898             for (var i = 0; i < chain.length; i++) {
68899                 var segment = chain[i];
68900                 switch (segment.kind) {
68901                     case 194:
68902                     case 195:
68903                         if (i === chain.length - 1 && captureThisArg) {
68904                             if (shouldCaptureInTempVariable(rightExpression)) {
68905                                 thisArg = ts.createTempVariable(hoistVariableDeclaration);
68906                                 rightExpression = ts.createAssignment(thisArg, rightExpression);
68907                             }
68908                             else {
68909                                 thisArg = rightExpression;
68910                             }
68911                         }
68912                         rightExpression = segment.kind === 194
68913                             ? ts.createPropertyAccess(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier))
68914                             : ts.createElementAccess(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression));
68915                         break;
68916                     case 196:
68917                         if (i === 0 && leftThisArg) {
68918                             rightExpression = ts.createFunctionCall(rightExpression, leftThisArg.kind === 102 ? ts.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression));
68919                         }
68920                         else {
68921                             rightExpression = ts.createCall(rightExpression, undefined, ts.visitNodes(segment.arguments, visitor, ts.isExpression));
68922                         }
68923                         break;
68924                 }
68925                 ts.setOriginalNode(rightExpression, segment);
68926             }
68927             var target = isDelete
68928                 ? ts.createConditional(createNotNullCondition(leftExpression, capturedLeft, true), ts.createTrue(), ts.createDelete(rightExpression))
68929                 : ts.createConditional(createNotNullCondition(leftExpression, capturedLeft, true), ts.createVoidZero(), rightExpression);
68930             return thisArg ? ts.createSyntheticReferenceExpression(target, thisArg) : target;
68931         }
68932         function createNotNullCondition(left, right, invert) {
68933             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()));
68934         }
68935         function transformNullishCoalescingExpression(node) {
68936             var left = ts.visitNode(node.left, visitor, ts.isExpression);
68937             var right = left;
68938             if (shouldCaptureInTempVariable(left)) {
68939                 right = ts.createTempVariable(hoistVariableDeclaration);
68940                 left = ts.createAssignment(right, left);
68941             }
68942             return ts.createConditional(createNotNullCondition(left, right), right, ts.visitNode(node.right, visitor, ts.isExpression));
68943         }
68944         function shouldCaptureInTempVariable(expression) {
68945             return !ts.isIdentifier(expression) &&
68946                 expression.kind !== 104 &&
68947                 expression.kind !== 102;
68948         }
68949         function visitDeleteExpression(node) {
68950             return ts.isOptionalChain(ts.skipParentheses(node.expression))
68951                 ? ts.setOriginalNode(visitNonOptionalExpression(node.expression, false, true), node)
68952                 : ts.updateDelete(node, ts.visitNode(node.expression, visitor, ts.isExpression));
68953         }
68954     }
68955     ts.transformES2020 = transformES2020;
68956 })(ts || (ts = {}));
68957 var ts;
68958 (function (ts) {
68959     function transformESNext(context) {
68960         return ts.chainBundle(transformSourceFile);
68961         function transformSourceFile(node) {
68962             if (node.isDeclarationFile) {
68963                 return node;
68964             }
68965             return ts.visitEachChild(node, visitor, context);
68966         }
68967         function visitor(node) {
68968             if ((node.transformFlags & 4) === 0) {
68969                 return node;
68970             }
68971             switch (node.kind) {
68972                 default:
68973                     return ts.visitEachChild(node, visitor, context);
68974             }
68975         }
68976     }
68977     ts.transformESNext = transformESNext;
68978 })(ts || (ts = {}));
68979 var ts;
68980 (function (ts) {
68981     function transformJsx(context) {
68982         var compilerOptions = context.getCompilerOptions();
68983         var currentSourceFile;
68984         return ts.chainBundle(transformSourceFile);
68985         function transformSourceFile(node) {
68986             if (node.isDeclarationFile) {
68987                 return node;
68988             }
68989             currentSourceFile = node;
68990             var visited = ts.visitEachChild(node, visitor, context);
68991             ts.addEmitHelpers(visited, context.readEmitHelpers());
68992             return visited;
68993         }
68994         function visitor(node) {
68995             if (node.transformFlags & 2) {
68996                 return visitorWorker(node);
68997             }
68998             else {
68999                 return node;
69000             }
69001         }
69002         function visitorWorker(node) {
69003             switch (node.kind) {
69004                 case 266:
69005                     return visitJsxElement(node, false);
69006                 case 267:
69007                     return visitJsxSelfClosingElement(node, false);
69008                 case 270:
69009                     return visitJsxFragment(node, false);
69010                 case 276:
69011                     return visitJsxExpression(node);
69012                 default:
69013                     return ts.visitEachChild(node, visitor, context);
69014             }
69015         }
69016         function transformJsxChildToExpression(node) {
69017             switch (node.kind) {
69018                 case 11:
69019                     return visitJsxText(node);
69020                 case 276:
69021                     return visitJsxExpression(node);
69022                 case 266:
69023                     return visitJsxElement(node, true);
69024                 case 267:
69025                     return visitJsxSelfClosingElement(node, true);
69026                 case 270:
69027                     return visitJsxFragment(node, true);
69028                 default:
69029                     return ts.Debug.failBadSyntaxKind(node);
69030             }
69031         }
69032         function visitJsxElement(node, isChild) {
69033             return visitJsxOpeningLikeElement(node.openingElement, node.children, isChild, node);
69034         }
69035         function visitJsxSelfClosingElement(node, isChild) {
69036             return visitJsxOpeningLikeElement(node, undefined, isChild, node);
69037         }
69038         function visitJsxFragment(node, isChild) {
69039             return visitJsxOpeningFragment(node.openingFragment, node.children, isChild, node);
69040         }
69041         function visitJsxOpeningLikeElement(node, children, isChild, location) {
69042             var tagName = getTagName(node);
69043             var objectProperties;
69044             var attrs = node.attributes.properties;
69045             if (attrs.length === 0) {
69046                 objectProperties = ts.createNull();
69047             }
69048             else {
69049                 var segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread
69050                     ? ts.map(attrs, transformJsxSpreadAttributeToExpression)
69051                     : ts.createObjectLiteral(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); }));
69052                 if (ts.isJsxSpreadAttribute(attrs[0])) {
69053                     segments.unshift(ts.createObjectLiteral());
69054                 }
69055                 objectProperties = ts.singleOrUndefined(segments);
69056                 if (!objectProperties) {
69057                     objectProperties = ts.createAssignHelper(context, segments);
69058                 }
69059             }
69060             var element = ts.createExpressionForJsxElement(context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, tagName, objectProperties, ts.mapDefined(children, transformJsxChildToExpression), node, location);
69061             if (isChild) {
69062                 ts.startOnNewLine(element);
69063             }
69064             return element;
69065         }
69066         function visitJsxOpeningFragment(node, children, isChild, location) {
69067             var element = ts.createExpressionForJsxFragment(context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, ts.mapDefined(children, transformJsxChildToExpression), node, location);
69068             if (isChild) {
69069                 ts.startOnNewLine(element);
69070             }
69071             return element;
69072         }
69073         function transformJsxSpreadAttributeToExpression(node) {
69074             return ts.visitNode(node.expression, visitor, ts.isExpression);
69075         }
69076         function transformJsxAttributeToObjectLiteralElement(node) {
69077             var name = getAttributeName(node);
69078             var expression = transformJsxAttributeInitializer(node.initializer);
69079             return ts.createPropertyAssignment(name, expression);
69080         }
69081         function transformJsxAttributeInitializer(node) {
69082             if (node === undefined) {
69083                 return ts.createTrue();
69084             }
69085             else if (node.kind === 10) {
69086                 var literal = ts.createLiteral(tryDecodeEntities(node.text) || node.text);
69087                 literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile);
69088                 return ts.setTextRange(literal, node);
69089             }
69090             else if (node.kind === 276) {
69091                 if (node.expression === undefined) {
69092                     return ts.createTrue();
69093                 }
69094                 return visitJsxExpression(node);
69095             }
69096             else {
69097                 return ts.Debug.failBadSyntaxKind(node);
69098             }
69099         }
69100         function visitJsxText(node) {
69101             var fixed = fixupWhitespaceAndDecodeEntities(node.text);
69102             return fixed === undefined ? undefined : ts.createLiteral(fixed);
69103         }
69104         function fixupWhitespaceAndDecodeEntities(text) {
69105             var acc;
69106             var firstNonWhitespace = 0;
69107             var lastNonWhitespace = -1;
69108             for (var i = 0; i < text.length; i++) {
69109                 var c = text.charCodeAt(i);
69110                 if (ts.isLineBreak(c)) {
69111                     if (firstNonWhitespace !== -1 && lastNonWhitespace !== -1) {
69112                         acc = addLineOfJsxText(acc, text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1));
69113                     }
69114                     firstNonWhitespace = -1;
69115                 }
69116                 else if (!ts.isWhiteSpaceSingleLine(c)) {
69117                     lastNonWhitespace = i;
69118                     if (firstNonWhitespace === -1) {
69119                         firstNonWhitespace = i;
69120                     }
69121                 }
69122             }
69123             return firstNonWhitespace !== -1
69124                 ? addLineOfJsxText(acc, text.substr(firstNonWhitespace))
69125                 : acc;
69126         }
69127         function addLineOfJsxText(acc, trimmedLine) {
69128             var decoded = decodeEntities(trimmedLine);
69129             return acc === undefined ? decoded : acc + " " + decoded;
69130         }
69131         function decodeEntities(text) {
69132             return text.replace(/&((#((\d+)|x([\da-fA-F]+)))|(\w+));/g, function (match, _all, _number, _digits, decimal, hex, word) {
69133                 if (decimal) {
69134                     return ts.utf16EncodeAsString(parseInt(decimal, 10));
69135                 }
69136                 else if (hex) {
69137                     return ts.utf16EncodeAsString(parseInt(hex, 16));
69138                 }
69139                 else {
69140                     var ch = entities.get(word);
69141                     return ch ? ts.utf16EncodeAsString(ch) : match;
69142                 }
69143             });
69144         }
69145         function tryDecodeEntities(text) {
69146             var decoded = decodeEntities(text);
69147             return decoded === text ? undefined : decoded;
69148         }
69149         function getTagName(node) {
69150             if (node.kind === 266) {
69151                 return getTagName(node.openingElement);
69152             }
69153             else {
69154                 var name = node.tagName;
69155                 if (ts.isIdentifier(name) && ts.isIntrinsicJsxName(name.escapedText)) {
69156                     return ts.createLiteral(ts.idText(name));
69157                 }
69158                 else {
69159                     return ts.createExpressionFromEntityName(name);
69160                 }
69161             }
69162         }
69163         function getAttributeName(node) {
69164             var name = node.name;
69165             var text = ts.idText(name);
69166             if (/^[A-Za-z_]\w*$/.test(text)) {
69167                 return name;
69168             }
69169             else {
69170                 return ts.createLiteral(text);
69171             }
69172         }
69173         function visitJsxExpression(node) {
69174             return ts.visitNode(node.expression, visitor, ts.isExpression);
69175         }
69176     }
69177     ts.transformJsx = transformJsx;
69178     var entities = ts.createMapFromTemplate({
69179         quot: 0x0022,
69180         amp: 0x0026,
69181         apos: 0x0027,
69182         lt: 0x003C,
69183         gt: 0x003E,
69184         nbsp: 0x00A0,
69185         iexcl: 0x00A1,
69186         cent: 0x00A2,
69187         pound: 0x00A3,
69188         curren: 0x00A4,
69189         yen: 0x00A5,
69190         brvbar: 0x00A6,
69191         sect: 0x00A7,
69192         uml: 0x00A8,
69193         copy: 0x00A9,
69194         ordf: 0x00AA,
69195         laquo: 0x00AB,
69196         not: 0x00AC,
69197         shy: 0x00AD,
69198         reg: 0x00AE,
69199         macr: 0x00AF,
69200         deg: 0x00B0,
69201         plusmn: 0x00B1,
69202         sup2: 0x00B2,
69203         sup3: 0x00B3,
69204         acute: 0x00B4,
69205         micro: 0x00B5,
69206         para: 0x00B6,
69207         middot: 0x00B7,
69208         cedil: 0x00B8,
69209         sup1: 0x00B9,
69210         ordm: 0x00BA,
69211         raquo: 0x00BB,
69212         frac14: 0x00BC,
69213         frac12: 0x00BD,
69214         frac34: 0x00BE,
69215         iquest: 0x00BF,
69216         Agrave: 0x00C0,
69217         Aacute: 0x00C1,
69218         Acirc: 0x00C2,
69219         Atilde: 0x00C3,
69220         Auml: 0x00C4,
69221         Aring: 0x00C5,
69222         AElig: 0x00C6,
69223         Ccedil: 0x00C7,
69224         Egrave: 0x00C8,
69225         Eacute: 0x00C9,
69226         Ecirc: 0x00CA,
69227         Euml: 0x00CB,
69228         Igrave: 0x00CC,
69229         Iacute: 0x00CD,
69230         Icirc: 0x00CE,
69231         Iuml: 0x00CF,
69232         ETH: 0x00D0,
69233         Ntilde: 0x00D1,
69234         Ograve: 0x00D2,
69235         Oacute: 0x00D3,
69236         Ocirc: 0x00D4,
69237         Otilde: 0x00D5,
69238         Ouml: 0x00D6,
69239         times: 0x00D7,
69240         Oslash: 0x00D8,
69241         Ugrave: 0x00D9,
69242         Uacute: 0x00DA,
69243         Ucirc: 0x00DB,
69244         Uuml: 0x00DC,
69245         Yacute: 0x00DD,
69246         THORN: 0x00DE,
69247         szlig: 0x00DF,
69248         agrave: 0x00E0,
69249         aacute: 0x00E1,
69250         acirc: 0x00E2,
69251         atilde: 0x00E3,
69252         auml: 0x00E4,
69253         aring: 0x00E5,
69254         aelig: 0x00E6,
69255         ccedil: 0x00E7,
69256         egrave: 0x00E8,
69257         eacute: 0x00E9,
69258         ecirc: 0x00EA,
69259         euml: 0x00EB,
69260         igrave: 0x00EC,
69261         iacute: 0x00ED,
69262         icirc: 0x00EE,
69263         iuml: 0x00EF,
69264         eth: 0x00F0,
69265         ntilde: 0x00F1,
69266         ograve: 0x00F2,
69267         oacute: 0x00F3,
69268         ocirc: 0x00F4,
69269         otilde: 0x00F5,
69270         ouml: 0x00F6,
69271         divide: 0x00F7,
69272         oslash: 0x00F8,
69273         ugrave: 0x00F9,
69274         uacute: 0x00FA,
69275         ucirc: 0x00FB,
69276         uuml: 0x00FC,
69277         yacute: 0x00FD,
69278         thorn: 0x00FE,
69279         yuml: 0x00FF,
69280         OElig: 0x0152,
69281         oelig: 0x0153,
69282         Scaron: 0x0160,
69283         scaron: 0x0161,
69284         Yuml: 0x0178,
69285         fnof: 0x0192,
69286         circ: 0x02C6,
69287         tilde: 0x02DC,
69288         Alpha: 0x0391,
69289         Beta: 0x0392,
69290         Gamma: 0x0393,
69291         Delta: 0x0394,
69292         Epsilon: 0x0395,
69293         Zeta: 0x0396,
69294         Eta: 0x0397,
69295         Theta: 0x0398,
69296         Iota: 0x0399,
69297         Kappa: 0x039A,
69298         Lambda: 0x039B,
69299         Mu: 0x039C,
69300         Nu: 0x039D,
69301         Xi: 0x039E,
69302         Omicron: 0x039F,
69303         Pi: 0x03A0,
69304         Rho: 0x03A1,
69305         Sigma: 0x03A3,
69306         Tau: 0x03A4,
69307         Upsilon: 0x03A5,
69308         Phi: 0x03A6,
69309         Chi: 0x03A7,
69310         Psi: 0x03A8,
69311         Omega: 0x03A9,
69312         alpha: 0x03B1,
69313         beta: 0x03B2,
69314         gamma: 0x03B3,
69315         delta: 0x03B4,
69316         epsilon: 0x03B5,
69317         zeta: 0x03B6,
69318         eta: 0x03B7,
69319         theta: 0x03B8,
69320         iota: 0x03B9,
69321         kappa: 0x03BA,
69322         lambda: 0x03BB,
69323         mu: 0x03BC,
69324         nu: 0x03BD,
69325         xi: 0x03BE,
69326         omicron: 0x03BF,
69327         pi: 0x03C0,
69328         rho: 0x03C1,
69329         sigmaf: 0x03C2,
69330         sigma: 0x03C3,
69331         tau: 0x03C4,
69332         upsilon: 0x03C5,
69333         phi: 0x03C6,
69334         chi: 0x03C7,
69335         psi: 0x03C8,
69336         omega: 0x03C9,
69337         thetasym: 0x03D1,
69338         upsih: 0x03D2,
69339         piv: 0x03D6,
69340         ensp: 0x2002,
69341         emsp: 0x2003,
69342         thinsp: 0x2009,
69343         zwnj: 0x200C,
69344         zwj: 0x200D,
69345         lrm: 0x200E,
69346         rlm: 0x200F,
69347         ndash: 0x2013,
69348         mdash: 0x2014,
69349         lsquo: 0x2018,
69350         rsquo: 0x2019,
69351         sbquo: 0x201A,
69352         ldquo: 0x201C,
69353         rdquo: 0x201D,
69354         bdquo: 0x201E,
69355         dagger: 0x2020,
69356         Dagger: 0x2021,
69357         bull: 0x2022,
69358         hellip: 0x2026,
69359         permil: 0x2030,
69360         prime: 0x2032,
69361         Prime: 0x2033,
69362         lsaquo: 0x2039,
69363         rsaquo: 0x203A,
69364         oline: 0x203E,
69365         frasl: 0x2044,
69366         euro: 0x20AC,
69367         image: 0x2111,
69368         weierp: 0x2118,
69369         real: 0x211C,
69370         trade: 0x2122,
69371         alefsym: 0x2135,
69372         larr: 0x2190,
69373         uarr: 0x2191,
69374         rarr: 0x2192,
69375         darr: 0x2193,
69376         harr: 0x2194,
69377         crarr: 0x21B5,
69378         lArr: 0x21D0,
69379         uArr: 0x21D1,
69380         rArr: 0x21D2,
69381         dArr: 0x21D3,
69382         hArr: 0x21D4,
69383         forall: 0x2200,
69384         part: 0x2202,
69385         exist: 0x2203,
69386         empty: 0x2205,
69387         nabla: 0x2207,
69388         isin: 0x2208,
69389         notin: 0x2209,
69390         ni: 0x220B,
69391         prod: 0x220F,
69392         sum: 0x2211,
69393         minus: 0x2212,
69394         lowast: 0x2217,
69395         radic: 0x221A,
69396         prop: 0x221D,
69397         infin: 0x221E,
69398         ang: 0x2220,
69399         and: 0x2227,
69400         or: 0x2228,
69401         cap: 0x2229,
69402         cup: 0x222A,
69403         int: 0x222B,
69404         there4: 0x2234,
69405         sim: 0x223C,
69406         cong: 0x2245,
69407         asymp: 0x2248,
69408         ne: 0x2260,
69409         equiv: 0x2261,
69410         le: 0x2264,
69411         ge: 0x2265,
69412         sub: 0x2282,
69413         sup: 0x2283,
69414         nsub: 0x2284,
69415         sube: 0x2286,
69416         supe: 0x2287,
69417         oplus: 0x2295,
69418         otimes: 0x2297,
69419         perp: 0x22A5,
69420         sdot: 0x22C5,
69421         lceil: 0x2308,
69422         rceil: 0x2309,
69423         lfloor: 0x230A,
69424         rfloor: 0x230B,
69425         lang: 0x2329,
69426         rang: 0x232A,
69427         loz: 0x25CA,
69428         spades: 0x2660,
69429         clubs: 0x2663,
69430         hearts: 0x2665,
69431         diams: 0x2666
69432     });
69433 })(ts || (ts = {}));
69434 var ts;
69435 (function (ts) {
69436     function transformES2016(context) {
69437         var hoistVariableDeclaration = context.hoistVariableDeclaration;
69438         return ts.chainBundle(transformSourceFile);
69439         function transformSourceFile(node) {
69440             if (node.isDeclarationFile) {
69441                 return node;
69442             }
69443             return ts.visitEachChild(node, visitor, context);
69444         }
69445         function visitor(node) {
69446             if ((node.transformFlags & 128) === 0) {
69447                 return node;
69448             }
69449             switch (node.kind) {
69450                 case 209:
69451                     return visitBinaryExpression(node);
69452                 default:
69453                     return ts.visitEachChild(node, visitor, context);
69454             }
69455         }
69456         function visitBinaryExpression(node) {
69457             switch (node.operatorToken.kind) {
69458                 case 66:
69459                     return visitExponentiationAssignmentExpression(node);
69460                 case 42:
69461                     return visitExponentiationExpression(node);
69462                 default:
69463                     return ts.visitEachChild(node, visitor, context);
69464             }
69465         }
69466         function visitExponentiationAssignmentExpression(node) {
69467             var target;
69468             var value;
69469             var left = ts.visitNode(node.left, visitor, ts.isExpression);
69470             var right = ts.visitNode(node.right, visitor, ts.isExpression);
69471             if (ts.isElementAccessExpression(left)) {
69472                 var expressionTemp = ts.createTempVariable(hoistVariableDeclaration);
69473                 var argumentExpressionTemp = ts.createTempVariable(hoistVariableDeclaration);
69474                 target = ts.setTextRange(ts.createElementAccess(ts.setTextRange(ts.createAssignment(expressionTemp, left.expression), left.expression), ts.setTextRange(ts.createAssignment(argumentExpressionTemp, left.argumentExpression), left.argumentExpression)), left);
69475                 value = ts.setTextRange(ts.createElementAccess(expressionTemp, argumentExpressionTemp), left);
69476             }
69477             else if (ts.isPropertyAccessExpression(left)) {
69478                 var expressionTemp = ts.createTempVariable(hoistVariableDeclaration);
69479                 target = ts.setTextRange(ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(expressionTemp, left.expression), left.expression), left.name), left);
69480                 value = ts.setTextRange(ts.createPropertyAccess(expressionTemp, left.name), left);
69481             }
69482             else {
69483                 target = left;
69484                 value = left;
69485             }
69486             return ts.setTextRange(ts.createAssignment(target, ts.createMathPow(value, right, node)), node);
69487         }
69488         function visitExponentiationExpression(node) {
69489             var left = ts.visitNode(node.left, visitor, ts.isExpression);
69490             var right = ts.visitNode(node.right, visitor, ts.isExpression);
69491             return ts.createMathPow(left, right, node);
69492         }
69493     }
69494     ts.transformES2016 = transformES2016;
69495 })(ts || (ts = {}));
69496 var ts;
69497 (function (ts) {
69498     function transformES2015(context) {
69499         var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
69500         var compilerOptions = context.getCompilerOptions();
69501         var resolver = context.getEmitResolver();
69502         var previousOnSubstituteNode = context.onSubstituteNode;
69503         var previousOnEmitNode = context.onEmitNode;
69504         context.onEmitNode = onEmitNode;
69505         context.onSubstituteNode = onSubstituteNode;
69506         var currentSourceFile;
69507         var currentText;
69508         var hierarchyFacts;
69509         var taggedTemplateStringDeclarations;
69510         function recordTaggedTemplateString(temp) {
69511             taggedTemplateStringDeclarations = ts.append(taggedTemplateStringDeclarations, ts.createVariableDeclaration(temp));
69512         }
69513         var convertedLoopState;
69514         var enabledSubstitutions;
69515         return ts.chainBundle(transformSourceFile);
69516         function transformSourceFile(node) {
69517             if (node.isDeclarationFile) {
69518                 return node;
69519             }
69520             currentSourceFile = node;
69521             currentText = node.text;
69522             var visited = visitSourceFile(node);
69523             ts.addEmitHelpers(visited, context.readEmitHelpers());
69524             currentSourceFile = undefined;
69525             currentText = undefined;
69526             taggedTemplateStringDeclarations = undefined;
69527             hierarchyFacts = 0;
69528             return visited;
69529         }
69530         function enterSubtree(excludeFacts, includeFacts) {
69531             var ancestorFacts = hierarchyFacts;
69532             hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 16383;
69533             return ancestorFacts;
69534         }
69535         function exitSubtree(ancestorFacts, excludeFacts, includeFacts) {
69536             hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -16384 | ancestorFacts;
69537         }
69538         function isReturnVoidStatementInConstructorWithCapturedSuper(node) {
69539             return (hierarchyFacts & 8192) !== 0
69540                 && node.kind === 235
69541                 && !node.expression;
69542         }
69543         function shouldVisitNode(node) {
69544             return (node.transformFlags & 256) !== 0
69545                 || convertedLoopState !== undefined
69546                 || (hierarchyFacts & 8192 && (ts.isStatement(node) || (node.kind === 223)))
69547                 || (ts.isIterationStatement(node, false) && shouldConvertIterationStatement(node))
69548                 || (ts.getEmitFlags(node) & 33554432) !== 0;
69549         }
69550         function visitor(node) {
69551             if (shouldVisitNode(node)) {
69552                 return visitJavaScript(node);
69553             }
69554             else {
69555                 return node;
69556             }
69557         }
69558         function callExpressionVisitor(node) {
69559             if (node.kind === 102) {
69560                 return visitSuperKeyword(true);
69561             }
69562             return visitor(node);
69563         }
69564         function visitJavaScript(node) {
69565             switch (node.kind) {
69566                 case 120:
69567                     return undefined;
69568                 case 245:
69569                     return visitClassDeclaration(node);
69570                 case 214:
69571                     return visitClassExpression(node);
69572                 case 156:
69573                     return visitParameter(node);
69574                 case 244:
69575                     return visitFunctionDeclaration(node);
69576                 case 202:
69577                     return visitArrowFunction(node);
69578                 case 201:
69579                     return visitFunctionExpression(node);
69580                 case 242:
69581                     return visitVariableDeclaration(node);
69582                 case 75:
69583                     return visitIdentifier(node);
69584                 case 243:
69585                     return visitVariableDeclarationList(node);
69586                 case 237:
69587                     return visitSwitchStatement(node);
69588                 case 251:
69589                     return visitCaseBlock(node);
69590                 case 223:
69591                     return visitBlock(node, false);
69592                 case 234:
69593                 case 233:
69594                     return visitBreakOrContinueStatement(node);
69595                 case 238:
69596                     return visitLabeledStatement(node);
69597                 case 228:
69598                 case 229:
69599                     return visitDoOrWhileStatement(node, undefined);
69600                 case 230:
69601                     return visitForStatement(node, undefined);
69602                 case 231:
69603                     return visitForInStatement(node, undefined);
69604                 case 232:
69605                     return visitForOfStatement(node, undefined);
69606                 case 226:
69607                     return visitExpressionStatement(node);
69608                 case 193:
69609                     return visitObjectLiteralExpression(node);
69610                 case 280:
69611                     return visitCatchClause(node);
69612                 case 282:
69613                     return visitShorthandPropertyAssignment(node);
69614                 case 154:
69615                     return visitComputedPropertyName(node);
69616                 case 192:
69617                     return visitArrayLiteralExpression(node);
69618                 case 196:
69619                     return visitCallExpression(node);
69620                 case 197:
69621                     return visitNewExpression(node);
69622                 case 200:
69623                     return visitParenthesizedExpression(node, true);
69624                 case 209:
69625                     return visitBinaryExpression(node, true);
69626                 case 14:
69627                 case 15:
69628                 case 16:
69629                 case 17:
69630                     return visitTemplateLiteral(node);
69631                 case 10:
69632                     return visitStringLiteral(node);
69633                 case 8:
69634                     return visitNumericLiteral(node);
69635                 case 198:
69636                     return visitTaggedTemplateExpression(node);
69637                 case 211:
69638                     return visitTemplateExpression(node);
69639                 case 212:
69640                     return visitYieldExpression(node);
69641                 case 213:
69642                     return visitSpreadElement(node);
69643                 case 102:
69644                     return visitSuperKeyword(false);
69645                 case 104:
69646                     return visitThisKeyword(node);
69647                 case 219:
69648                     return visitMetaProperty(node);
69649                 case 161:
69650                     return visitMethodDeclaration(node);
69651                 case 163:
69652                 case 164:
69653                     return visitAccessorDeclaration(node);
69654                 case 225:
69655                     return visitVariableStatement(node);
69656                 case 235:
69657                     return visitReturnStatement(node);
69658                 default:
69659                     return ts.visitEachChild(node, visitor, context);
69660             }
69661         }
69662         function visitSourceFile(node) {
69663             var ancestorFacts = enterSubtree(8064, 64);
69664             var prologue = [];
69665             var statements = [];
69666             startLexicalEnvironment();
69667             var statementOffset = ts.addStandardPrologue(prologue, node.statements, false);
69668             statementOffset = ts.addCustomPrologue(prologue, node.statements, statementOffset, visitor);
69669             ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset));
69670             if (taggedTemplateStringDeclarations) {
69671                 statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(taggedTemplateStringDeclarations)));
69672             }
69673             ts.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
69674             insertCaptureThisForNodeIfNeeded(prologue, node);
69675             exitSubtree(ancestorFacts, 0, 0);
69676             return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(ts.concatenate(prologue, statements)), node.statements));
69677         }
69678         function visitSwitchStatement(node) {
69679             if (convertedLoopState !== undefined) {
69680                 var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps;
69681                 convertedLoopState.allowedNonLabeledJumps |= 2;
69682                 var result = ts.visitEachChild(node, visitor, context);
69683                 convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps;
69684                 return result;
69685             }
69686             return ts.visitEachChild(node, visitor, context);
69687         }
69688         function visitCaseBlock(node) {
69689             var ancestorFacts = enterSubtree(7104, 0);
69690             var updated = ts.visitEachChild(node, visitor, context);
69691             exitSubtree(ancestorFacts, 0, 0);
69692             return updated;
69693         }
69694         function returnCapturedThis(node) {
69695             return ts.setOriginalNode(ts.createReturn(ts.createFileLevelUniqueName("_this")), node);
69696         }
69697         function visitReturnStatement(node) {
69698             if (convertedLoopState) {
69699                 convertedLoopState.nonLocalJumps |= 8;
69700                 if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) {
69701                     node = returnCapturedThis(node);
69702                 }
69703                 return ts.createReturn(ts.createObjectLiteral([
69704                     ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression
69705                         ? ts.visitNode(node.expression, visitor, ts.isExpression)
69706                         : ts.createVoidZero())
69707                 ]));
69708             }
69709             else if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) {
69710                 return returnCapturedThis(node);
69711             }
69712             return ts.visitEachChild(node, visitor, context);
69713         }
69714         function visitThisKeyword(node) {
69715             if (hierarchyFacts & 2) {
69716                 hierarchyFacts |= 32768;
69717             }
69718             if (convertedLoopState) {
69719                 if (hierarchyFacts & 2) {
69720                     convertedLoopState.containsLexicalThis = true;
69721                     return node;
69722                 }
69723                 return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this"));
69724             }
69725             return node;
69726         }
69727         function visitIdentifier(node) {
69728             if (!convertedLoopState) {
69729                 return node;
69730             }
69731             if (ts.isGeneratedIdentifier(node)) {
69732                 return node;
69733             }
69734             if (node.escapedText !== "arguments" || !resolver.isArgumentsLocalBinding(node)) {
69735                 return node;
69736             }
69737             return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = ts.createUniqueName("arguments"));
69738         }
69739         function visitBreakOrContinueStatement(node) {
69740             if (convertedLoopState) {
69741                 var jump = node.kind === 234 ? 2 : 4;
69742                 var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(ts.idText(node.label))) ||
69743                     (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump));
69744                 if (!canUseBreakOrContinue) {
69745                     var labelMarker = void 0;
69746                     var label = node.label;
69747                     if (!label) {
69748                         if (node.kind === 234) {
69749                             convertedLoopState.nonLocalJumps |= 2;
69750                             labelMarker = "break";
69751                         }
69752                         else {
69753                             convertedLoopState.nonLocalJumps |= 4;
69754                             labelMarker = "continue";
69755                         }
69756                     }
69757                     else {
69758                         if (node.kind === 234) {
69759                             labelMarker = "break-" + label.escapedText;
69760                             setLabeledJump(convertedLoopState, true, ts.idText(label), labelMarker);
69761                         }
69762                         else {
69763                             labelMarker = "continue-" + label.escapedText;
69764                             setLabeledJump(convertedLoopState, false, ts.idText(label), labelMarker);
69765                         }
69766                     }
69767                     var returnExpression = ts.createLiteral(labelMarker);
69768                     if (convertedLoopState.loopOutParameters.length) {
69769                         var outParams = convertedLoopState.loopOutParameters;
69770                         var expr = void 0;
69771                         for (var i = 0; i < outParams.length; i++) {
69772                             var copyExpr = copyOutParameter(outParams[i], 1);
69773                             if (i === 0) {
69774                                 expr = copyExpr;
69775                             }
69776                             else {
69777                                 expr = ts.createBinary(expr, 27, copyExpr);
69778                             }
69779                         }
69780                         returnExpression = ts.createBinary(expr, 27, returnExpression);
69781                     }
69782                     return ts.createReturn(returnExpression);
69783                 }
69784             }
69785             return ts.visitEachChild(node, visitor, context);
69786         }
69787         function visitClassDeclaration(node) {
69788             var variable = ts.createVariableDeclaration(ts.getLocalName(node, true), undefined, transformClassLikeDeclarationToExpression(node));
69789             ts.setOriginalNode(variable, node);
69790             var statements = [];
69791             var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([variable]));
69792             ts.setOriginalNode(statement, node);
69793             ts.setTextRange(statement, node);
69794             ts.startOnNewLine(statement);
69795             statements.push(statement);
69796             if (ts.hasModifier(node, 1)) {
69797                 var exportStatement = ts.hasModifier(node, 512)
69798                     ? ts.createExportDefault(ts.getLocalName(node))
69799                     : ts.createExternalModuleExport(ts.getLocalName(node));
69800                 ts.setOriginalNode(exportStatement, statement);
69801                 statements.push(exportStatement);
69802             }
69803             var emitFlags = ts.getEmitFlags(node);
69804             if ((emitFlags & 4194304) === 0) {
69805                 statements.push(ts.createEndOfDeclarationMarker(node));
69806                 ts.setEmitFlags(statement, emitFlags | 4194304);
69807             }
69808             return ts.singleOrMany(statements);
69809         }
69810         function visitClassExpression(node) {
69811             return transformClassLikeDeclarationToExpression(node);
69812         }
69813         function transformClassLikeDeclarationToExpression(node) {
69814             if (node.name) {
69815                 enableSubstitutionsForBlockScopedBindings();
69816             }
69817             var extendsClauseElement = ts.getClassExtendsHeritageElement(node);
69818             var classFunction = ts.createFunctionExpression(undefined, undefined, undefined, undefined, extendsClauseElement ? [ts.createParameter(undefined, undefined, undefined, ts.createFileLevelUniqueName("_super"))] : [], undefined, transformClassBody(node, extendsClauseElement));
69819             ts.setEmitFlags(classFunction, (ts.getEmitFlags(node) & 65536) | 524288);
69820             var inner = ts.createPartiallyEmittedExpression(classFunction);
69821             inner.end = node.end;
69822             ts.setEmitFlags(inner, 1536);
69823             var outer = ts.createPartiallyEmittedExpression(inner);
69824             outer.end = ts.skipTrivia(currentText, node.pos);
69825             ts.setEmitFlags(outer, 1536);
69826             var result = ts.createParen(ts.createCall(outer, undefined, extendsClauseElement
69827                 ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)]
69828                 : []));
69829             ts.addSyntheticLeadingComment(result, 3, "* @class ");
69830             return result;
69831         }
69832         function transformClassBody(node, extendsClauseElement) {
69833             var statements = [];
69834             startLexicalEnvironment();
69835             addExtendsHelperIfNeeded(statements, node, extendsClauseElement);
69836             addConstructor(statements, node, extendsClauseElement);
69837             addClassMembers(statements, node);
69838             var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 19);
69839             var localName = ts.getInternalName(node);
69840             var outer = ts.createPartiallyEmittedExpression(localName);
69841             outer.end = closingBraceLocation.end;
69842             ts.setEmitFlags(outer, 1536);
69843             var statement = ts.createReturn(outer);
69844             statement.pos = closingBraceLocation.pos;
69845             ts.setEmitFlags(statement, 1536 | 384);
69846             statements.push(statement);
69847             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
69848             var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), node.members), true);
69849             ts.setEmitFlags(block, 1536);
69850             return block;
69851         }
69852         function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) {
69853             if (extendsClauseElement) {
69854                 statements.push(ts.setTextRange(ts.createExpressionStatement(createExtendsHelper(context, ts.getInternalName(node))), extendsClauseElement));
69855             }
69856         }
69857         function addConstructor(statements, node, extendsClauseElement) {
69858             var savedConvertedLoopState = convertedLoopState;
69859             convertedLoopState = undefined;
69860             var ancestorFacts = enterSubtree(16278, 73);
69861             var constructor = ts.getFirstConstructorWithBody(node);
69862             var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined);
69863             var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, ts.getInternalName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper));
69864             ts.setTextRange(constructorFunction, constructor || node);
69865             if (extendsClauseElement) {
69866                 ts.setEmitFlags(constructorFunction, 8);
69867             }
69868             statements.push(constructorFunction);
69869             exitSubtree(ancestorFacts, 49152, 0);
69870             convertedLoopState = savedConvertedLoopState;
69871         }
69872         function transformConstructorParameters(constructor, hasSynthesizedSuper) {
69873             return ts.visitParameterList(constructor && !hasSynthesizedSuper ? constructor.parameters : undefined, visitor, context)
69874                 || [];
69875         }
69876         function createDefaultConstructorBody(node, isDerivedClass) {
69877             var statements = [];
69878             resumeLexicalEnvironment();
69879             ts.mergeLexicalEnvironment(statements, endLexicalEnvironment());
69880             if (isDerivedClass) {
69881                 statements.push(ts.createReturn(createDefaultSuperCallOrThis()));
69882             }
69883             var statementsArray = ts.createNodeArray(statements);
69884             ts.setTextRange(statementsArray, node.members);
69885             var block = ts.createBlock(statementsArray, true);
69886             ts.setTextRange(block, node);
69887             ts.setEmitFlags(block, 1536);
69888             return block;
69889         }
69890         function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) {
69891             var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 100;
69892             if (!constructor)
69893                 return createDefaultConstructorBody(node, isDerivedClass);
69894             var prologue = [];
69895             var statements = [];
69896             resumeLexicalEnvironment();
69897             var statementOffset = 0;
69898             if (!hasSynthesizedSuper)
69899                 statementOffset = ts.addStandardPrologue(prologue, constructor.body.statements, false);
69900             addDefaultValueAssignmentsIfNeeded(statements, constructor);
69901             addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper);
69902             if (!hasSynthesizedSuper)
69903                 statementOffset = ts.addCustomPrologue(statements, constructor.body.statements, statementOffset, visitor);
69904             var superCallExpression;
69905             if (hasSynthesizedSuper) {
69906                 superCallExpression = createDefaultSuperCallOrThis();
69907             }
69908             else if (isDerivedClass && statementOffset < constructor.body.statements.length) {
69909                 var firstStatement = constructor.body.statements[statementOffset];
69910                 if (ts.isExpressionStatement(firstStatement) && ts.isSuperCall(firstStatement.expression)) {
69911                     superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression);
69912                 }
69913             }
69914             if (superCallExpression) {
69915                 hierarchyFacts |= 8192;
69916                 statementOffset++;
69917             }
69918             ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset));
69919             ts.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
69920             insertCaptureNewTargetIfNeeded(prologue, constructor, false);
69921             if (isDerivedClass) {
69922                 if (superCallExpression && statementOffset === constructor.body.statements.length && !(constructor.body.transformFlags & 4096)) {
69923                     var superCall = ts.cast(ts.cast(superCallExpression, ts.isBinaryExpression).left, ts.isCallExpression);
69924                     var returnStatement = ts.createReturn(superCallExpression);
69925                     ts.setCommentRange(returnStatement, ts.getCommentRange(superCall));
69926                     ts.setEmitFlags(superCall, 1536);
69927                     statements.push(returnStatement);
69928                 }
69929                 else {
69930                     insertCaptureThisForNode(statements, constructor, superCallExpression || createActualThis());
69931                     if (!isSufficientlyCoveredByReturnStatements(constructor.body)) {
69932                         statements.push(ts.createReturn(ts.createFileLevelUniqueName("_this")));
69933                     }
69934                 }
69935             }
69936             else {
69937                 insertCaptureThisForNodeIfNeeded(prologue, constructor);
69938             }
69939             var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(ts.concatenate(prologue, statements)), constructor.body.statements), true);
69940             ts.setTextRange(block, constructor.body);
69941             return block;
69942         }
69943         function isSufficientlyCoveredByReturnStatements(statement) {
69944             if (statement.kind === 235) {
69945                 return true;
69946             }
69947             else if (statement.kind === 227) {
69948                 var ifStatement = statement;
69949                 if (ifStatement.elseStatement) {
69950                     return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) &&
69951                         isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement);
69952                 }
69953             }
69954             else if (statement.kind === 223) {
69955                 var lastStatement = ts.lastOrUndefined(statement.statements);
69956                 if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) {
69957                     return true;
69958                 }
69959             }
69960             return false;
69961         }
69962         function createActualThis() {
69963             return ts.setEmitFlags(ts.createThis(), 4);
69964         }
69965         function createDefaultSuperCallOrThis() {
69966             return ts.createLogicalOr(ts.createLogicalAnd(ts.createStrictInequality(ts.createFileLevelUniqueName("_super"), ts.createNull()), ts.createFunctionApply(ts.createFileLevelUniqueName("_super"), createActualThis(), ts.createIdentifier("arguments"))), createActualThis());
69967         }
69968         function visitParameter(node) {
69969             if (node.dotDotDotToken) {
69970                 return undefined;
69971             }
69972             else if (ts.isBindingPattern(node.name)) {
69973                 return ts.setOriginalNode(ts.setTextRange(ts.createParameter(undefined, undefined, undefined, ts.getGeneratedNameForNode(node), undefined, undefined, undefined), node), node);
69974             }
69975             else if (node.initializer) {
69976                 return ts.setOriginalNode(ts.setTextRange(ts.createParameter(undefined, undefined, undefined, node.name, undefined, undefined, undefined), node), node);
69977             }
69978             else {
69979                 return node;
69980             }
69981         }
69982         function hasDefaultValueOrBindingPattern(node) {
69983             return node.initializer !== undefined
69984                 || ts.isBindingPattern(node.name);
69985         }
69986         function addDefaultValueAssignmentsIfNeeded(statements, node) {
69987             if (!ts.some(node.parameters, hasDefaultValueOrBindingPattern)) {
69988                 return false;
69989             }
69990             var added = false;
69991             for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
69992                 var parameter = _a[_i];
69993                 var name = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken;
69994                 if (dotDotDotToken) {
69995                     continue;
69996                 }
69997                 if (ts.isBindingPattern(name)) {
69998                     added = insertDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) || added;
69999                 }
70000                 else if (initializer) {
70001                     insertDefaultValueAssignmentForInitializer(statements, parameter, name, initializer);
70002                     added = true;
70003                 }
70004             }
70005             return added;
70006         }
70007         function insertDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) {
70008             if (name.elements.length > 0) {
70009                 ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0, ts.getGeneratedNameForNode(parameter)))), 1048576));
70010                 return true;
70011             }
70012             else if (initializer) {
70013                 ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(ts.createExpressionStatement(ts.createAssignment(ts.getGeneratedNameForNode(parameter), ts.visitNode(initializer, visitor, ts.isExpression))), 1048576));
70014                 return true;
70015             }
70016             return false;
70017         }
70018         function insertDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) {
70019             initializer = ts.visitNode(initializer, visitor, ts.isExpression);
70020             var statement = ts.createIf(ts.createTypeCheck(ts.getSynthesizedClone(name), "undefined"), ts.setEmitFlags(ts.setTextRange(ts.createBlock([
70021                 ts.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48), ts.setEmitFlags(initializer, 48 | ts.getEmitFlags(initializer) | 1536)), parameter), 1536))
70022             ]), parameter), 1 | 32 | 384 | 1536));
70023             ts.startOnNewLine(statement);
70024             ts.setTextRange(statement, parameter);
70025             ts.setEmitFlags(statement, 384 | 32 | 1048576 | 1536);
70026             ts.insertStatementAfterCustomPrologue(statements, statement);
70027         }
70028         function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) {
70029             return !!(node && node.dotDotDotToken && !inConstructorWithSynthesizedSuper);
70030         }
70031         function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) {
70032             var prologueStatements = [];
70033             var parameter = ts.lastOrUndefined(node.parameters);
70034             if (!shouldAddRestParameter(parameter, inConstructorWithSynthesizedSuper)) {
70035                 return false;
70036             }
70037             var declarationName = parameter.name.kind === 75 ? ts.getMutableClone(parameter.name) : ts.createTempVariable(undefined);
70038             ts.setEmitFlags(declarationName, 48);
70039             var expressionName = parameter.name.kind === 75 ? ts.getSynthesizedClone(parameter.name) : declarationName;
70040             var restIndex = node.parameters.length - 1;
70041             var temp = ts.createLoopVariable();
70042             prologueStatements.push(ts.setEmitFlags(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
70043                 ts.createVariableDeclaration(declarationName, undefined, ts.createArrayLiteral([]))
70044             ])), parameter), 1048576));
70045             var forStatement = ts.createFor(ts.setTextRange(ts.createVariableDeclarationList([
70046                 ts.createVariableDeclaration(temp, undefined, ts.createLiteral(restIndex))
70047             ]), parameter), ts.setTextRange(ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length")), parameter), ts.setTextRange(ts.createPostfixIncrement(temp), parameter), ts.createBlock([
70048                 ts.startOnNewLine(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0
70049                     ? temp
70050                     : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp))), parameter))
70051             ]));
70052             ts.setEmitFlags(forStatement, 1048576);
70053             ts.startOnNewLine(forStatement);
70054             prologueStatements.push(forStatement);
70055             if (parameter.name.kind !== 75) {
70056                 prologueStatements.push(ts.setEmitFlags(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0, expressionName))), parameter), 1048576));
70057             }
70058             ts.insertStatementsAfterCustomPrologue(statements, prologueStatements);
70059             return true;
70060         }
70061         function insertCaptureThisForNodeIfNeeded(statements, node) {
70062             if (hierarchyFacts & 32768 && node.kind !== 202) {
70063                 insertCaptureThisForNode(statements, node, ts.createThis());
70064                 return true;
70065             }
70066             return false;
70067         }
70068         function insertCaptureThisForNode(statements, node, initializer) {
70069             enableSubstitutionsForCapturedThis();
70070             var captureThisStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
70071                 ts.createVariableDeclaration(ts.createFileLevelUniqueName("_this"), undefined, initializer)
70072             ]));
70073             ts.setEmitFlags(captureThisStatement, 1536 | 1048576);
70074             ts.setSourceMapRange(captureThisStatement, node);
70075             ts.insertStatementAfterCustomPrologue(statements, captureThisStatement);
70076         }
70077         function insertCaptureNewTargetIfNeeded(statements, node, copyOnWrite) {
70078             if (hierarchyFacts & 16384) {
70079                 var newTarget = void 0;
70080                 switch (node.kind) {
70081                     case 202:
70082                         return statements;
70083                     case 161:
70084                     case 163:
70085                     case 164:
70086                         newTarget = ts.createVoidZero();
70087                         break;
70088                     case 162:
70089                         newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor");
70090                         break;
70091                     case 244:
70092                     case 201:
70093                         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());
70094                         break;
70095                     default:
70096                         return ts.Debug.failBadSyntaxKind(node);
70097                 }
70098                 var captureNewTargetStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
70099                     ts.createVariableDeclaration(ts.createFileLevelUniqueName("_newTarget"), undefined, newTarget)
70100                 ]));
70101                 ts.setEmitFlags(captureNewTargetStatement, 1536 | 1048576);
70102                 if (copyOnWrite) {
70103                     statements = statements.slice();
70104                 }
70105                 ts.insertStatementAfterCustomPrologue(statements, captureNewTargetStatement);
70106             }
70107             return statements;
70108         }
70109         function addClassMembers(statements, node) {
70110             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
70111                 var member = _a[_i];
70112                 switch (member.kind) {
70113                     case 222:
70114                         statements.push(transformSemicolonClassElementToStatement(member));
70115                         break;
70116                     case 161:
70117                         statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node));
70118                         break;
70119                     case 163:
70120                     case 164:
70121                         var accessors = ts.getAllAccessorDeclarations(node.members, member);
70122                         if (member === accessors.firstAccessor) {
70123                             statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node));
70124                         }
70125                         break;
70126                     case 162:
70127                         break;
70128                     default:
70129                         ts.Debug.failBadSyntaxKind(member, currentSourceFile && currentSourceFile.fileName);
70130                         break;
70131                 }
70132             }
70133         }
70134         function transformSemicolonClassElementToStatement(member) {
70135             return ts.setTextRange(ts.createEmptyStatement(), member);
70136         }
70137         function transformClassMethodDeclarationToStatement(receiver, member, container) {
70138             var commentRange = ts.getCommentRange(member);
70139             var sourceMapRange = ts.getSourceMapRange(member);
70140             var memberFunction = transformFunctionLikeToExpression(member, member, undefined, container);
70141             var propertyName = ts.visitNode(member.name, visitor, ts.isPropertyName);
70142             var e;
70143             if (!ts.isPrivateIdentifier(propertyName) && context.getCompilerOptions().useDefineForClassFields) {
70144                 var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression
70145                     : ts.isIdentifier(propertyName) ? ts.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText))
70146                         : propertyName;
70147                 e = ts.createObjectDefinePropertyCall(receiver, name, ts.createPropertyDescriptor({ value: memberFunction, enumerable: false, writable: true, configurable: true }));
70148             }
70149             else {
70150                 var memberName = ts.createMemberAccessForPropertyName(receiver, propertyName, member.name);
70151                 e = ts.createAssignment(memberName, memberFunction);
70152             }
70153             ts.setEmitFlags(memberFunction, 1536);
70154             ts.setSourceMapRange(memberFunction, sourceMapRange);
70155             var statement = ts.setTextRange(ts.createExpressionStatement(e), member);
70156             ts.setOriginalNode(statement, member);
70157             ts.setCommentRange(statement, commentRange);
70158             ts.setEmitFlags(statement, 48);
70159             return statement;
70160         }
70161         function transformAccessorsToStatement(receiver, accessors, container) {
70162             var statement = ts.createExpressionStatement(transformAccessorsToExpression(receiver, accessors, container, false));
70163             ts.setEmitFlags(statement, 1536);
70164             ts.setSourceMapRange(statement, ts.getSourceMapRange(accessors.firstAccessor));
70165             return statement;
70166         }
70167         function transformAccessorsToExpression(receiver, _a, container, startsOnNewLine) {
70168             var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor;
70169             var target = ts.getMutableClone(receiver);
70170             ts.setEmitFlags(target, 1536 | 32);
70171             ts.setSourceMapRange(target, firstAccessor.name);
70172             var visitedAccessorName = ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName);
70173             if (ts.isPrivateIdentifier(visitedAccessorName)) {
70174                 return ts.Debug.failBadSyntaxKind(visitedAccessorName, "Encountered unhandled private identifier while transforming ES2015.");
70175             }
70176             var propertyName = ts.createExpressionForPropertyName(visitedAccessorName);
70177             ts.setEmitFlags(propertyName, 1536 | 16);
70178             ts.setSourceMapRange(propertyName, firstAccessor.name);
70179             var properties = [];
70180             if (getAccessor) {
70181                 var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined, container);
70182                 ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor));
70183                 ts.setEmitFlags(getterFunction, 512);
70184                 var getter = ts.createPropertyAssignment("get", getterFunction);
70185                 ts.setCommentRange(getter, ts.getCommentRange(getAccessor));
70186                 properties.push(getter);
70187             }
70188             if (setAccessor) {
70189                 var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined, container);
70190                 ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor));
70191                 ts.setEmitFlags(setterFunction, 512);
70192                 var setter = ts.createPropertyAssignment("set", setterFunction);
70193                 ts.setCommentRange(setter, ts.getCommentRange(setAccessor));
70194                 properties.push(setter);
70195             }
70196             properties.push(ts.createPropertyAssignment("enumerable", getAccessor || setAccessor ? ts.createFalse() : ts.createTrue()), ts.createPropertyAssignment("configurable", ts.createTrue()));
70197             var call = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [
70198                 target,
70199                 propertyName,
70200                 ts.createObjectLiteral(properties, true)
70201             ]);
70202             if (startsOnNewLine) {
70203                 ts.startOnNewLine(call);
70204             }
70205             return call;
70206         }
70207         function visitArrowFunction(node) {
70208             if (node.transformFlags & 4096) {
70209                 hierarchyFacts |= 32768;
70210             }
70211             var savedConvertedLoopState = convertedLoopState;
70212             convertedLoopState = undefined;
70213             var ancestorFacts = enterSubtree(15232, 66);
70214             var func = ts.createFunctionExpression(undefined, undefined, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node));
70215             ts.setTextRange(func, node);
70216             ts.setOriginalNode(func, node);
70217             ts.setEmitFlags(func, 8);
70218             if (hierarchyFacts & 32768) {
70219                 enableSubstitutionsForCapturedThis();
70220             }
70221             exitSubtree(ancestorFacts, 0, 0);
70222             convertedLoopState = savedConvertedLoopState;
70223             return func;
70224         }
70225         function visitFunctionExpression(node) {
70226             var ancestorFacts = ts.getEmitFlags(node) & 262144
70227                 ? enterSubtree(16278, 69)
70228                 : enterSubtree(16286, 65);
70229             var savedConvertedLoopState = convertedLoopState;
70230             convertedLoopState = undefined;
70231             var parameters = ts.visitParameterList(node.parameters, visitor, context);
70232             var body = transformFunctionBody(node);
70233             var name = hierarchyFacts & 16384
70234                 ? ts.getLocalName(node)
70235                 : node.name;
70236             exitSubtree(ancestorFacts, 49152, 0);
70237             convertedLoopState = savedConvertedLoopState;
70238             return ts.updateFunctionExpression(node, undefined, node.asteriskToken, name, undefined, parameters, undefined, body);
70239         }
70240         function visitFunctionDeclaration(node) {
70241             var savedConvertedLoopState = convertedLoopState;
70242             convertedLoopState = undefined;
70243             var ancestorFacts = enterSubtree(16286, 65);
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.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, name, undefined, parameters, undefined, body);
70252         }
70253         function transformFunctionLikeToExpression(node, location, name, container) {
70254             var savedConvertedLoopState = convertedLoopState;
70255             convertedLoopState = undefined;
70256             var ancestorFacts = container && ts.isClassLike(container) && !ts.hasModifier(node, 32)
70257                 ? enterSubtree(16286, 65 | 8)
70258                 : enterSubtree(16286, 65);
70259             var parameters = ts.visitParameterList(node.parameters, visitor, context);
70260             var body = transformFunctionBody(node);
70261             if (hierarchyFacts & 16384 && !name && (node.kind === 244 || node.kind === 201)) {
70262                 name = ts.getGeneratedNameForNode(node);
70263             }
70264             exitSubtree(ancestorFacts, 49152, 0);
70265             convertedLoopState = savedConvertedLoopState;
70266             return ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, parameters, undefined, body), location), node);
70267         }
70268         function transformFunctionBody(node) {
70269             var multiLine = false;
70270             var singleLine = false;
70271             var statementsLocation;
70272             var closeBraceLocation;
70273             var prologue = [];
70274             var statements = [];
70275             var body = node.body;
70276             var statementOffset;
70277             resumeLexicalEnvironment();
70278             if (ts.isBlock(body)) {
70279                 statementOffset = ts.addStandardPrologue(prologue, body.statements, false);
70280                 statementOffset = ts.addCustomPrologue(statements, body.statements, statementOffset, visitor, ts.isHoistedFunction);
70281                 statementOffset = ts.addCustomPrologue(statements, body.statements, statementOffset, visitor, ts.isHoistedVariableStatement);
70282             }
70283             multiLine = addDefaultValueAssignmentsIfNeeded(statements, node) || multiLine;
70284             multiLine = addRestParameterIfNeeded(statements, node, false) || multiLine;
70285             if (ts.isBlock(body)) {
70286                 statementOffset = ts.addCustomPrologue(statements, body.statements, statementOffset, visitor);
70287                 statementsLocation = body.statements;
70288                 ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, statementOffset));
70289                 if (!multiLine && body.multiLine) {
70290                     multiLine = true;
70291                 }
70292             }
70293             else {
70294                 ts.Debug.assert(node.kind === 202);
70295                 statementsLocation = ts.moveRangeEnd(body, -1);
70296                 var equalsGreaterThanToken = node.equalsGreaterThanToken;
70297                 if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) {
70298                     if (ts.rangeEndIsOnSameLineAsRangeStart(equalsGreaterThanToken, body, currentSourceFile)) {
70299                         singleLine = true;
70300                     }
70301                     else {
70302                         multiLine = true;
70303                     }
70304                 }
70305                 var expression = ts.visitNode(body, visitor, ts.isExpression);
70306                 var returnStatement = ts.createReturn(expression);
70307                 ts.setTextRange(returnStatement, body);
70308                 ts.moveSyntheticComments(returnStatement, body);
70309                 ts.setEmitFlags(returnStatement, 384 | 32 | 1024);
70310                 statements.push(returnStatement);
70311                 closeBraceLocation = body;
70312             }
70313             ts.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
70314             insertCaptureNewTargetIfNeeded(prologue, node, false);
70315             insertCaptureThisForNodeIfNeeded(prologue, node);
70316             if (ts.some(prologue)) {
70317                 multiLine = true;
70318             }
70319             statements.unshift.apply(statements, prologue);
70320             if (ts.isBlock(body) && ts.arrayIsEqualTo(statements, body.statements)) {
70321                 return body;
70322             }
70323             var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), multiLine);
70324             ts.setTextRange(block, node.body);
70325             if (!multiLine && singleLine) {
70326                 ts.setEmitFlags(block, 1);
70327             }
70328             if (closeBraceLocation) {
70329                 ts.setTokenSourceMapRange(block, 19, closeBraceLocation);
70330             }
70331             ts.setOriginalNode(block, node.body);
70332             return block;
70333         }
70334         function visitBlock(node, isFunctionBody) {
70335             if (isFunctionBody) {
70336                 return ts.visitEachChild(node, visitor, context);
70337             }
70338             var ancestorFacts = hierarchyFacts & 256
70339                 ? enterSubtree(7104, 512)
70340                 : enterSubtree(6976, 128);
70341             var updated = ts.visitEachChild(node, visitor, context);
70342             exitSubtree(ancestorFacts, 0, 0);
70343             return updated;
70344         }
70345         function visitExpressionStatement(node) {
70346             switch (node.expression.kind) {
70347                 case 200:
70348                     return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, false));
70349                 case 209:
70350                     return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, false));
70351             }
70352             return ts.visitEachChild(node, visitor, context);
70353         }
70354         function visitParenthesizedExpression(node, needsDestructuringValue) {
70355             if (!needsDestructuringValue) {
70356                 switch (node.expression.kind) {
70357                     case 200:
70358                         return ts.updateParen(node, visitParenthesizedExpression(node.expression, false));
70359                     case 209:
70360                         return ts.updateParen(node, visitBinaryExpression(node.expression, false));
70361                 }
70362             }
70363             return ts.visitEachChild(node, visitor, context);
70364         }
70365         function visitBinaryExpression(node, needsDestructuringValue) {
70366             if (ts.isDestructuringAssignment(node)) {
70367                 return ts.flattenDestructuringAssignment(node, visitor, context, 0, needsDestructuringValue);
70368             }
70369             return ts.visitEachChild(node, visitor, context);
70370         }
70371         function isVariableStatementOfTypeScriptClassWrapper(node) {
70372             return node.declarationList.declarations.length === 1
70373                 && !!node.declarationList.declarations[0].initializer
70374                 && !!(ts.getEmitFlags(node.declarationList.declarations[0].initializer) & 33554432);
70375         }
70376         function visitVariableStatement(node) {
70377             var ancestorFacts = enterSubtree(0, ts.hasModifier(node, 1) ? 32 : 0);
70378             var updated;
70379             if (convertedLoopState && (node.declarationList.flags & 3) === 0 && !isVariableStatementOfTypeScriptClassWrapper(node)) {
70380                 var assignments = void 0;
70381                 for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
70382                     var decl = _a[_i];
70383                     hoistVariableDeclarationDeclaredInConvertedLoop(convertedLoopState, decl);
70384                     if (decl.initializer) {
70385                         var assignment = void 0;
70386                         if (ts.isBindingPattern(decl.name)) {
70387                             assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0);
70388                         }
70389                         else {
70390                             assignment = ts.createBinary(decl.name, 62, ts.visitNode(decl.initializer, visitor, ts.isExpression));
70391                             ts.setTextRange(assignment, decl);
70392                         }
70393                         assignments = ts.append(assignments, assignment);
70394                     }
70395                 }
70396                 if (assignments) {
70397                     updated = ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(assignments)), node);
70398                 }
70399                 else {
70400                     updated = undefined;
70401                 }
70402             }
70403             else {
70404                 updated = ts.visitEachChild(node, visitor, context);
70405             }
70406             exitSubtree(ancestorFacts, 0, 0);
70407             return updated;
70408         }
70409         function visitVariableDeclarationList(node) {
70410             if (node.flags & 3 || node.transformFlags & 131072) {
70411                 if (node.flags & 3) {
70412                     enableSubstitutionsForBlockScopedBindings();
70413                 }
70414                 var declarations = ts.flatMap(node.declarations, node.flags & 1
70415                     ? visitVariableDeclarationInLetDeclarationList
70416                     : visitVariableDeclaration);
70417                 var declarationList = ts.createVariableDeclarationList(declarations);
70418                 ts.setOriginalNode(declarationList, node);
70419                 ts.setTextRange(declarationList, node);
70420                 ts.setCommentRange(declarationList, node);
70421                 if (node.transformFlags & 131072
70422                     && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) {
70423                     ts.setSourceMapRange(declarationList, getRangeUnion(declarations));
70424                 }
70425                 return declarationList;
70426             }
70427             return ts.visitEachChild(node, visitor, context);
70428         }
70429         function getRangeUnion(declarations) {
70430             var pos = -1, end = -1;
70431             for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) {
70432                 var node = declarations_10[_i];
70433                 pos = pos === -1 ? node.pos : node.pos === -1 ? pos : Math.min(pos, node.pos);
70434                 end = Math.max(end, node.end);
70435             }
70436             return ts.createRange(pos, end);
70437         }
70438         function shouldEmitExplicitInitializerForLetDeclaration(node) {
70439             var flags = resolver.getNodeCheckFlags(node);
70440             var isCapturedInFunction = flags & 262144;
70441             var isDeclaredInLoop = flags & 524288;
70442             var emittedAsTopLevel = (hierarchyFacts & 64) !== 0
70443                 || (isCapturedInFunction
70444                     && isDeclaredInLoop
70445                     && (hierarchyFacts & 512) !== 0);
70446             var emitExplicitInitializer = !emittedAsTopLevel
70447                 && (hierarchyFacts & 4096) === 0
70448                 && (!resolver.isDeclarationWithCollidingName(node)
70449                     || (isDeclaredInLoop
70450                         && !isCapturedInFunction
70451                         && (hierarchyFacts & (2048 | 4096)) === 0));
70452             return emitExplicitInitializer;
70453         }
70454         function visitVariableDeclarationInLetDeclarationList(node) {
70455             var name = node.name;
70456             if (ts.isBindingPattern(name)) {
70457                 return visitVariableDeclaration(node);
70458             }
70459             if (!node.initializer && shouldEmitExplicitInitializerForLetDeclaration(node)) {
70460                 var clone_3 = ts.getMutableClone(node);
70461                 clone_3.initializer = ts.createVoidZero();
70462                 return clone_3;
70463             }
70464             return ts.visitEachChild(node, visitor, context);
70465         }
70466         function visitVariableDeclaration(node) {
70467             var ancestorFacts = enterSubtree(32, 0);
70468             var updated;
70469             if (ts.isBindingPattern(node.name)) {
70470                 updated = ts.flattenDestructuringBinding(node, visitor, context, 0, undefined, (ancestorFacts & 32) !== 0);
70471             }
70472             else {
70473                 updated = ts.visitEachChild(node, visitor, context);
70474             }
70475             exitSubtree(ancestorFacts, 0, 0);
70476             return updated;
70477         }
70478         function recordLabel(node) {
70479             convertedLoopState.labels.set(ts.idText(node.label), true);
70480         }
70481         function resetLabel(node) {
70482             convertedLoopState.labels.set(ts.idText(node.label), false);
70483         }
70484         function visitLabeledStatement(node) {
70485             if (convertedLoopState && !convertedLoopState.labels) {
70486                 convertedLoopState.labels = ts.createMap();
70487             }
70488             var statement = ts.unwrapInnermostStatementOfLabel(node, convertedLoopState && recordLabel);
70489             return ts.isIterationStatement(statement, false)
70490                 ? visitIterationStatement(statement, node)
70491                 : ts.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement, ts.liftToBlock), node, convertedLoopState && resetLabel);
70492         }
70493         function visitIterationStatement(node, outermostLabeledStatement) {
70494             switch (node.kind) {
70495                 case 228:
70496                 case 229:
70497                     return visitDoOrWhileStatement(node, outermostLabeledStatement);
70498                 case 230:
70499                     return visitForStatement(node, outermostLabeledStatement);
70500                 case 231:
70501                     return visitForInStatement(node, outermostLabeledStatement);
70502                 case 232:
70503                     return visitForOfStatement(node, outermostLabeledStatement);
70504             }
70505         }
70506         function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) {
70507             var ancestorFacts = enterSubtree(excludeFacts, includeFacts);
70508             var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert);
70509             exitSubtree(ancestorFacts, 0, 0);
70510             return updated;
70511         }
70512         function visitDoOrWhileStatement(node, outermostLabeledStatement) {
70513             return visitIterationStatementWithFacts(0, 1280, node, outermostLabeledStatement);
70514         }
70515         function visitForStatement(node, outermostLabeledStatement) {
70516             return visitIterationStatementWithFacts(5056, 3328, node, outermostLabeledStatement);
70517         }
70518         function visitForInStatement(node, outermostLabeledStatement) {
70519             return visitIterationStatementWithFacts(3008, 5376, node, outermostLabeledStatement);
70520         }
70521         function visitForOfStatement(node, outermostLabeledStatement) {
70522             return visitIterationStatementWithFacts(3008, 5376, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray);
70523         }
70524         function convertForOfStatementHead(node, boundValue, convertedLoopBodyStatements) {
70525             var statements = [];
70526             var initializer = node.initializer;
70527             if (ts.isVariableDeclarationList(initializer)) {
70528                 if (node.initializer.flags & 3) {
70529                     enableSubstitutionsForBlockScopedBindings();
70530                 }
70531                 var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations);
70532                 if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) {
70533                     var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0, boundValue);
70534                     var declarationList = ts.setTextRange(ts.createVariableDeclarationList(declarations), node.initializer);
70535                     ts.setOriginalNode(declarationList, node.initializer);
70536                     ts.setSourceMapRange(declarationList, ts.createRange(declarations[0].pos, ts.last(declarations).end));
70537                     statements.push(ts.createVariableStatement(undefined, declarationList));
70538                 }
70539                 else {
70540                     statements.push(ts.setTextRange(ts.createVariableStatement(undefined, ts.setOriginalNode(ts.setTextRange(ts.createVariableDeclarationList([
70541                         ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(undefined), undefined, boundValue)
70542                     ]), ts.moveRangePos(initializer, -1)), initializer)), ts.moveRangeEnd(initializer, -1)));
70543                 }
70544             }
70545             else {
70546                 var assignment = ts.createAssignment(initializer, boundValue);
70547                 if (ts.isDestructuringAssignment(assignment)) {
70548                     ts.aggregateTransformFlags(assignment);
70549                     statements.push(ts.createExpressionStatement(visitBinaryExpression(assignment, false)));
70550                 }
70551                 else {
70552                     assignment.end = initializer.end;
70553                     statements.push(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(initializer, -1)));
70554                 }
70555             }
70556             if (convertedLoopBodyStatements) {
70557                 return createSyntheticBlockForConvertedStatements(ts.addRange(statements, convertedLoopBodyStatements));
70558             }
70559             else {
70560                 var statement = ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock);
70561                 if (ts.isBlock(statement)) {
70562                     return ts.updateBlock(statement, ts.setTextRange(ts.createNodeArray(ts.concatenate(statements, statement.statements)), statement.statements));
70563                 }
70564                 else {
70565                     statements.push(statement);
70566                     return createSyntheticBlockForConvertedStatements(statements);
70567                 }
70568             }
70569         }
70570         function createSyntheticBlockForConvertedStatements(statements) {
70571             return ts.setEmitFlags(ts.createBlock(ts.createNodeArray(statements), true), 48 | 384);
70572         }
70573         function convertForOfStatementForArray(node, outermostLabeledStatement, convertedLoopBodyStatements) {
70574             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
70575             var counter = ts.createLoopVariable();
70576             var rhsReference = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(expression) : ts.createTempVariable(undefined);
70577             ts.setEmitFlags(expression, 48 | ts.getEmitFlags(expression));
70578             var forStatement = ts.setTextRange(ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([
70579                 ts.setTextRange(ts.createVariableDeclaration(counter, undefined, ts.createLiteral(0)), ts.moveRangePos(node.expression, -1)),
70580                 ts.setTextRange(ts.createVariableDeclaration(rhsReference, undefined, expression), node.expression)
70581             ]), 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);
70582             ts.setEmitFlags(forStatement, 256);
70583             ts.setTextRange(forStatement, node);
70584             return ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel);
70585         }
70586         function convertForOfStatementForIterable(node, outermostLabeledStatement, convertedLoopBodyStatements, ancestorFacts) {
70587             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
70588             var iterator = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(expression) : ts.createTempVariable(undefined);
70589             var result = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(iterator) : ts.createTempVariable(undefined);
70590             var errorRecord = ts.createUniqueName("e");
70591             var catchVariable = ts.getGeneratedNameForNode(errorRecord);
70592             var returnMethod = ts.createTempVariable(undefined);
70593             var values = ts.createValuesHelper(context, expression, node.expression);
70594             var next = ts.createCall(ts.createPropertyAccess(iterator, "next"), undefined, []);
70595             hoistVariableDeclaration(errorRecord);
70596             hoistVariableDeclaration(returnMethod);
70597             var initializer = ancestorFacts & 1024
70598                 ? ts.inlineExpressions([ts.createAssignment(errorRecord, ts.createVoidZero()), values])
70599                 : values;
70600             var forStatement = ts.setEmitFlags(ts.setTextRange(ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([
70601                 ts.setTextRange(ts.createVariableDeclaration(iterator, undefined, initializer), node.expression),
70602                 ts.createVariableDeclaration(result, undefined, next)
70603             ]), node.expression), 2097152), ts.createLogicalNot(ts.createPropertyAccess(result, "done")), ts.createAssignment(result, next), convertForOfStatementHead(node, ts.createPropertyAccess(result, "value"), convertedLoopBodyStatements)), node), 256);
70604             return ts.createTry(ts.createBlock([
70605                 ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel)
70606             ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([
70607                 ts.createExpressionStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([
70608                     ts.createPropertyAssignment("error", catchVariable)
70609                 ])))
70610             ]), 1)), ts.createBlock([
70611                 ts.createTry(ts.createBlock([
70612                     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),
70613                 ]), undefined, ts.setEmitFlags(ts.createBlock([
70614                     ts.setEmitFlags(ts.createIf(errorRecord, ts.createThrow(ts.createPropertyAccess(errorRecord, "error"))), 1)
70615                 ]), 1))
70616             ]));
70617         }
70618         function visitObjectLiteralExpression(node) {
70619             var properties = node.properties;
70620             var numProperties = properties.length;
70621             var numInitialProperties = numProperties;
70622             var numInitialPropertiesWithoutYield = numProperties;
70623             for (var i = 0; i < numProperties; i++) {
70624                 var property = properties[i];
70625                 if ((property.transformFlags & 262144 && hierarchyFacts & 4)
70626                     && i < numInitialPropertiesWithoutYield) {
70627                     numInitialPropertiesWithoutYield = i;
70628                 }
70629                 if (property.name.kind === 154) {
70630                     numInitialProperties = i;
70631                     break;
70632                 }
70633             }
70634             if (numInitialProperties !== numProperties) {
70635                 if (numInitialPropertiesWithoutYield < numInitialProperties) {
70636                     numInitialProperties = numInitialPropertiesWithoutYield;
70637                 }
70638                 var temp = ts.createTempVariable(hoistVariableDeclaration);
70639                 var expressions = [];
70640                 var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), 65536));
70641                 if (node.multiLine) {
70642                     ts.startOnNewLine(assignment);
70643                 }
70644                 expressions.push(assignment);
70645                 addObjectLiteralMembers(expressions, node, temp, numInitialProperties);
70646                 expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp);
70647                 return ts.inlineExpressions(expressions);
70648             }
70649             return ts.visitEachChild(node, visitor, context);
70650         }
70651         function shouldConvertPartOfIterationStatement(node) {
70652             return (resolver.getNodeCheckFlags(node) & 131072) !== 0;
70653         }
70654         function shouldConvertInitializerOfForStatement(node) {
70655             return ts.isForStatement(node) && !!node.initializer && shouldConvertPartOfIterationStatement(node.initializer);
70656         }
70657         function shouldConvertConditionOfForStatement(node) {
70658             return ts.isForStatement(node) && !!node.condition && shouldConvertPartOfIterationStatement(node.condition);
70659         }
70660         function shouldConvertIncrementorOfForStatement(node) {
70661             return ts.isForStatement(node) && !!node.incrementor && shouldConvertPartOfIterationStatement(node.incrementor);
70662         }
70663         function shouldConvertIterationStatement(node) {
70664             return shouldConvertBodyOfIterationStatement(node)
70665                 || shouldConvertInitializerOfForStatement(node);
70666         }
70667         function shouldConvertBodyOfIterationStatement(node) {
70668             return (resolver.getNodeCheckFlags(node) & 65536) !== 0;
70669         }
70670         function hoistVariableDeclarationDeclaredInConvertedLoop(state, node) {
70671             if (!state.hoistedLocalVariables) {
70672                 state.hoistedLocalVariables = [];
70673             }
70674             visit(node.name);
70675             function visit(node) {
70676                 if (node.kind === 75) {
70677                     state.hoistedLocalVariables.push(node);
70678                 }
70679                 else {
70680                     for (var _i = 0, _a = node.elements; _i < _a.length; _i++) {
70681                         var element = _a[_i];
70682                         if (!ts.isOmittedExpression(element)) {
70683                             visit(element.name);
70684                         }
70685                     }
70686                 }
70687             }
70688         }
70689         function convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert) {
70690             if (!shouldConvertIterationStatement(node)) {
70691                 var saveAllowedNonLabeledJumps = void 0;
70692                 if (convertedLoopState) {
70693                     saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps;
70694                     convertedLoopState.allowedNonLabeledJumps = 2 | 4;
70695                 }
70696                 var result = convert
70697                     ? convert(node, outermostLabeledStatement, undefined, ancestorFacts)
70698                     : ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement, convertedLoopState && resetLabel);
70699                 if (convertedLoopState) {
70700                     convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps;
70701                 }
70702                 return result;
70703             }
70704             var currentState = createConvertedLoopState(node);
70705             var statements = [];
70706             var outerConvertedLoopState = convertedLoopState;
70707             convertedLoopState = currentState;
70708             var initializerFunction = shouldConvertInitializerOfForStatement(node) ? createFunctionForInitializerOfForStatement(node, currentState) : undefined;
70709             var bodyFunction = shouldConvertBodyOfIterationStatement(node) ? createFunctionForBodyOfIterationStatement(node, currentState, outerConvertedLoopState) : undefined;
70710             convertedLoopState = outerConvertedLoopState;
70711             if (initializerFunction)
70712                 statements.push(initializerFunction.functionDeclaration);
70713             if (bodyFunction)
70714                 statements.push(bodyFunction.functionDeclaration);
70715             addExtraDeclarationsForConvertedLoop(statements, currentState, outerConvertedLoopState);
70716             if (initializerFunction) {
70717                 statements.push(generateCallToConvertedLoopInitializer(initializerFunction.functionName, initializerFunction.containsYield));
70718             }
70719             var loop;
70720             if (bodyFunction) {
70721                 if (convert) {
70722                     loop = convert(node, outermostLabeledStatement, bodyFunction.part, ancestorFacts);
70723                 }
70724                 else {
70725                     var clone_4 = convertIterationStatementCore(node, initializerFunction, ts.createBlock(bodyFunction.part, true));
70726                     ts.aggregateTransformFlags(clone_4);
70727                     loop = ts.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel);
70728                 }
70729             }
70730             else {
70731                 var clone_5 = convertIterationStatementCore(node, initializerFunction, ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock));
70732                 ts.aggregateTransformFlags(clone_5);
70733                 loop = ts.restoreEnclosingLabel(clone_5, outermostLabeledStatement, convertedLoopState && resetLabel);
70734             }
70735             statements.push(loop);
70736             return statements;
70737         }
70738         function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) {
70739             switch (node.kind) {
70740                 case 230: return convertForStatement(node, initializerFunction, convertedLoopBody);
70741                 case 231: return convertForInStatement(node, convertedLoopBody);
70742                 case 232: return convertForOfStatement(node, convertedLoopBody);
70743                 case 228: return convertDoStatement(node, convertedLoopBody);
70744                 case 229: return convertWhileStatement(node, convertedLoopBody);
70745                 default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected");
70746             }
70747         }
70748         function convertForStatement(node, initializerFunction, convertedLoopBody) {
70749             var shouldConvertCondition = node.condition && shouldConvertPartOfIterationStatement(node.condition);
70750             var shouldConvertIncrementor = shouldConvertCondition || node.incrementor && shouldConvertPartOfIterationStatement(node.incrementor);
70751             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);
70752         }
70753         function convertForOfStatement(node, convertedLoopBody) {
70754             return ts.updateForOf(node, undefined, ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), convertedLoopBody);
70755         }
70756         function convertForInStatement(node, convertedLoopBody) {
70757             return ts.updateForIn(node, ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), convertedLoopBody);
70758         }
70759         function convertDoStatement(node, convertedLoopBody) {
70760             return ts.updateDo(node, convertedLoopBody, ts.visitNode(node.expression, visitor, ts.isExpression));
70761         }
70762         function convertWhileStatement(node, convertedLoopBody) {
70763             return ts.updateWhile(node, ts.visitNode(node.expression, visitor, ts.isExpression), convertedLoopBody);
70764         }
70765         function createConvertedLoopState(node) {
70766             var loopInitializer;
70767             switch (node.kind) {
70768                 case 230:
70769                 case 231:
70770                 case 232:
70771                     var initializer = node.initializer;
70772                     if (initializer && initializer.kind === 243) {
70773                         loopInitializer = initializer;
70774                     }
70775                     break;
70776             }
70777             var loopParameters = [];
70778             var loopOutParameters = [];
70779             if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3)) {
70780                 var hasCapturedBindingsInForInitializer = shouldConvertInitializerOfForStatement(node);
70781                 for (var _i = 0, _a = loopInitializer.declarations; _i < _a.length; _i++) {
70782                     var decl = _a[_i];
70783                     processLoopVariableDeclaration(node, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer);
70784                 }
70785             }
70786             var currentState = { loopParameters: loopParameters, loopOutParameters: loopOutParameters };
70787             if (convertedLoopState) {
70788                 if (convertedLoopState.argumentsName) {
70789                     currentState.argumentsName = convertedLoopState.argumentsName;
70790                 }
70791                 if (convertedLoopState.thisName) {
70792                     currentState.thisName = convertedLoopState.thisName;
70793                 }
70794                 if (convertedLoopState.hoistedLocalVariables) {
70795                     currentState.hoistedLocalVariables = convertedLoopState.hoistedLocalVariables;
70796                 }
70797             }
70798             return currentState;
70799         }
70800         function addExtraDeclarationsForConvertedLoop(statements, state, outerState) {
70801             var extraVariableDeclarations;
70802             if (state.argumentsName) {
70803                 if (outerState) {
70804                     outerState.argumentsName = state.argumentsName;
70805                 }
70806                 else {
70807                     (extraVariableDeclarations || (extraVariableDeclarations = [])).push(ts.createVariableDeclaration(state.argumentsName, undefined, ts.createIdentifier("arguments")));
70808                 }
70809             }
70810             if (state.thisName) {
70811                 if (outerState) {
70812                     outerState.thisName = state.thisName;
70813                 }
70814                 else {
70815                     (extraVariableDeclarations || (extraVariableDeclarations = [])).push(ts.createVariableDeclaration(state.thisName, undefined, ts.createIdentifier("this")));
70816                 }
70817             }
70818             if (state.hoistedLocalVariables) {
70819                 if (outerState) {
70820                     outerState.hoistedLocalVariables = state.hoistedLocalVariables;
70821                 }
70822                 else {
70823                     if (!extraVariableDeclarations) {
70824                         extraVariableDeclarations = [];
70825                     }
70826                     for (var _i = 0, _a = state.hoistedLocalVariables; _i < _a.length; _i++) {
70827                         var identifier = _a[_i];
70828                         extraVariableDeclarations.push(ts.createVariableDeclaration(identifier));
70829                     }
70830                 }
70831             }
70832             if (state.loopOutParameters.length) {
70833                 if (!extraVariableDeclarations) {
70834                     extraVariableDeclarations = [];
70835                 }
70836                 for (var _b = 0, _c = state.loopOutParameters; _b < _c.length; _b++) {
70837                     var outParam = _c[_b];
70838                     extraVariableDeclarations.push(ts.createVariableDeclaration(outParam.outParamName));
70839                 }
70840             }
70841             if (state.conditionVariable) {
70842                 if (!extraVariableDeclarations) {
70843                     extraVariableDeclarations = [];
70844                 }
70845                 extraVariableDeclarations.push(ts.createVariableDeclaration(state.conditionVariable, undefined, ts.createFalse()));
70846             }
70847             if (extraVariableDeclarations) {
70848                 statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(extraVariableDeclarations)));
70849             }
70850         }
70851         function createOutVariable(p) {
70852             return ts.createVariableDeclaration(p.originalName, undefined, p.outParamName);
70853         }
70854         function createFunctionForInitializerOfForStatement(node, currentState) {
70855             var functionName = ts.createUniqueName("_loop_init");
70856             var containsYield = (node.initializer.transformFlags & 262144) !== 0;
70857             var emitFlags = 0;
70858             if (currentState.containsLexicalThis)
70859                 emitFlags |= 8;
70860             if (containsYield && hierarchyFacts & 4)
70861                 emitFlags |= 262144;
70862             var statements = [];
70863             statements.push(ts.createVariableStatement(undefined, node.initializer));
70864             copyOutParameters(currentState.loopOutParameters, 2, 1, statements);
70865             var functionDeclaration = ts.createVariableStatement(undefined, ts.setEmitFlags(ts.createVariableDeclarationList([
70866                 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))
70867             ]), 2097152));
70868             var part = ts.createVariableDeclarationList(ts.map(currentState.loopOutParameters, createOutVariable));
70869             return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part };
70870         }
70871         function createFunctionForBodyOfIterationStatement(node, currentState, outerState) {
70872             var functionName = ts.createUniqueName("_loop");
70873             startLexicalEnvironment();
70874             var statement = ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock);
70875             var lexicalEnvironment = endLexicalEnvironment();
70876             var statements = [];
70877             if (shouldConvertConditionOfForStatement(node) || shouldConvertIncrementorOfForStatement(node)) {
70878                 currentState.conditionVariable = ts.createUniqueName("inc");
70879                 statements.push(ts.createIf(currentState.conditionVariable, ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), ts.createStatement(ts.createAssignment(currentState.conditionVariable, ts.createTrue()))));
70880                 if (shouldConvertConditionOfForStatement(node)) {
70881                     statements.push(ts.createIf(ts.createPrefix(53, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement)));
70882                 }
70883             }
70884             if (ts.isBlock(statement)) {
70885                 ts.addRange(statements, statement.statements);
70886             }
70887             else {
70888                 statements.push(statement);
70889             }
70890             copyOutParameters(currentState.loopOutParameters, 1, 1, statements);
70891             ts.insertStatementsAfterStandardPrologue(statements, lexicalEnvironment);
70892             var loopBody = ts.createBlock(statements, true);
70893             if (ts.isBlock(statement))
70894                 ts.setOriginalNode(loopBody, statement);
70895             var containsYield = (node.statement.transformFlags & 262144) !== 0;
70896             var emitFlags = 0;
70897             if (currentState.containsLexicalThis)
70898                 emitFlags |= 8;
70899             if (containsYield && (hierarchyFacts & 4) !== 0)
70900                 emitFlags |= 262144;
70901             var functionDeclaration = ts.createVariableStatement(undefined, ts.setEmitFlags(ts.createVariableDeclarationList([
70902                 ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(undefined, containsYield ? ts.createToken(41) : undefined, undefined, undefined, currentState.loopParameters, undefined, loopBody), emitFlags))
70903             ]), 2097152));
70904             var part = generateCallToConvertedLoop(functionName, currentState, outerState, containsYield);
70905             return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part };
70906         }
70907         function copyOutParameter(outParam, copyDirection) {
70908             var source = copyDirection === 0 ? outParam.outParamName : outParam.originalName;
70909             var target = copyDirection === 0 ? outParam.originalName : outParam.outParamName;
70910             return ts.createBinary(target, 62, source);
70911         }
70912         function copyOutParameters(outParams, partFlags, copyDirection, statements) {
70913             for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) {
70914                 var outParam = outParams_1[_i];
70915                 if (outParam.flags & partFlags) {
70916                     statements.push(ts.createExpressionStatement(copyOutParameter(outParam, copyDirection)));
70917                 }
70918             }
70919         }
70920         function generateCallToConvertedLoopInitializer(initFunctionExpressionName, containsYield) {
70921             var call = ts.createCall(initFunctionExpressionName, undefined, []);
70922             var callResult = containsYield
70923                 ? ts.createYield(ts.createToken(41), ts.setEmitFlags(call, 8388608))
70924                 : call;
70925             return ts.createStatement(callResult);
70926         }
70927         function generateCallToConvertedLoop(loopFunctionExpressionName, state, outerState, containsYield) {
70928             var statements = [];
70929             var isSimpleLoop = !(state.nonLocalJumps & ~4) &&
70930                 !state.labeledNonLocalBreaks &&
70931                 !state.labeledNonLocalContinues;
70932             var call = ts.createCall(loopFunctionExpressionName, undefined, ts.map(state.loopParameters, function (p) { return p.name; }));
70933             var callResult = containsYield
70934                 ? ts.createYield(ts.createToken(41), ts.setEmitFlags(call, 8388608))
70935                 : call;
70936             if (isSimpleLoop) {
70937                 statements.push(ts.createExpressionStatement(callResult));
70938                 copyOutParameters(state.loopOutParameters, 1, 0, statements);
70939             }
70940             else {
70941                 var loopResultName = ts.createUniqueName("state");
70942                 var stateVariable = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ts.createVariableDeclaration(loopResultName, undefined, callResult)]));
70943                 statements.push(stateVariable);
70944                 copyOutParameters(state.loopOutParameters, 1, 0, statements);
70945                 if (state.nonLocalJumps & 8) {
70946                     var returnStatement = void 0;
70947                     if (outerState) {
70948                         outerState.nonLocalJumps |= 8;
70949                         returnStatement = ts.createReturn(loopResultName);
70950                     }
70951                     else {
70952                         returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value"));
70953                     }
70954                     statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 36, ts.createLiteral("object")), returnStatement));
70955                 }
70956                 if (state.nonLocalJumps & 2) {
70957                     statements.push(ts.createIf(ts.createBinary(loopResultName, 36, ts.createLiteral("break")), ts.createBreak()));
70958                 }
70959                 if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) {
70960                     var caseClauses = [];
70961                     processLabeledJumps(state.labeledNonLocalBreaks, true, loopResultName, outerState, caseClauses);
70962                     processLabeledJumps(state.labeledNonLocalContinues, false, loopResultName, outerState, caseClauses);
70963                     statements.push(ts.createSwitch(loopResultName, ts.createCaseBlock(caseClauses)));
70964                 }
70965             }
70966             return statements;
70967         }
70968         function setLabeledJump(state, isBreak, labelText, labelMarker) {
70969             if (isBreak) {
70970                 if (!state.labeledNonLocalBreaks) {
70971                     state.labeledNonLocalBreaks = ts.createMap();
70972                 }
70973                 state.labeledNonLocalBreaks.set(labelText, labelMarker);
70974             }
70975             else {
70976                 if (!state.labeledNonLocalContinues) {
70977                     state.labeledNonLocalContinues = ts.createMap();
70978                 }
70979                 state.labeledNonLocalContinues.set(labelText, labelMarker);
70980             }
70981         }
70982         function processLabeledJumps(table, isBreak, loopResultName, outerLoop, caseClauses) {
70983             if (!table) {
70984                 return;
70985             }
70986             table.forEach(function (labelMarker, labelText) {
70987                 var statements = [];
70988                 if (!outerLoop || (outerLoop.labels && outerLoop.labels.get(labelText))) {
70989                     var label = ts.createIdentifier(labelText);
70990                     statements.push(isBreak ? ts.createBreak(label) : ts.createContinue(label));
70991                 }
70992                 else {
70993                     setLabeledJump(outerLoop, isBreak, labelText, labelMarker);
70994                     statements.push(ts.createReturn(loopResultName));
70995                 }
70996                 caseClauses.push(ts.createCaseClause(ts.createLiteral(labelMarker), statements));
70997             });
70998         }
70999         function processLoopVariableDeclaration(container, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer) {
71000             var name = decl.name;
71001             if (ts.isBindingPattern(name)) {
71002                 for (var _i = 0, _a = name.elements; _i < _a.length; _i++) {
71003                     var element = _a[_i];
71004                     if (!ts.isOmittedExpression(element)) {
71005                         processLoopVariableDeclaration(container, element, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer);
71006                     }
71007                 }
71008             }
71009             else {
71010                 loopParameters.push(ts.createParameter(undefined, undefined, undefined, name));
71011                 var checkFlags = resolver.getNodeCheckFlags(decl);
71012                 if (checkFlags & 4194304 || hasCapturedBindingsInForInitializer) {
71013                     var outParamName = ts.createUniqueName("out_" + ts.idText(name));
71014                     var flags = 0;
71015                     if (checkFlags & 4194304) {
71016                         flags |= 1;
71017                     }
71018                     if (ts.isForStatement(container) && container.initializer && resolver.isBindingCapturedByNode(container.initializer, decl)) {
71019                         flags |= 2;
71020                     }
71021                     loopOutParameters.push({ flags: flags, originalName: name, outParamName: outParamName });
71022                 }
71023             }
71024         }
71025         function addObjectLiteralMembers(expressions, node, receiver, start) {
71026             var properties = node.properties;
71027             var numProperties = properties.length;
71028             for (var i = start; i < numProperties; i++) {
71029                 var property = properties[i];
71030                 switch (property.kind) {
71031                     case 163:
71032                     case 164:
71033                         var accessors = ts.getAllAccessorDeclarations(node.properties, property);
71034                         if (property === accessors.firstAccessor) {
71035                             expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine));
71036                         }
71037                         break;
71038                     case 161:
71039                         expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine));
71040                         break;
71041                     case 281:
71042                         expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine));
71043                         break;
71044                     case 282:
71045                         expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine));
71046                         break;
71047                     default:
71048                         ts.Debug.failBadSyntaxKind(node);
71049                         break;
71050                 }
71051             }
71052         }
71053         function transformPropertyAssignmentToExpression(property, receiver, startsOnNewLine) {
71054             var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression));
71055             ts.setTextRange(expression, property);
71056             if (startsOnNewLine) {
71057                 ts.startOnNewLine(expression);
71058             }
71059             return expression;
71060         }
71061         function transformShorthandPropertyAssignmentToExpression(property, receiver, startsOnNewLine) {
71062             var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name));
71063             ts.setTextRange(expression, property);
71064             if (startsOnNewLine) {
71065                 ts.startOnNewLine(expression);
71066             }
71067             return expression;
71068         }
71069         function transformObjectLiteralMethodDeclarationToExpression(method, receiver, container, startsOnNewLine) {
71070             var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined, container));
71071             ts.setTextRange(expression, method);
71072             if (startsOnNewLine) {
71073                 ts.startOnNewLine(expression);
71074             }
71075             return expression;
71076         }
71077         function visitCatchClause(node) {
71078             var ancestorFacts = enterSubtree(7104, 0);
71079             var updated;
71080             ts.Debug.assert(!!node.variableDeclaration, "Catch clause variable should always be present when downleveling ES2015.");
71081             if (ts.isBindingPattern(node.variableDeclaration.name)) {
71082                 var temp = ts.createTempVariable(undefined);
71083                 var newVariableDeclaration = ts.createVariableDeclaration(temp);
71084                 ts.setTextRange(newVariableDeclaration, node.variableDeclaration);
71085                 var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0, temp);
71086                 var list = ts.createVariableDeclarationList(vars);
71087                 ts.setTextRange(list, node.variableDeclaration);
71088                 var destructure = ts.createVariableStatement(undefined, list);
71089                 updated = ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure));
71090             }
71091             else {
71092                 updated = ts.visitEachChild(node, visitor, context);
71093             }
71094             exitSubtree(ancestorFacts, 0, 0);
71095             return updated;
71096         }
71097         function addStatementToStartOfBlock(block, statement) {
71098             var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement);
71099             return ts.updateBlock(block, __spreadArrays([statement], transformedStatements));
71100         }
71101         function visitMethodDeclaration(node) {
71102             ts.Debug.assert(!ts.isComputedPropertyName(node.name));
71103             var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined, undefined);
71104             ts.setEmitFlags(functionExpression, 512 | ts.getEmitFlags(functionExpression));
71105             return ts.setTextRange(ts.createPropertyAssignment(node.name, functionExpression), node);
71106         }
71107         function visitAccessorDeclaration(node) {
71108             ts.Debug.assert(!ts.isComputedPropertyName(node.name));
71109             var savedConvertedLoopState = convertedLoopState;
71110             convertedLoopState = undefined;
71111             var ancestorFacts = enterSubtree(16286, 65);
71112             var updated;
71113             var parameters = ts.visitParameterList(node.parameters, visitor, context);
71114             var body = transformFunctionBody(node);
71115             if (node.kind === 163) {
71116                 updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body);
71117             }
71118             else {
71119                 updated = ts.updateSetAccessor(node, node.decorators, node.modifiers, node.name, parameters, body);
71120             }
71121             exitSubtree(ancestorFacts, 49152, 0);
71122             convertedLoopState = savedConvertedLoopState;
71123             return updated;
71124         }
71125         function visitShorthandPropertyAssignment(node) {
71126             return ts.setTextRange(ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name)), node);
71127         }
71128         function visitComputedPropertyName(node) {
71129             return ts.visitEachChild(node, visitor, context);
71130         }
71131         function visitYieldExpression(node) {
71132             return ts.visitEachChild(node, visitor, context);
71133         }
71134         function visitArrayLiteralExpression(node) {
71135             if (ts.some(node.elements, ts.isSpreadElement)) {
71136                 return transformAndSpreadElements(node.elements, true, !!node.multiLine, !!node.elements.hasTrailingComma);
71137             }
71138             return ts.visitEachChild(node, visitor, context);
71139         }
71140         function visitCallExpression(node) {
71141             if (ts.getEmitFlags(node) & 33554432) {
71142                 return visitTypeScriptClassWrapper(node);
71143             }
71144             var expression = ts.skipOuterExpressions(node.expression);
71145             if (expression.kind === 102 ||
71146                 ts.isSuperProperty(expression) ||
71147                 ts.some(node.arguments, ts.isSpreadElement)) {
71148                 return visitCallExpressionWithPotentialCapturedThisAssignment(node, true);
71149             }
71150             return ts.updateCall(node, ts.visitNode(node.expression, callExpressionVisitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression));
71151         }
71152         function visitTypeScriptClassWrapper(node) {
71153             var body = ts.cast(ts.cast(ts.skipOuterExpressions(node.expression), ts.isArrowFunction).body, ts.isBlock);
71154             var isVariableStatementWithInitializer = function (stmt) { return ts.isVariableStatement(stmt) && !!ts.first(stmt.declarationList.declarations).initializer; };
71155             var savedConvertedLoopState = convertedLoopState;
71156             convertedLoopState = undefined;
71157             var bodyStatements = ts.visitNodes(body.statements, visitor, ts.isStatement);
71158             convertedLoopState = savedConvertedLoopState;
71159             var classStatements = ts.filter(bodyStatements, isVariableStatementWithInitializer);
71160             var remainingStatements = ts.filter(bodyStatements, function (stmt) { return !isVariableStatementWithInitializer(stmt); });
71161             var varStatement = ts.cast(ts.first(classStatements), ts.isVariableStatement);
71162             var variable = varStatement.declarationList.declarations[0];
71163             var initializer = ts.skipOuterExpressions(variable.initializer);
71164             var aliasAssignment = ts.tryCast(initializer, ts.isAssignmentExpression);
71165             var call = ts.cast(aliasAssignment ? ts.skipOuterExpressions(aliasAssignment.right) : initializer, ts.isCallExpression);
71166             var func = ts.cast(ts.skipOuterExpressions(call.expression), ts.isFunctionExpression);
71167             var funcStatements = func.body.statements;
71168             var classBodyStart = 0;
71169             var classBodyEnd = -1;
71170             var statements = [];
71171             if (aliasAssignment) {
71172                 var extendsCall = ts.tryCast(funcStatements[classBodyStart], ts.isExpressionStatement);
71173                 if (extendsCall) {
71174                     statements.push(extendsCall);
71175                     classBodyStart++;
71176                 }
71177                 statements.push(funcStatements[classBodyStart]);
71178                 classBodyStart++;
71179                 statements.push(ts.createExpressionStatement(ts.createAssignment(aliasAssignment.left, ts.cast(variable.name, ts.isIdentifier))));
71180             }
71181             while (!ts.isReturnStatement(ts.elementAt(funcStatements, classBodyEnd))) {
71182                 classBodyEnd--;
71183             }
71184             ts.addRange(statements, funcStatements, classBodyStart, classBodyEnd);
71185             if (classBodyEnd < -1) {
71186                 ts.addRange(statements, funcStatements, classBodyEnd + 1);
71187             }
71188             ts.addRange(statements, remainingStatements);
71189             ts.addRange(statements, classStatements, 1);
71190             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))));
71191         }
71192         function visitImmediateSuperCallInBody(node) {
71193             return visitCallExpressionWithPotentialCapturedThisAssignment(node, false);
71194         }
71195         function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) {
71196             if (node.transformFlags & 8192 ||
71197                 node.expression.kind === 102 ||
71198                 ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) {
71199                 var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg;
71200                 if (node.expression.kind === 102) {
71201                     ts.setEmitFlags(thisArg, 4);
71202                 }
71203                 var resultingCall = void 0;
71204                 if (node.transformFlags & 8192) {
71205                     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));
71206                 }
71207                 else {
71208                     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);
71209                 }
71210                 if (node.expression.kind === 102) {
71211                     var initializer = ts.createLogicalOr(resultingCall, createActualThis());
71212                     resultingCall = assignToCapturedThis
71213                         ? ts.createAssignment(ts.createFileLevelUniqueName("_this"), initializer)
71214                         : initializer;
71215                 }
71216                 return ts.setOriginalNode(resultingCall, node);
71217             }
71218             return ts.visitEachChild(node, visitor, context);
71219         }
71220         function visitNewExpression(node) {
71221             if (ts.some(node.arguments, ts.isSpreadElement)) {
71222                 var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg;
71223                 return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray(__spreadArrays([ts.createVoidZero()], node.arguments)), false, false, false)), undefined, []);
71224             }
71225             return ts.visitEachChild(node, visitor, context);
71226         }
71227         function transformAndSpreadElements(elements, needsUniqueCopy, multiLine, hasTrailingComma) {
71228             var numElements = elements.length;
71229             var segments = ts.flatten(ts.spanMap(elements, partitionSpread, function (partition, visitPartition, _start, end) {
71230                 return visitPartition(partition, multiLine, hasTrailingComma && end === numElements);
71231             }));
71232             if (compilerOptions.downlevelIteration) {
71233                 if (segments.length === 1) {
71234                     var firstSegment = segments[0];
71235                     if (isCallToHelper(firstSegment, "___spread")) {
71236                         return segments[0];
71237                     }
71238                 }
71239                 return ts.createSpreadHelper(context, segments);
71240             }
71241             else {
71242                 if (segments.length === 1) {
71243                     var firstSegment = segments[0];
71244                     if (!needsUniqueCopy
71245                         || isPackedArrayLiteral(firstSegment)
71246                         || isCallToHelper(firstSegment, "___spreadArrays")) {
71247                         return segments[0];
71248                     }
71249                 }
71250                 return ts.createSpreadArraysHelper(context, segments);
71251             }
71252         }
71253         function isPackedElement(node) {
71254             return !ts.isOmittedExpression(node);
71255         }
71256         function isPackedArrayLiteral(node) {
71257             return ts.isArrayLiteralExpression(node) && ts.every(node.elements, isPackedElement);
71258         }
71259         function isCallToHelper(firstSegment, helperName) {
71260             return ts.isCallExpression(firstSegment)
71261                 && ts.isIdentifier(firstSegment.expression)
71262                 && (ts.getEmitFlags(firstSegment.expression) & 4096)
71263                 && firstSegment.expression.escapedText === helperName;
71264         }
71265         function partitionSpread(node) {
71266             return ts.isSpreadElement(node)
71267                 ? visitSpanOfSpreads
71268                 : visitSpanOfNonSpreads;
71269         }
71270         function visitSpanOfSpreads(chunk) {
71271             return ts.map(chunk, visitExpressionOfSpread);
71272         }
71273         function visitSpanOfNonSpreads(chunk, multiLine, hasTrailingComma) {
71274             return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, hasTrailingComma), visitor, ts.isExpression), multiLine);
71275         }
71276         function visitSpreadElement(node) {
71277             return ts.visitNode(node.expression, visitor, ts.isExpression);
71278         }
71279         function visitExpressionOfSpread(node) {
71280             return ts.visitNode(node.expression, visitor, ts.isExpression);
71281         }
71282         function visitTemplateLiteral(node) {
71283             return ts.setTextRange(ts.createLiteral(node.text), node);
71284         }
71285         function visitStringLiteral(node) {
71286             if (node.hasExtendedUnicodeEscape) {
71287                 return ts.setTextRange(ts.createLiteral(node.text), node);
71288             }
71289             return node;
71290         }
71291         function visitNumericLiteral(node) {
71292             if (node.numericLiteralFlags & 384) {
71293                 return ts.setTextRange(ts.createNumericLiteral(node.text), node);
71294             }
71295             return node;
71296         }
71297         function visitTaggedTemplateExpression(node) {
71298             return ts.processTaggedTemplateExpression(context, node, visitor, currentSourceFile, recordTaggedTemplateString, ts.ProcessLevel.All);
71299         }
71300         function visitTemplateExpression(node) {
71301             var expressions = [];
71302             addTemplateHead(expressions, node);
71303             addTemplateSpans(expressions, node);
71304             var expression = ts.reduceLeft(expressions, ts.createAdd);
71305             if (ts.nodeIsSynthesized(expression)) {
71306                 expression.pos = node.pos;
71307                 expression.end = node.end;
71308             }
71309             return expression;
71310         }
71311         function shouldAddTemplateHead(node) {
71312             ts.Debug.assert(node.templateSpans.length !== 0);
71313             return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0;
71314         }
71315         function addTemplateHead(expressions, node) {
71316             if (!shouldAddTemplateHead(node)) {
71317                 return;
71318             }
71319             expressions.push(ts.createLiteral(node.head.text));
71320         }
71321         function addTemplateSpans(expressions, node) {
71322             for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) {
71323                 var span = _a[_i];
71324                 expressions.push(ts.visitNode(span.expression, visitor, ts.isExpression));
71325                 if (span.literal.text.length !== 0) {
71326                     expressions.push(ts.createLiteral(span.literal.text));
71327                 }
71328             }
71329         }
71330         function visitSuperKeyword(isExpressionOfCall) {
71331             return hierarchyFacts & 8 && !isExpressionOfCall ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") :
71332                 ts.createFileLevelUniqueName("_super");
71333         }
71334         function visitMetaProperty(node) {
71335             if (node.keywordToken === 99 && node.name.escapedText === "target") {
71336                 hierarchyFacts |= 16384;
71337                 return ts.createFileLevelUniqueName("_newTarget");
71338             }
71339             return node;
71340         }
71341         function onEmitNode(hint, node, emitCallback) {
71342             if (enabledSubstitutions & 1 && ts.isFunctionLike(node)) {
71343                 var ancestorFacts = enterSubtree(16286, ts.getEmitFlags(node) & 8
71344                     ? 65 | 16
71345                     : 65);
71346                 previousOnEmitNode(hint, node, emitCallback);
71347                 exitSubtree(ancestorFacts, 0, 0);
71348                 return;
71349             }
71350             previousOnEmitNode(hint, node, emitCallback);
71351         }
71352         function enableSubstitutionsForBlockScopedBindings() {
71353             if ((enabledSubstitutions & 2) === 0) {
71354                 enabledSubstitutions |= 2;
71355                 context.enableSubstitution(75);
71356             }
71357         }
71358         function enableSubstitutionsForCapturedThis() {
71359             if ((enabledSubstitutions & 1) === 0) {
71360                 enabledSubstitutions |= 1;
71361                 context.enableSubstitution(104);
71362                 context.enableEmitNotification(162);
71363                 context.enableEmitNotification(161);
71364                 context.enableEmitNotification(163);
71365                 context.enableEmitNotification(164);
71366                 context.enableEmitNotification(202);
71367                 context.enableEmitNotification(201);
71368                 context.enableEmitNotification(244);
71369             }
71370         }
71371         function onSubstituteNode(hint, node) {
71372             node = previousOnSubstituteNode(hint, node);
71373             if (hint === 1) {
71374                 return substituteExpression(node);
71375             }
71376             if (ts.isIdentifier(node)) {
71377                 return substituteIdentifier(node);
71378             }
71379             return node;
71380         }
71381         function substituteIdentifier(node) {
71382             if (enabledSubstitutions & 2 && !ts.isInternalName(node)) {
71383                 var original = ts.getParseTreeNode(node, ts.isIdentifier);
71384                 if (original && isNameOfDeclarationWithCollidingName(original)) {
71385                     return ts.setTextRange(ts.getGeneratedNameForNode(original), node);
71386                 }
71387             }
71388             return node;
71389         }
71390         function isNameOfDeclarationWithCollidingName(node) {
71391             switch (node.parent.kind) {
71392                 case 191:
71393                 case 245:
71394                 case 248:
71395                 case 242:
71396                     return node.parent.name === node
71397                         && resolver.isDeclarationWithCollidingName(node.parent);
71398             }
71399             return false;
71400         }
71401         function substituteExpression(node) {
71402             switch (node.kind) {
71403                 case 75:
71404                     return substituteExpressionIdentifier(node);
71405                 case 104:
71406                     return substituteThisKeyword(node);
71407             }
71408             return node;
71409         }
71410         function substituteExpressionIdentifier(node) {
71411             if (enabledSubstitutions & 2 && !ts.isInternalName(node)) {
71412                 var declaration = resolver.getReferencedDeclarationWithCollidingName(node);
71413                 if (declaration && !(ts.isClassLike(declaration) && isPartOfClassBody(declaration, node))) {
71414                     return ts.setTextRange(ts.getGeneratedNameForNode(ts.getNameOfDeclaration(declaration)), node);
71415                 }
71416             }
71417             return node;
71418         }
71419         function isPartOfClassBody(declaration, node) {
71420             var currentNode = ts.getParseTreeNode(node);
71421             if (!currentNode || currentNode === declaration || currentNode.end <= declaration.pos || currentNode.pos >= declaration.end) {
71422                 return false;
71423             }
71424             var blockScope = ts.getEnclosingBlockScopeContainer(declaration);
71425             while (currentNode) {
71426                 if (currentNode === blockScope || currentNode === declaration) {
71427                     return false;
71428                 }
71429                 if (ts.isClassElement(currentNode) && currentNode.parent === declaration) {
71430                     return true;
71431                 }
71432                 currentNode = currentNode.parent;
71433             }
71434             return false;
71435         }
71436         function substituteThisKeyword(node) {
71437             if (enabledSubstitutions & 1
71438                 && hierarchyFacts & 16) {
71439                 return ts.setTextRange(ts.createFileLevelUniqueName("_this"), node);
71440             }
71441             return node;
71442         }
71443         function getClassMemberPrefix(node, member) {
71444             return ts.hasModifier(member, 32)
71445                 ? ts.getInternalName(node)
71446                 : ts.createPropertyAccess(ts.getInternalName(node), "prototype");
71447         }
71448         function hasSynthesizedDefaultSuperCall(constructor, hasExtendsClause) {
71449             if (!constructor || !hasExtendsClause) {
71450                 return false;
71451             }
71452             if (ts.some(constructor.parameters)) {
71453                 return false;
71454             }
71455             var statement = ts.firstOrUndefined(constructor.body.statements);
71456             if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 226) {
71457                 return false;
71458             }
71459             var statementExpression = statement.expression;
71460             if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 196) {
71461                 return false;
71462             }
71463             var callTarget = statementExpression.expression;
71464             if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 102) {
71465                 return false;
71466             }
71467             var callArgument = ts.singleOrUndefined(statementExpression.arguments);
71468             if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 213) {
71469                 return false;
71470             }
71471             var expression = callArgument.expression;
71472             return ts.isIdentifier(expression) && expression.escapedText === "arguments";
71473         }
71474     }
71475     ts.transformES2015 = transformES2015;
71476     function createExtendsHelper(context, name) {
71477         context.requestEmitHelper(ts.extendsHelper);
71478         return ts.createCall(ts.getUnscopedHelperName("__extends"), undefined, [
71479             name,
71480             ts.createFileLevelUniqueName("_super")
71481         ]);
71482     }
71483     ts.extendsHelper = {
71484         name: "typescript:extends",
71485         importName: "__extends",
71486         scoped: false,
71487         priority: 0,
71488         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            })();"
71489     };
71490 })(ts || (ts = {}));
71491 var ts;
71492 (function (ts) {
71493     function transformES5(context) {
71494         var compilerOptions = context.getCompilerOptions();
71495         var previousOnEmitNode;
71496         var noSubstitution;
71497         if (compilerOptions.jsx === 1 || compilerOptions.jsx === 3) {
71498             previousOnEmitNode = context.onEmitNode;
71499             context.onEmitNode = onEmitNode;
71500             context.enableEmitNotification(268);
71501             context.enableEmitNotification(269);
71502             context.enableEmitNotification(267);
71503             noSubstitution = [];
71504         }
71505         var previousOnSubstituteNode = context.onSubstituteNode;
71506         context.onSubstituteNode = onSubstituteNode;
71507         context.enableSubstitution(194);
71508         context.enableSubstitution(281);
71509         return ts.chainBundle(transformSourceFile);
71510         function transformSourceFile(node) {
71511             return node;
71512         }
71513         function onEmitNode(hint, node, emitCallback) {
71514             switch (node.kind) {
71515                 case 268:
71516                 case 269:
71517                 case 267:
71518                     var tagName = node.tagName;
71519                     noSubstitution[ts.getOriginalNodeId(tagName)] = true;
71520                     break;
71521             }
71522             previousOnEmitNode(hint, node, emitCallback);
71523         }
71524         function onSubstituteNode(hint, node) {
71525             if (node.id && noSubstitution && noSubstitution[node.id]) {
71526                 return previousOnSubstituteNode(hint, node);
71527             }
71528             node = previousOnSubstituteNode(hint, node);
71529             if (ts.isPropertyAccessExpression(node)) {
71530                 return substitutePropertyAccessExpression(node);
71531             }
71532             else if (ts.isPropertyAssignment(node)) {
71533                 return substitutePropertyAssignment(node);
71534             }
71535             return node;
71536         }
71537         function substitutePropertyAccessExpression(node) {
71538             if (ts.isPrivateIdentifier(node.name)) {
71539                 return node;
71540             }
71541             var literalName = trySubstituteReservedName(node.name);
71542             if (literalName) {
71543                 return ts.setTextRange(ts.createElementAccess(node.expression, literalName), node);
71544             }
71545             return node;
71546         }
71547         function substitutePropertyAssignment(node) {
71548             var literalName = ts.isIdentifier(node.name) && trySubstituteReservedName(node.name);
71549             if (literalName) {
71550                 return ts.updatePropertyAssignment(node, literalName, node.initializer);
71551             }
71552             return node;
71553         }
71554         function trySubstituteReservedName(name) {
71555             var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined);
71556             if (token !== undefined && token >= 77 && token <= 112) {
71557                 return ts.setTextRange(ts.createLiteral(name), name);
71558             }
71559             return undefined;
71560         }
71561     }
71562     ts.transformES5 = transformES5;
71563 })(ts || (ts = {}));
71564 var ts;
71565 (function (ts) {
71566     function getInstructionName(instruction) {
71567         switch (instruction) {
71568             case 2: return "return";
71569             case 3: return "break";
71570             case 4: return "yield";
71571             case 5: return "yield*";
71572             case 7: return "endfinally";
71573             default: return undefined;
71574         }
71575     }
71576     function transformGenerators(context) {
71577         var resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistFunctionDeclaration = context.hoistFunctionDeclaration, hoistVariableDeclaration = context.hoistVariableDeclaration;
71578         var compilerOptions = context.getCompilerOptions();
71579         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
71580         var resolver = context.getEmitResolver();
71581         var previousOnSubstituteNode = context.onSubstituteNode;
71582         context.onSubstituteNode = onSubstituteNode;
71583         var renamedCatchVariables;
71584         var renamedCatchVariableDeclarations;
71585         var inGeneratorFunctionBody;
71586         var inStatementContainingYield;
71587         var blocks;
71588         var blockOffsets;
71589         var blockActions;
71590         var blockStack;
71591         var labelOffsets;
71592         var labelExpressions;
71593         var nextLabelId = 1;
71594         var operations;
71595         var operationArguments;
71596         var operationLocations;
71597         var state;
71598         var blockIndex = 0;
71599         var labelNumber = 0;
71600         var labelNumbers;
71601         var lastOperationWasAbrupt;
71602         var lastOperationWasCompletion;
71603         var clauses;
71604         var statements;
71605         var exceptionBlockStack;
71606         var currentExceptionBlock;
71607         var withBlockStack;
71608         return ts.chainBundle(transformSourceFile);
71609         function transformSourceFile(node) {
71610             if (node.isDeclarationFile || (node.transformFlags & 512) === 0) {
71611                 return node;
71612             }
71613             var visited = ts.visitEachChild(node, visitor, context);
71614             ts.addEmitHelpers(visited, context.readEmitHelpers());
71615             return visited;
71616         }
71617         function visitor(node) {
71618             var transformFlags = node.transformFlags;
71619             if (inStatementContainingYield) {
71620                 return visitJavaScriptInStatementContainingYield(node);
71621             }
71622             else if (inGeneratorFunctionBody) {
71623                 return visitJavaScriptInGeneratorFunctionBody(node);
71624             }
71625             else if (ts.isFunctionLikeDeclaration(node) && node.asteriskToken) {
71626                 return visitGenerator(node);
71627             }
71628             else if (transformFlags & 512) {
71629                 return ts.visitEachChild(node, visitor, context);
71630             }
71631             else {
71632                 return node;
71633             }
71634         }
71635         function visitJavaScriptInStatementContainingYield(node) {
71636             switch (node.kind) {
71637                 case 228:
71638                     return visitDoStatement(node);
71639                 case 229:
71640                     return visitWhileStatement(node);
71641                 case 237:
71642                     return visitSwitchStatement(node);
71643                 case 238:
71644                     return visitLabeledStatement(node);
71645                 default:
71646                     return visitJavaScriptInGeneratorFunctionBody(node);
71647             }
71648         }
71649         function visitJavaScriptInGeneratorFunctionBody(node) {
71650             switch (node.kind) {
71651                 case 244:
71652                     return visitFunctionDeclaration(node);
71653                 case 201:
71654                     return visitFunctionExpression(node);
71655                 case 163:
71656                 case 164:
71657                     return visitAccessorDeclaration(node);
71658                 case 225:
71659                     return visitVariableStatement(node);
71660                 case 230:
71661                     return visitForStatement(node);
71662                 case 231:
71663                     return visitForInStatement(node);
71664                 case 234:
71665                     return visitBreakStatement(node);
71666                 case 233:
71667                     return visitContinueStatement(node);
71668                 case 235:
71669                     return visitReturnStatement(node);
71670                 default:
71671                     if (node.transformFlags & 262144) {
71672                         return visitJavaScriptContainingYield(node);
71673                     }
71674                     else if (node.transformFlags & (512 | 1048576)) {
71675                         return ts.visitEachChild(node, visitor, context);
71676                     }
71677                     else {
71678                         return node;
71679                     }
71680             }
71681         }
71682         function visitJavaScriptContainingYield(node) {
71683             switch (node.kind) {
71684                 case 209:
71685                     return visitBinaryExpression(node);
71686                 case 210:
71687                     return visitConditionalExpression(node);
71688                 case 212:
71689                     return visitYieldExpression(node);
71690                 case 192:
71691                     return visitArrayLiteralExpression(node);
71692                 case 193:
71693                     return visitObjectLiteralExpression(node);
71694                 case 195:
71695                     return visitElementAccessExpression(node);
71696                 case 196:
71697                     return visitCallExpression(node);
71698                 case 197:
71699                     return visitNewExpression(node);
71700                 default:
71701                     return ts.visitEachChild(node, visitor, context);
71702             }
71703         }
71704         function visitGenerator(node) {
71705             switch (node.kind) {
71706                 case 244:
71707                     return visitFunctionDeclaration(node);
71708                 case 201:
71709                     return visitFunctionExpression(node);
71710                 default:
71711                     return ts.Debug.failBadSyntaxKind(node);
71712             }
71713         }
71714         function visitFunctionDeclaration(node) {
71715             if (node.asteriskToken) {
71716                 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);
71717             }
71718             else {
71719                 var savedInGeneratorFunctionBody = inGeneratorFunctionBody;
71720                 var savedInStatementContainingYield = inStatementContainingYield;
71721                 inGeneratorFunctionBody = false;
71722                 inStatementContainingYield = false;
71723                 node = ts.visitEachChild(node, visitor, context);
71724                 inGeneratorFunctionBody = savedInGeneratorFunctionBody;
71725                 inStatementContainingYield = savedInStatementContainingYield;
71726             }
71727             if (inGeneratorFunctionBody) {
71728                 hoistFunctionDeclaration(node);
71729                 return undefined;
71730             }
71731             else {
71732                 return node;
71733             }
71734         }
71735         function visitFunctionExpression(node) {
71736             if (node.asteriskToken) {
71737                 node = ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(undefined, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body)), node), node);
71738             }
71739             else {
71740                 var savedInGeneratorFunctionBody = inGeneratorFunctionBody;
71741                 var savedInStatementContainingYield = inStatementContainingYield;
71742                 inGeneratorFunctionBody = false;
71743                 inStatementContainingYield = false;
71744                 node = ts.visitEachChild(node, visitor, context);
71745                 inGeneratorFunctionBody = savedInGeneratorFunctionBody;
71746                 inStatementContainingYield = savedInStatementContainingYield;
71747             }
71748             return node;
71749         }
71750         function visitAccessorDeclaration(node) {
71751             var savedInGeneratorFunctionBody = inGeneratorFunctionBody;
71752             var savedInStatementContainingYield = inStatementContainingYield;
71753             inGeneratorFunctionBody = false;
71754             inStatementContainingYield = false;
71755             node = ts.visitEachChild(node, visitor, context);
71756             inGeneratorFunctionBody = savedInGeneratorFunctionBody;
71757             inStatementContainingYield = savedInStatementContainingYield;
71758             return node;
71759         }
71760         function transformGeneratorFunctionBody(body) {
71761             var statements = [];
71762             var savedInGeneratorFunctionBody = inGeneratorFunctionBody;
71763             var savedInStatementContainingYield = inStatementContainingYield;
71764             var savedBlocks = blocks;
71765             var savedBlockOffsets = blockOffsets;
71766             var savedBlockActions = blockActions;
71767             var savedBlockStack = blockStack;
71768             var savedLabelOffsets = labelOffsets;
71769             var savedLabelExpressions = labelExpressions;
71770             var savedNextLabelId = nextLabelId;
71771             var savedOperations = operations;
71772             var savedOperationArguments = operationArguments;
71773             var savedOperationLocations = operationLocations;
71774             var savedState = state;
71775             inGeneratorFunctionBody = true;
71776             inStatementContainingYield = false;
71777             blocks = undefined;
71778             blockOffsets = undefined;
71779             blockActions = undefined;
71780             blockStack = undefined;
71781             labelOffsets = undefined;
71782             labelExpressions = undefined;
71783             nextLabelId = 1;
71784             operations = undefined;
71785             operationArguments = undefined;
71786             operationLocations = undefined;
71787             state = ts.createTempVariable(undefined);
71788             resumeLexicalEnvironment();
71789             var statementOffset = ts.addPrologue(statements, body.statements, false, visitor);
71790             transformAndEmitStatements(body.statements, statementOffset);
71791             var buildResult = build();
71792             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
71793             statements.push(ts.createReturn(buildResult));
71794             inGeneratorFunctionBody = savedInGeneratorFunctionBody;
71795             inStatementContainingYield = savedInStatementContainingYield;
71796             blocks = savedBlocks;
71797             blockOffsets = savedBlockOffsets;
71798             blockActions = savedBlockActions;
71799             blockStack = savedBlockStack;
71800             labelOffsets = savedLabelOffsets;
71801             labelExpressions = savedLabelExpressions;
71802             nextLabelId = savedNextLabelId;
71803             operations = savedOperations;
71804             operationArguments = savedOperationArguments;
71805             operationLocations = savedOperationLocations;
71806             state = savedState;
71807             return ts.setTextRange(ts.createBlock(statements, body.multiLine), body);
71808         }
71809         function visitVariableStatement(node) {
71810             if (node.transformFlags & 262144) {
71811                 transformAndEmitVariableDeclarationList(node.declarationList);
71812                 return undefined;
71813             }
71814             else {
71815                 if (ts.getEmitFlags(node) & 1048576) {
71816                     return node;
71817                 }
71818                 for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
71819                     var variable = _a[_i];
71820                     hoistVariableDeclaration(variable.name);
71821                 }
71822                 var variables = ts.getInitializedVariables(node.declarationList);
71823                 if (variables.length === 0) {
71824                     return undefined;
71825                 }
71826                 return ts.setSourceMapRange(ts.createExpressionStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node);
71827             }
71828         }
71829         function visitBinaryExpression(node) {
71830             var assoc = ts.getExpressionAssociativity(node);
71831             switch (assoc) {
71832                 case 0:
71833                     return visitLeftAssociativeBinaryExpression(node);
71834                 case 1:
71835                     return visitRightAssociativeBinaryExpression(node);
71836                 default:
71837                     return ts.Debug.assertNever(assoc);
71838             }
71839         }
71840         function visitRightAssociativeBinaryExpression(node) {
71841             var left = node.left, right = node.right;
71842             if (containsYield(right)) {
71843                 var target = void 0;
71844                 switch (left.kind) {
71845                     case 194:
71846                         target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name);
71847                         break;
71848                     case 195:
71849                         target = ts.updateElementAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression)));
71850                         break;
71851                     default:
71852                         target = ts.visitNode(left, visitor, ts.isExpression);
71853                         break;
71854                 }
71855                 var operator = node.operatorToken.kind;
71856                 if (ts.isCompoundAssignment(operator)) {
71857                     return ts.setTextRange(ts.createAssignment(target, ts.setTextRange(ts.createBinary(cacheExpression(target), ts.getNonAssignmentOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression)), node)), node);
71858                 }
71859                 else {
71860                     return ts.updateBinary(node, target, ts.visitNode(right, visitor, ts.isExpression));
71861                 }
71862             }
71863             return ts.visitEachChild(node, visitor, context);
71864         }
71865         function visitLeftAssociativeBinaryExpression(node) {
71866             if (containsYield(node.right)) {
71867                 if (ts.isLogicalOperator(node.operatorToken.kind)) {
71868                     return visitLogicalBinaryExpression(node);
71869                 }
71870                 else if (node.operatorToken.kind === 27) {
71871                     return visitCommaExpression(node);
71872                 }
71873                 var clone_6 = ts.getMutableClone(node);
71874                 clone_6.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression));
71875                 clone_6.right = ts.visitNode(node.right, visitor, ts.isExpression);
71876                 return clone_6;
71877             }
71878             return ts.visitEachChild(node, visitor, context);
71879         }
71880         function visitLogicalBinaryExpression(node) {
71881             var resultLabel = defineLabel();
71882             var resultLocal = declareLocal();
71883             emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), node.left);
71884             if (node.operatorToken.kind === 55) {
71885                 emitBreakWhenFalse(resultLabel, resultLocal, node.left);
71886             }
71887             else {
71888                 emitBreakWhenTrue(resultLabel, resultLocal, node.left);
71889             }
71890             emitAssignment(resultLocal, ts.visitNode(node.right, visitor, ts.isExpression), node.right);
71891             markLabel(resultLabel);
71892             return resultLocal;
71893         }
71894         function visitCommaExpression(node) {
71895             var pendingExpressions = [];
71896             visit(node.left);
71897             visit(node.right);
71898             return ts.inlineExpressions(pendingExpressions);
71899             function visit(node) {
71900                 if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27) {
71901                     visit(node.left);
71902                     visit(node.right);
71903                 }
71904                 else {
71905                     if (containsYield(node) && pendingExpressions.length > 0) {
71906                         emitWorker(1, [ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))]);
71907                         pendingExpressions = [];
71908                     }
71909                     pendingExpressions.push(ts.visitNode(node, visitor, ts.isExpression));
71910                 }
71911             }
71912         }
71913         function visitConditionalExpression(node) {
71914             if (containsYield(node.whenTrue) || containsYield(node.whenFalse)) {
71915                 var whenFalseLabel = defineLabel();
71916                 var resultLabel = defineLabel();
71917                 var resultLocal = declareLocal();
71918                 emitBreakWhenFalse(whenFalseLabel, ts.visitNode(node.condition, visitor, ts.isExpression), node.condition);
71919                 emitAssignment(resultLocal, ts.visitNode(node.whenTrue, visitor, ts.isExpression), node.whenTrue);
71920                 emitBreak(resultLabel);
71921                 markLabel(whenFalseLabel);
71922                 emitAssignment(resultLocal, ts.visitNode(node.whenFalse, visitor, ts.isExpression), node.whenFalse);
71923                 markLabel(resultLabel);
71924                 return resultLocal;
71925             }
71926             return ts.visitEachChild(node, visitor, context);
71927         }
71928         function visitYieldExpression(node) {
71929             var resumeLabel = defineLabel();
71930             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
71931             if (node.asteriskToken) {
71932                 var iterator = (ts.getEmitFlags(node.expression) & 8388608) === 0
71933                     ? ts.createValuesHelper(context, expression, node)
71934                     : expression;
71935                 emitYieldStar(iterator, node);
71936             }
71937             else {
71938                 emitYield(expression, node);
71939             }
71940             markLabel(resumeLabel);
71941             return createGeneratorResume(node);
71942         }
71943         function visitArrayLiteralExpression(node) {
71944             return visitElements(node.elements, undefined, undefined, node.multiLine);
71945         }
71946         function visitElements(elements, leadingElement, location, multiLine) {
71947             var numInitialElements = countInitialNodesWithoutYield(elements);
71948             var temp;
71949             if (numInitialElements > 0) {
71950                 temp = declareLocal();
71951                 var initialElements = ts.visitNodes(elements, visitor, ts.isExpression, 0, numInitialElements);
71952                 emitAssignment(temp, ts.createArrayLiteral(leadingElement
71953                     ? __spreadArrays([leadingElement], initialElements) : initialElements));
71954                 leadingElement = undefined;
71955             }
71956             var expressions = ts.reduceLeft(elements, reduceElement, [], numInitialElements);
71957             return temp
71958                 ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)])
71959                 : ts.setTextRange(ts.createArrayLiteral(leadingElement ? __spreadArrays([leadingElement], expressions) : expressions, multiLine), location);
71960             function reduceElement(expressions, element) {
71961                 if (containsYield(element) && expressions.length > 0) {
71962                     var hasAssignedTemp = temp !== undefined;
71963                     if (!temp) {
71964                         temp = declareLocal();
71965                     }
71966                     emitAssignment(temp, hasAssignedTemp
71967                         ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)])
71968                         : ts.createArrayLiteral(leadingElement ? __spreadArrays([leadingElement], expressions) : expressions, multiLine));
71969                     leadingElement = undefined;
71970                     expressions = [];
71971                 }
71972                 expressions.push(ts.visitNode(element, visitor, ts.isExpression));
71973                 return expressions;
71974             }
71975         }
71976         function visitObjectLiteralExpression(node) {
71977             var properties = node.properties;
71978             var multiLine = node.multiLine;
71979             var numInitialProperties = countInitialNodesWithoutYield(properties);
71980             var temp = declareLocal();
71981             emitAssignment(temp, ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), multiLine));
71982             var expressions = ts.reduceLeft(properties, reduceProperty, [], numInitialProperties);
71983             expressions.push(multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp);
71984             return ts.inlineExpressions(expressions);
71985             function reduceProperty(expressions, property) {
71986                 if (containsYield(property) && expressions.length > 0) {
71987                     emitStatement(ts.createExpressionStatement(ts.inlineExpressions(expressions)));
71988                     expressions = [];
71989                 }
71990                 var expression = ts.createExpressionForObjectLiteralElementLike(node, property, temp);
71991                 var visited = ts.visitNode(expression, visitor, ts.isExpression);
71992                 if (visited) {
71993                     if (multiLine) {
71994                         ts.startOnNewLine(visited);
71995                     }
71996                     expressions.push(visited);
71997                 }
71998                 return expressions;
71999             }
72000         }
72001         function visitElementAccessExpression(node) {
72002             if (containsYield(node.argumentExpression)) {
72003                 var clone_7 = ts.getMutableClone(node);
72004                 clone_7.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression));
72005                 clone_7.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression);
72006                 return clone_7;
72007             }
72008             return ts.visitEachChild(node, visitor, context);
72009         }
72010         function visitCallExpression(node) {
72011             if (!ts.isImportCall(node) && ts.forEach(node.arguments, containsYield)) {
72012                 var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration, languageVersion, true), target = _a.target, thisArg = _a.thisArg;
72013                 return ts.setOriginalNode(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isLeftHandSideExpression)), thisArg, visitElements(node.arguments), node), node);
72014             }
72015             return ts.visitEachChild(node, visitor, context);
72016         }
72017         function visitNewExpression(node) {
72018             if (ts.forEach(node.arguments, containsYield)) {
72019                 var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg;
72020                 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);
72021             }
72022             return ts.visitEachChild(node, visitor, context);
72023         }
72024         function transformAndEmitStatements(statements, start) {
72025             if (start === void 0) { start = 0; }
72026             var numStatements = statements.length;
72027             for (var i = start; i < numStatements; i++) {
72028                 transformAndEmitStatement(statements[i]);
72029             }
72030         }
72031         function transformAndEmitEmbeddedStatement(node) {
72032             if (ts.isBlock(node)) {
72033                 transformAndEmitStatements(node.statements);
72034             }
72035             else {
72036                 transformAndEmitStatement(node);
72037             }
72038         }
72039         function transformAndEmitStatement(node) {
72040             var savedInStatementContainingYield = inStatementContainingYield;
72041             if (!inStatementContainingYield) {
72042                 inStatementContainingYield = containsYield(node);
72043             }
72044             transformAndEmitStatementWorker(node);
72045             inStatementContainingYield = savedInStatementContainingYield;
72046         }
72047         function transformAndEmitStatementWorker(node) {
72048             switch (node.kind) {
72049                 case 223:
72050                     return transformAndEmitBlock(node);
72051                 case 226:
72052                     return transformAndEmitExpressionStatement(node);
72053                 case 227:
72054                     return transformAndEmitIfStatement(node);
72055                 case 228:
72056                     return transformAndEmitDoStatement(node);
72057                 case 229:
72058                     return transformAndEmitWhileStatement(node);
72059                 case 230:
72060                     return transformAndEmitForStatement(node);
72061                 case 231:
72062                     return transformAndEmitForInStatement(node);
72063                 case 233:
72064                     return transformAndEmitContinueStatement(node);
72065                 case 234:
72066                     return transformAndEmitBreakStatement(node);
72067                 case 235:
72068                     return transformAndEmitReturnStatement(node);
72069                 case 236:
72070                     return transformAndEmitWithStatement(node);
72071                 case 237:
72072                     return transformAndEmitSwitchStatement(node);
72073                 case 238:
72074                     return transformAndEmitLabeledStatement(node);
72075                 case 239:
72076                     return transformAndEmitThrowStatement(node);
72077                 case 240:
72078                     return transformAndEmitTryStatement(node);
72079                 default:
72080                     return emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72081             }
72082         }
72083         function transformAndEmitBlock(node) {
72084             if (containsYield(node)) {
72085                 transformAndEmitStatements(node.statements);
72086             }
72087             else {
72088                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72089             }
72090         }
72091         function transformAndEmitExpressionStatement(node) {
72092             emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72093         }
72094         function transformAndEmitVariableDeclarationList(node) {
72095             for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) {
72096                 var variable = _a[_i];
72097                 var name = ts.getSynthesizedClone(variable.name);
72098                 ts.setCommentRange(name, variable.name);
72099                 hoistVariableDeclaration(name);
72100             }
72101             var variables = ts.getInitializedVariables(node);
72102             var numVariables = variables.length;
72103             var variablesWritten = 0;
72104             var pendingExpressions = [];
72105             while (variablesWritten < numVariables) {
72106                 for (var i = variablesWritten; i < numVariables; i++) {
72107                     var variable = variables[i];
72108                     if (containsYield(variable.initializer) && pendingExpressions.length > 0) {
72109                         break;
72110                     }
72111                     pendingExpressions.push(transformInitializedVariable(variable));
72112                 }
72113                 if (pendingExpressions.length) {
72114                     emitStatement(ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions)));
72115                     variablesWritten += pendingExpressions.length;
72116                     pendingExpressions = [];
72117                 }
72118             }
72119             return undefined;
72120         }
72121         function transformInitializedVariable(node) {
72122             return ts.setSourceMapRange(ts.createAssignment(ts.setSourceMapRange(ts.getSynthesizedClone(node.name), node.name), ts.visitNode(node.initializer, visitor, ts.isExpression)), node);
72123         }
72124         function transformAndEmitIfStatement(node) {
72125             if (containsYield(node)) {
72126                 if (containsYield(node.thenStatement) || containsYield(node.elseStatement)) {
72127                     var endLabel = defineLabel();
72128                     var elseLabel = node.elseStatement ? defineLabel() : undefined;
72129                     emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression), node.expression);
72130                     transformAndEmitEmbeddedStatement(node.thenStatement);
72131                     if (node.elseStatement) {
72132                         emitBreak(endLabel);
72133                         markLabel(elseLabel);
72134                         transformAndEmitEmbeddedStatement(node.elseStatement);
72135                     }
72136                     markLabel(endLabel);
72137                 }
72138                 else {
72139                     emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72140                 }
72141             }
72142             else {
72143                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72144             }
72145         }
72146         function transformAndEmitDoStatement(node) {
72147             if (containsYield(node)) {
72148                 var conditionLabel = defineLabel();
72149                 var loopLabel = defineLabel();
72150                 beginLoopBlock(conditionLabel);
72151                 markLabel(loopLabel);
72152                 transformAndEmitEmbeddedStatement(node.statement);
72153                 markLabel(conditionLabel);
72154                 emitBreakWhenTrue(loopLabel, ts.visitNode(node.expression, visitor, ts.isExpression));
72155                 endLoopBlock();
72156             }
72157             else {
72158                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72159             }
72160         }
72161         function visitDoStatement(node) {
72162             if (inStatementContainingYield) {
72163                 beginScriptLoopBlock();
72164                 node = ts.visitEachChild(node, visitor, context);
72165                 endLoopBlock();
72166                 return node;
72167             }
72168             else {
72169                 return ts.visitEachChild(node, visitor, context);
72170             }
72171         }
72172         function transformAndEmitWhileStatement(node) {
72173             if (containsYield(node)) {
72174                 var loopLabel = defineLabel();
72175                 var endLabel = beginLoopBlock(loopLabel);
72176                 markLabel(loopLabel);
72177                 emitBreakWhenFalse(endLabel, ts.visitNode(node.expression, visitor, ts.isExpression));
72178                 transformAndEmitEmbeddedStatement(node.statement);
72179                 emitBreak(loopLabel);
72180                 endLoopBlock();
72181             }
72182             else {
72183                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72184             }
72185         }
72186         function visitWhileStatement(node) {
72187             if (inStatementContainingYield) {
72188                 beginScriptLoopBlock();
72189                 node = ts.visitEachChild(node, visitor, context);
72190                 endLoopBlock();
72191                 return node;
72192             }
72193             else {
72194                 return ts.visitEachChild(node, visitor, context);
72195             }
72196         }
72197         function transformAndEmitForStatement(node) {
72198             if (containsYield(node)) {
72199                 var conditionLabel = defineLabel();
72200                 var incrementLabel = defineLabel();
72201                 var endLabel = beginLoopBlock(incrementLabel);
72202                 if (node.initializer) {
72203                     var initializer = node.initializer;
72204                     if (ts.isVariableDeclarationList(initializer)) {
72205                         transformAndEmitVariableDeclarationList(initializer);
72206                     }
72207                     else {
72208                         emitStatement(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer));
72209                     }
72210                 }
72211                 markLabel(conditionLabel);
72212                 if (node.condition) {
72213                     emitBreakWhenFalse(endLabel, ts.visitNode(node.condition, visitor, ts.isExpression));
72214                 }
72215                 transformAndEmitEmbeddedStatement(node.statement);
72216                 markLabel(incrementLabel);
72217                 if (node.incrementor) {
72218                     emitStatement(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor));
72219                 }
72220                 emitBreak(conditionLabel);
72221                 endLoopBlock();
72222             }
72223             else {
72224                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72225             }
72226         }
72227         function visitForStatement(node) {
72228             if (inStatementContainingYield) {
72229                 beginScriptLoopBlock();
72230             }
72231             var initializer = node.initializer;
72232             if (initializer && ts.isVariableDeclarationList(initializer)) {
72233                 for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) {
72234                     var variable = _a[_i];
72235                     hoistVariableDeclaration(variable.name);
72236                 }
72237                 var variables = ts.getInitializedVariables(initializer);
72238                 node = ts.updateFor(node, variables.length > 0
72239                     ? ts.inlineExpressions(ts.map(variables, transformInitializedVariable))
72240                     : undefined, ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock));
72241             }
72242             else {
72243                 node = ts.visitEachChild(node, visitor, context);
72244             }
72245             if (inStatementContainingYield) {
72246                 endLoopBlock();
72247             }
72248             return node;
72249         }
72250         function transformAndEmitForInStatement(node) {
72251             if (containsYield(node)) {
72252                 var keysArray = declareLocal();
72253                 var key = declareLocal();
72254                 var keysIndex = ts.createLoopVariable();
72255                 var initializer = node.initializer;
72256                 hoistVariableDeclaration(keysIndex);
72257                 emitAssignment(keysArray, ts.createArrayLiteral());
72258                 emitStatement(ts.createForIn(key, ts.visitNode(node.expression, visitor, ts.isExpression), ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(keysArray, "push"), undefined, [key]))));
72259                 emitAssignment(keysIndex, ts.createLiteral(0));
72260                 var conditionLabel = defineLabel();
72261                 var incrementLabel = defineLabel();
72262                 var endLabel = beginLoopBlock(incrementLabel);
72263                 markLabel(conditionLabel);
72264                 emitBreakWhenFalse(endLabel, ts.createLessThan(keysIndex, ts.createPropertyAccess(keysArray, "length")));
72265                 var variable = void 0;
72266                 if (ts.isVariableDeclarationList(initializer)) {
72267                     for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) {
72268                         var variable_1 = _a[_i];
72269                         hoistVariableDeclaration(variable_1.name);
72270                     }
72271                     variable = ts.getSynthesizedClone(initializer.declarations[0].name);
72272                 }
72273                 else {
72274                     variable = ts.visitNode(initializer, visitor, ts.isExpression);
72275                     ts.Debug.assert(ts.isLeftHandSideExpression(variable));
72276                 }
72277                 emitAssignment(variable, ts.createElementAccess(keysArray, keysIndex));
72278                 transformAndEmitEmbeddedStatement(node.statement);
72279                 markLabel(incrementLabel);
72280                 emitStatement(ts.createExpressionStatement(ts.createPostfixIncrement(keysIndex)));
72281                 emitBreak(conditionLabel);
72282                 endLoopBlock();
72283             }
72284             else {
72285                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72286             }
72287         }
72288         function visitForInStatement(node) {
72289             if (inStatementContainingYield) {
72290                 beginScriptLoopBlock();
72291             }
72292             var initializer = node.initializer;
72293             if (ts.isVariableDeclarationList(initializer)) {
72294                 for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) {
72295                     var variable = _a[_i];
72296                     hoistVariableDeclaration(variable.name);
72297                 }
72298                 node = ts.updateForIn(node, initializer.declarations[0].name, ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock));
72299             }
72300             else {
72301                 node = ts.visitEachChild(node, visitor, context);
72302             }
72303             if (inStatementContainingYield) {
72304                 endLoopBlock();
72305             }
72306             return node;
72307         }
72308         function transformAndEmitContinueStatement(node) {
72309             var label = findContinueTarget(node.label ? ts.idText(node.label) : undefined);
72310             if (label > 0) {
72311                 emitBreak(label, node);
72312             }
72313             else {
72314                 emitStatement(node);
72315             }
72316         }
72317         function visitContinueStatement(node) {
72318             if (inStatementContainingYield) {
72319                 var label = findContinueTarget(node.label && ts.idText(node.label));
72320                 if (label > 0) {
72321                     return createInlineBreak(label, node);
72322                 }
72323             }
72324             return ts.visitEachChild(node, visitor, context);
72325         }
72326         function transformAndEmitBreakStatement(node) {
72327             var label = findBreakTarget(node.label ? ts.idText(node.label) : undefined);
72328             if (label > 0) {
72329                 emitBreak(label, node);
72330             }
72331             else {
72332                 emitStatement(node);
72333             }
72334         }
72335         function visitBreakStatement(node) {
72336             if (inStatementContainingYield) {
72337                 var label = findBreakTarget(node.label && ts.idText(node.label));
72338                 if (label > 0) {
72339                     return createInlineBreak(label, node);
72340                 }
72341             }
72342             return ts.visitEachChild(node, visitor, context);
72343         }
72344         function transformAndEmitReturnStatement(node) {
72345             emitReturn(ts.visitNode(node.expression, visitor, ts.isExpression), node);
72346         }
72347         function visitReturnStatement(node) {
72348             return createInlineReturn(ts.visitNode(node.expression, visitor, ts.isExpression), node);
72349         }
72350         function transformAndEmitWithStatement(node) {
72351             if (containsYield(node)) {
72352                 beginWithBlock(cacheExpression(ts.visitNode(node.expression, visitor, ts.isExpression)));
72353                 transformAndEmitEmbeddedStatement(node.statement);
72354                 endWithBlock();
72355             }
72356             else {
72357                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72358             }
72359         }
72360         function transformAndEmitSwitchStatement(node) {
72361             if (containsYield(node.caseBlock)) {
72362                 var caseBlock = node.caseBlock;
72363                 var numClauses = caseBlock.clauses.length;
72364                 var endLabel = beginSwitchBlock();
72365                 var expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isExpression));
72366                 var clauseLabels = [];
72367                 var defaultClauseIndex = -1;
72368                 for (var i = 0; i < numClauses; i++) {
72369                     var clause = caseBlock.clauses[i];
72370                     clauseLabels.push(defineLabel());
72371                     if (clause.kind === 278 && defaultClauseIndex === -1) {
72372                         defaultClauseIndex = i;
72373                     }
72374                 }
72375                 var clausesWritten = 0;
72376                 var pendingClauses = [];
72377                 while (clausesWritten < numClauses) {
72378                     var defaultClausesSkipped = 0;
72379                     for (var i = clausesWritten; i < numClauses; i++) {
72380                         var clause = caseBlock.clauses[i];
72381                         if (clause.kind === 277) {
72382                             if (containsYield(clause.expression) && pendingClauses.length > 0) {
72383                                 break;
72384                             }
72385                             pendingClauses.push(ts.createCaseClause(ts.visitNode(clause.expression, visitor, ts.isExpression), [
72386                                 createInlineBreak(clauseLabels[i], clause.expression)
72387                             ]));
72388                         }
72389                         else {
72390                             defaultClausesSkipped++;
72391                         }
72392                     }
72393                     if (pendingClauses.length) {
72394                         emitStatement(ts.createSwitch(expression, ts.createCaseBlock(pendingClauses)));
72395                         clausesWritten += pendingClauses.length;
72396                         pendingClauses = [];
72397                     }
72398                     if (defaultClausesSkipped > 0) {
72399                         clausesWritten += defaultClausesSkipped;
72400                         defaultClausesSkipped = 0;
72401                     }
72402                 }
72403                 if (defaultClauseIndex >= 0) {
72404                     emitBreak(clauseLabels[defaultClauseIndex]);
72405                 }
72406                 else {
72407                     emitBreak(endLabel);
72408                 }
72409                 for (var i = 0; i < numClauses; i++) {
72410                     markLabel(clauseLabels[i]);
72411                     transformAndEmitStatements(caseBlock.clauses[i].statements);
72412                 }
72413                 endSwitchBlock();
72414             }
72415             else {
72416                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72417             }
72418         }
72419         function visitSwitchStatement(node) {
72420             if (inStatementContainingYield) {
72421                 beginScriptSwitchBlock();
72422             }
72423             node = ts.visitEachChild(node, visitor, context);
72424             if (inStatementContainingYield) {
72425                 endSwitchBlock();
72426             }
72427             return node;
72428         }
72429         function transformAndEmitLabeledStatement(node) {
72430             if (containsYield(node)) {
72431                 beginLabeledBlock(ts.idText(node.label));
72432                 transformAndEmitEmbeddedStatement(node.statement);
72433                 endLabeledBlock();
72434             }
72435             else {
72436                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72437             }
72438         }
72439         function visitLabeledStatement(node) {
72440             if (inStatementContainingYield) {
72441                 beginScriptLabeledBlock(ts.idText(node.label));
72442             }
72443             node = ts.visitEachChild(node, visitor, context);
72444             if (inStatementContainingYield) {
72445                 endLabeledBlock();
72446             }
72447             return node;
72448         }
72449         function transformAndEmitThrowStatement(node) {
72450             emitThrow(ts.visitNode(node.expression, visitor, ts.isExpression), node);
72451         }
72452         function transformAndEmitTryStatement(node) {
72453             if (containsYield(node)) {
72454                 beginExceptionBlock();
72455                 transformAndEmitEmbeddedStatement(node.tryBlock);
72456                 if (node.catchClause) {
72457                     beginCatchBlock(node.catchClause.variableDeclaration);
72458                     transformAndEmitEmbeddedStatement(node.catchClause.block);
72459                 }
72460                 if (node.finallyBlock) {
72461                     beginFinallyBlock();
72462                     transformAndEmitEmbeddedStatement(node.finallyBlock);
72463                 }
72464                 endExceptionBlock();
72465             }
72466             else {
72467                 emitStatement(ts.visitEachChild(node, visitor, context));
72468             }
72469         }
72470         function containsYield(node) {
72471             return !!node && (node.transformFlags & 262144) !== 0;
72472         }
72473         function countInitialNodesWithoutYield(nodes) {
72474             var numNodes = nodes.length;
72475             for (var i = 0; i < numNodes; i++) {
72476                 if (containsYield(nodes[i])) {
72477                     return i;
72478                 }
72479             }
72480             return -1;
72481         }
72482         function onSubstituteNode(hint, node) {
72483             node = previousOnSubstituteNode(hint, node);
72484             if (hint === 1) {
72485                 return substituteExpression(node);
72486             }
72487             return node;
72488         }
72489         function substituteExpression(node) {
72490             if (ts.isIdentifier(node)) {
72491                 return substituteExpressionIdentifier(node);
72492             }
72493             return node;
72494         }
72495         function substituteExpressionIdentifier(node) {
72496             if (!ts.isGeneratedIdentifier(node) && renamedCatchVariables && renamedCatchVariables.has(ts.idText(node))) {
72497                 var original = ts.getOriginalNode(node);
72498                 if (ts.isIdentifier(original) && original.parent) {
72499                     var declaration = resolver.getReferencedValueDeclaration(original);
72500                     if (declaration) {
72501                         var name = renamedCatchVariableDeclarations[ts.getOriginalNodeId(declaration)];
72502                         if (name) {
72503                             var clone_8 = ts.getMutableClone(name);
72504                             ts.setSourceMapRange(clone_8, node);
72505                             ts.setCommentRange(clone_8, node);
72506                             return clone_8;
72507                         }
72508                     }
72509                 }
72510             }
72511             return node;
72512         }
72513         function cacheExpression(node) {
72514             if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096) {
72515                 return node;
72516             }
72517             var temp = ts.createTempVariable(hoistVariableDeclaration);
72518             emitAssignment(temp, node, node);
72519             return temp;
72520         }
72521         function declareLocal(name) {
72522             var temp = name
72523                 ? ts.createUniqueName(name)
72524                 : ts.createTempVariable(undefined);
72525             hoistVariableDeclaration(temp);
72526             return temp;
72527         }
72528         function defineLabel() {
72529             if (!labelOffsets) {
72530                 labelOffsets = [];
72531             }
72532             var label = nextLabelId;
72533             nextLabelId++;
72534             labelOffsets[label] = -1;
72535             return label;
72536         }
72537         function markLabel(label) {
72538             ts.Debug.assert(labelOffsets !== undefined, "No labels were defined.");
72539             labelOffsets[label] = operations ? operations.length : 0;
72540         }
72541         function beginBlock(block) {
72542             if (!blocks) {
72543                 blocks = [];
72544                 blockActions = [];
72545                 blockOffsets = [];
72546                 blockStack = [];
72547             }
72548             var index = blockActions.length;
72549             blockActions[index] = 0;
72550             blockOffsets[index] = operations ? operations.length : 0;
72551             blocks[index] = block;
72552             blockStack.push(block);
72553             return index;
72554         }
72555         function endBlock() {
72556             var block = peekBlock();
72557             if (block === undefined)
72558                 return ts.Debug.fail("beginBlock was never called.");
72559             var index = blockActions.length;
72560             blockActions[index] = 1;
72561             blockOffsets[index] = operations ? operations.length : 0;
72562             blocks[index] = block;
72563             blockStack.pop();
72564             return block;
72565         }
72566         function peekBlock() {
72567             return ts.lastOrUndefined(blockStack);
72568         }
72569         function peekBlockKind() {
72570             var block = peekBlock();
72571             return block && block.kind;
72572         }
72573         function beginWithBlock(expression) {
72574             var startLabel = defineLabel();
72575             var endLabel = defineLabel();
72576             markLabel(startLabel);
72577             beginBlock({
72578                 kind: 1,
72579                 expression: expression,
72580                 startLabel: startLabel,
72581                 endLabel: endLabel
72582             });
72583         }
72584         function endWithBlock() {
72585             ts.Debug.assert(peekBlockKind() === 1);
72586             var block = endBlock();
72587             markLabel(block.endLabel);
72588         }
72589         function beginExceptionBlock() {
72590             var startLabel = defineLabel();
72591             var endLabel = defineLabel();
72592             markLabel(startLabel);
72593             beginBlock({
72594                 kind: 0,
72595                 state: 0,
72596                 startLabel: startLabel,
72597                 endLabel: endLabel
72598             });
72599             emitNop();
72600             return endLabel;
72601         }
72602         function beginCatchBlock(variable) {
72603             ts.Debug.assert(peekBlockKind() === 0);
72604             var name;
72605             if (ts.isGeneratedIdentifier(variable.name)) {
72606                 name = variable.name;
72607                 hoistVariableDeclaration(variable.name);
72608             }
72609             else {
72610                 var text = ts.idText(variable.name);
72611                 name = declareLocal(text);
72612                 if (!renamedCatchVariables) {
72613                     renamedCatchVariables = ts.createMap();
72614                     renamedCatchVariableDeclarations = [];
72615                     context.enableSubstitution(75);
72616                 }
72617                 renamedCatchVariables.set(text, true);
72618                 renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name;
72619             }
72620             var exception = peekBlock();
72621             ts.Debug.assert(exception.state < 1);
72622             var endLabel = exception.endLabel;
72623             emitBreak(endLabel);
72624             var catchLabel = defineLabel();
72625             markLabel(catchLabel);
72626             exception.state = 1;
72627             exception.catchVariable = name;
72628             exception.catchLabel = catchLabel;
72629             emitAssignment(name, ts.createCall(ts.createPropertyAccess(state, "sent"), undefined, []));
72630             emitNop();
72631         }
72632         function beginFinallyBlock() {
72633             ts.Debug.assert(peekBlockKind() === 0);
72634             var exception = peekBlock();
72635             ts.Debug.assert(exception.state < 2);
72636             var endLabel = exception.endLabel;
72637             emitBreak(endLabel);
72638             var finallyLabel = defineLabel();
72639             markLabel(finallyLabel);
72640             exception.state = 2;
72641             exception.finallyLabel = finallyLabel;
72642         }
72643         function endExceptionBlock() {
72644             ts.Debug.assert(peekBlockKind() === 0);
72645             var exception = endBlock();
72646             var state = exception.state;
72647             if (state < 2) {
72648                 emitBreak(exception.endLabel);
72649             }
72650             else {
72651                 emitEndfinally();
72652             }
72653             markLabel(exception.endLabel);
72654             emitNop();
72655             exception.state = 3;
72656         }
72657         function beginScriptLoopBlock() {
72658             beginBlock({
72659                 kind: 3,
72660                 isScript: true,
72661                 breakLabel: -1,
72662                 continueLabel: -1
72663             });
72664         }
72665         function beginLoopBlock(continueLabel) {
72666             var breakLabel = defineLabel();
72667             beginBlock({
72668                 kind: 3,
72669                 isScript: false,
72670                 breakLabel: breakLabel,
72671                 continueLabel: continueLabel,
72672             });
72673             return breakLabel;
72674         }
72675         function endLoopBlock() {
72676             ts.Debug.assert(peekBlockKind() === 3);
72677             var block = endBlock();
72678             var breakLabel = block.breakLabel;
72679             if (!block.isScript) {
72680                 markLabel(breakLabel);
72681             }
72682         }
72683         function beginScriptSwitchBlock() {
72684             beginBlock({
72685                 kind: 2,
72686                 isScript: true,
72687                 breakLabel: -1
72688             });
72689         }
72690         function beginSwitchBlock() {
72691             var breakLabel = defineLabel();
72692             beginBlock({
72693                 kind: 2,
72694                 isScript: false,
72695                 breakLabel: breakLabel,
72696             });
72697             return breakLabel;
72698         }
72699         function endSwitchBlock() {
72700             ts.Debug.assert(peekBlockKind() === 2);
72701             var block = endBlock();
72702             var breakLabel = block.breakLabel;
72703             if (!block.isScript) {
72704                 markLabel(breakLabel);
72705             }
72706         }
72707         function beginScriptLabeledBlock(labelText) {
72708             beginBlock({
72709                 kind: 4,
72710                 isScript: true,
72711                 labelText: labelText,
72712                 breakLabel: -1
72713             });
72714         }
72715         function beginLabeledBlock(labelText) {
72716             var breakLabel = defineLabel();
72717             beginBlock({
72718                 kind: 4,
72719                 isScript: false,
72720                 labelText: labelText,
72721                 breakLabel: breakLabel
72722             });
72723         }
72724         function endLabeledBlock() {
72725             ts.Debug.assert(peekBlockKind() === 4);
72726             var block = endBlock();
72727             if (!block.isScript) {
72728                 markLabel(block.breakLabel);
72729             }
72730         }
72731         function supportsUnlabeledBreak(block) {
72732             return block.kind === 2
72733                 || block.kind === 3;
72734         }
72735         function supportsLabeledBreakOrContinue(block) {
72736             return block.kind === 4;
72737         }
72738         function supportsUnlabeledContinue(block) {
72739             return block.kind === 3;
72740         }
72741         function hasImmediateContainingLabeledBlock(labelText, start) {
72742             for (var j = start; j >= 0; j--) {
72743                 var containingBlock = blockStack[j];
72744                 if (supportsLabeledBreakOrContinue(containingBlock)) {
72745                     if (containingBlock.labelText === labelText) {
72746                         return true;
72747                     }
72748                 }
72749                 else {
72750                     break;
72751                 }
72752             }
72753             return false;
72754         }
72755         function findBreakTarget(labelText) {
72756             if (blockStack) {
72757                 if (labelText) {
72758                     for (var i = blockStack.length - 1; i >= 0; i--) {
72759                         var block = blockStack[i];
72760                         if (supportsLabeledBreakOrContinue(block) && block.labelText === labelText) {
72761                             return block.breakLabel;
72762                         }
72763                         else if (supportsUnlabeledBreak(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) {
72764                             return block.breakLabel;
72765                         }
72766                     }
72767                 }
72768                 else {
72769                     for (var i = blockStack.length - 1; i >= 0; i--) {
72770                         var block = blockStack[i];
72771                         if (supportsUnlabeledBreak(block)) {
72772                             return block.breakLabel;
72773                         }
72774                     }
72775                 }
72776             }
72777             return 0;
72778         }
72779         function findContinueTarget(labelText) {
72780             if (blockStack) {
72781                 if (labelText) {
72782                     for (var i = blockStack.length - 1; i >= 0; i--) {
72783                         var block = blockStack[i];
72784                         if (supportsUnlabeledContinue(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) {
72785                             return block.continueLabel;
72786                         }
72787                     }
72788                 }
72789                 else {
72790                     for (var i = blockStack.length - 1; i >= 0; i--) {
72791                         var block = blockStack[i];
72792                         if (supportsUnlabeledContinue(block)) {
72793                             return block.continueLabel;
72794                         }
72795                     }
72796                 }
72797             }
72798             return 0;
72799         }
72800         function createLabel(label) {
72801             if (label !== undefined && label > 0) {
72802                 if (labelExpressions === undefined) {
72803                     labelExpressions = [];
72804                 }
72805                 var expression = ts.createLiteral(-1);
72806                 if (labelExpressions[label] === undefined) {
72807                     labelExpressions[label] = [expression];
72808                 }
72809                 else {
72810                     labelExpressions[label].push(expression);
72811                 }
72812                 return expression;
72813             }
72814             return ts.createOmittedExpression();
72815         }
72816         function createInstruction(instruction) {
72817             var literal = ts.createLiteral(instruction);
72818             ts.addSyntheticTrailingComment(literal, 3, getInstructionName(instruction));
72819             return literal;
72820         }
72821         function createInlineBreak(label, location) {
72822             ts.Debug.assertLessThan(0, label, "Invalid label");
72823             return ts.setTextRange(ts.createReturn(ts.createArrayLiteral([
72824                 createInstruction(3),
72825                 createLabel(label)
72826             ])), location);
72827         }
72828         function createInlineReturn(expression, location) {
72829             return ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression
72830                 ? [createInstruction(2), expression]
72831                 : [createInstruction(2)])), location);
72832         }
72833         function createGeneratorResume(location) {
72834             return ts.setTextRange(ts.createCall(ts.createPropertyAccess(state, "sent"), undefined, []), location);
72835         }
72836         function emitNop() {
72837             emitWorker(0);
72838         }
72839         function emitStatement(node) {
72840             if (node) {
72841                 emitWorker(1, [node]);
72842             }
72843             else {
72844                 emitNop();
72845             }
72846         }
72847         function emitAssignment(left, right, location) {
72848             emitWorker(2, [left, right], location);
72849         }
72850         function emitBreak(label, location) {
72851             emitWorker(3, [label], location);
72852         }
72853         function emitBreakWhenTrue(label, condition, location) {
72854             emitWorker(4, [label, condition], location);
72855         }
72856         function emitBreakWhenFalse(label, condition, location) {
72857             emitWorker(5, [label, condition], location);
72858         }
72859         function emitYieldStar(expression, location) {
72860             emitWorker(7, [expression], location);
72861         }
72862         function emitYield(expression, location) {
72863             emitWorker(6, [expression], location);
72864         }
72865         function emitReturn(expression, location) {
72866             emitWorker(8, [expression], location);
72867         }
72868         function emitThrow(expression, location) {
72869             emitWorker(9, [expression], location);
72870         }
72871         function emitEndfinally() {
72872             emitWorker(10);
72873         }
72874         function emitWorker(code, args, location) {
72875             if (operations === undefined) {
72876                 operations = [];
72877                 operationArguments = [];
72878                 operationLocations = [];
72879             }
72880             if (labelOffsets === undefined) {
72881                 markLabel(defineLabel());
72882             }
72883             var operationIndex = operations.length;
72884             operations[operationIndex] = code;
72885             operationArguments[operationIndex] = args;
72886             operationLocations[operationIndex] = location;
72887         }
72888         function build() {
72889             blockIndex = 0;
72890             labelNumber = 0;
72891             labelNumbers = undefined;
72892             lastOperationWasAbrupt = false;
72893             lastOperationWasCompletion = false;
72894             clauses = undefined;
72895             statements = undefined;
72896             exceptionBlockStack = undefined;
72897             currentExceptionBlock = undefined;
72898             withBlockStack = undefined;
72899             var buildResult = buildStatements();
72900             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));
72901         }
72902         function buildStatements() {
72903             if (operations) {
72904                 for (var operationIndex = 0; operationIndex < operations.length; operationIndex++) {
72905                     writeOperation(operationIndex);
72906                 }
72907                 flushFinalLabel(operations.length);
72908             }
72909             else {
72910                 flushFinalLabel(0);
72911             }
72912             if (clauses) {
72913                 var labelExpression = ts.createPropertyAccess(state, "label");
72914                 var switchStatement = ts.createSwitch(labelExpression, ts.createCaseBlock(clauses));
72915                 return [ts.startOnNewLine(switchStatement)];
72916             }
72917             if (statements) {
72918                 return statements;
72919             }
72920             return [];
72921         }
72922         function flushLabel() {
72923             if (!statements) {
72924                 return;
72925             }
72926             appendLabel(!lastOperationWasAbrupt);
72927             lastOperationWasAbrupt = false;
72928             lastOperationWasCompletion = false;
72929             labelNumber++;
72930         }
72931         function flushFinalLabel(operationIndex) {
72932             if (isFinalLabelReachable(operationIndex)) {
72933                 tryEnterLabel(operationIndex);
72934                 withBlockStack = undefined;
72935                 writeReturn(undefined, undefined);
72936             }
72937             if (statements && clauses) {
72938                 appendLabel(false);
72939             }
72940             updateLabelExpressions();
72941         }
72942         function isFinalLabelReachable(operationIndex) {
72943             if (!lastOperationWasCompletion) {
72944                 return true;
72945             }
72946             if (!labelOffsets || !labelExpressions) {
72947                 return false;
72948             }
72949             for (var label = 0; label < labelOffsets.length; label++) {
72950                 if (labelOffsets[label] === operationIndex && labelExpressions[label]) {
72951                     return true;
72952                 }
72953             }
72954             return false;
72955         }
72956         function appendLabel(markLabelEnd) {
72957             if (!clauses) {
72958                 clauses = [];
72959             }
72960             if (statements) {
72961                 if (withBlockStack) {
72962                     for (var i = withBlockStack.length - 1; i >= 0; i--) {
72963                         var withBlock = withBlockStack[i];
72964                         statements = [ts.createWith(withBlock.expression, ts.createBlock(statements))];
72965                     }
72966                 }
72967                 if (currentExceptionBlock) {
72968                     var startLabel = currentExceptionBlock.startLabel, catchLabel = currentExceptionBlock.catchLabel, finallyLabel = currentExceptionBlock.finallyLabel, endLabel = currentExceptionBlock.endLabel;
72969                     statements.unshift(ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createPropertyAccess(state, "trys"), "push"), undefined, [
72970                         ts.createArrayLiteral([
72971                             createLabel(startLabel),
72972                             createLabel(catchLabel),
72973                             createLabel(finallyLabel),
72974                             createLabel(endLabel)
72975                         ])
72976                     ])));
72977                     currentExceptionBlock = undefined;
72978                 }
72979                 if (markLabelEnd) {
72980                     statements.push(ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(state, "label"), ts.createLiteral(labelNumber + 1))));
72981                 }
72982             }
72983             clauses.push(ts.createCaseClause(ts.createLiteral(labelNumber), statements || []));
72984             statements = undefined;
72985         }
72986         function tryEnterLabel(operationIndex) {
72987             if (!labelOffsets) {
72988                 return;
72989             }
72990             for (var label = 0; label < labelOffsets.length; label++) {
72991                 if (labelOffsets[label] === operationIndex) {
72992                     flushLabel();
72993                     if (labelNumbers === undefined) {
72994                         labelNumbers = [];
72995                     }
72996                     if (labelNumbers[labelNumber] === undefined) {
72997                         labelNumbers[labelNumber] = [label];
72998                     }
72999                     else {
73000                         labelNumbers[labelNumber].push(label);
73001                     }
73002                 }
73003             }
73004         }
73005         function updateLabelExpressions() {
73006             if (labelExpressions !== undefined && labelNumbers !== undefined) {
73007                 for (var labelNumber_1 = 0; labelNumber_1 < labelNumbers.length; labelNumber_1++) {
73008                     var labels = labelNumbers[labelNumber_1];
73009                     if (labels !== undefined) {
73010                         for (var _i = 0, labels_1 = labels; _i < labels_1.length; _i++) {
73011                             var label = labels_1[_i];
73012                             var expressions = labelExpressions[label];
73013                             if (expressions !== undefined) {
73014                                 for (var _a = 0, expressions_1 = expressions; _a < expressions_1.length; _a++) {
73015                                     var expression = expressions_1[_a];
73016                                     expression.text = String(labelNumber_1);
73017                                 }
73018                             }
73019                         }
73020                     }
73021                 }
73022             }
73023         }
73024         function tryEnterOrLeaveBlock(operationIndex) {
73025             if (blocks) {
73026                 for (; blockIndex < blockActions.length && blockOffsets[blockIndex] <= operationIndex; blockIndex++) {
73027                     var block = blocks[blockIndex];
73028                     var blockAction = blockActions[blockIndex];
73029                     switch (block.kind) {
73030                         case 0:
73031                             if (blockAction === 0) {
73032                                 if (!exceptionBlockStack) {
73033                                     exceptionBlockStack = [];
73034                                 }
73035                                 if (!statements) {
73036                                     statements = [];
73037                                 }
73038                                 exceptionBlockStack.push(currentExceptionBlock);
73039                                 currentExceptionBlock = block;
73040                             }
73041                             else if (blockAction === 1) {
73042                                 currentExceptionBlock = exceptionBlockStack.pop();
73043                             }
73044                             break;
73045                         case 1:
73046                             if (blockAction === 0) {
73047                                 if (!withBlockStack) {
73048                                     withBlockStack = [];
73049                                 }
73050                                 withBlockStack.push(block);
73051                             }
73052                             else if (blockAction === 1) {
73053                                 withBlockStack.pop();
73054                             }
73055                             break;
73056                     }
73057                 }
73058             }
73059         }
73060         function writeOperation(operationIndex) {
73061             tryEnterLabel(operationIndex);
73062             tryEnterOrLeaveBlock(operationIndex);
73063             if (lastOperationWasAbrupt) {
73064                 return;
73065             }
73066             lastOperationWasAbrupt = false;
73067             lastOperationWasCompletion = false;
73068             var opcode = operations[operationIndex];
73069             if (opcode === 0) {
73070                 return;
73071             }
73072             else if (opcode === 10) {
73073                 return writeEndfinally();
73074             }
73075             var args = operationArguments[operationIndex];
73076             if (opcode === 1) {
73077                 return writeStatement(args[0]);
73078             }
73079             var location = operationLocations[operationIndex];
73080             switch (opcode) {
73081                 case 2:
73082                     return writeAssign(args[0], args[1], location);
73083                 case 3:
73084                     return writeBreak(args[0], location);
73085                 case 4:
73086                     return writeBreakWhenTrue(args[0], args[1], location);
73087                 case 5:
73088                     return writeBreakWhenFalse(args[0], args[1], location);
73089                 case 6:
73090                     return writeYield(args[0], location);
73091                 case 7:
73092                     return writeYieldStar(args[0], location);
73093                 case 8:
73094                     return writeReturn(args[0], location);
73095                 case 9:
73096                     return writeThrow(args[0], location);
73097             }
73098         }
73099         function writeStatement(statement) {
73100             if (statement) {
73101                 if (!statements) {
73102                     statements = [statement];
73103                 }
73104                 else {
73105                     statements.push(statement);
73106                 }
73107             }
73108         }
73109         function writeAssign(left, right, operationLocation) {
73110             writeStatement(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(left, right)), operationLocation));
73111         }
73112         function writeThrow(expression, operationLocation) {
73113             lastOperationWasAbrupt = true;
73114             lastOperationWasCompletion = true;
73115             writeStatement(ts.setTextRange(ts.createThrow(expression), operationLocation));
73116         }
73117         function writeReturn(expression, operationLocation) {
73118             lastOperationWasAbrupt = true;
73119             lastOperationWasCompletion = true;
73120             writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression
73121                 ? [createInstruction(2), expression]
73122                 : [createInstruction(2)])), operationLocation), 384));
73123         }
73124         function writeBreak(label, operationLocation) {
73125             lastOperationWasAbrupt = true;
73126             writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([
73127                 createInstruction(3),
73128                 createLabel(label)
73129             ])), operationLocation), 384));
73130         }
73131         function writeBreakWhenTrue(label, condition, operationLocation) {
73132             writeStatement(ts.setEmitFlags(ts.createIf(condition, ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([
73133                 createInstruction(3),
73134                 createLabel(label)
73135             ])), operationLocation), 384)), 1));
73136         }
73137         function writeBreakWhenFalse(label, condition, operationLocation) {
73138             writeStatement(ts.setEmitFlags(ts.createIf(ts.createLogicalNot(condition), ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([
73139                 createInstruction(3),
73140                 createLabel(label)
73141             ])), operationLocation), 384)), 1));
73142         }
73143         function writeYield(expression, operationLocation) {
73144             lastOperationWasAbrupt = true;
73145             writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression
73146                 ? [createInstruction(4), expression]
73147                 : [createInstruction(4)])), operationLocation), 384));
73148         }
73149         function writeYieldStar(expression, operationLocation) {
73150             lastOperationWasAbrupt = true;
73151             writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([
73152                 createInstruction(5),
73153                 expression
73154             ])), operationLocation), 384));
73155         }
73156         function writeEndfinally() {
73157             lastOperationWasAbrupt = true;
73158             writeStatement(ts.createReturn(ts.createArrayLiteral([
73159                 createInstruction(7)
73160             ])));
73161         }
73162     }
73163     ts.transformGenerators = transformGenerators;
73164     function createGeneratorHelper(context, body) {
73165         context.requestEmitHelper(ts.generatorHelper);
73166         return ts.createCall(ts.getUnscopedHelperName("__generator"), undefined, [ts.createThis(), body]);
73167     }
73168     ts.generatorHelper = {
73169         name: "typescript:generator",
73170         importName: "__generator",
73171         scoped: false,
73172         priority: 6,
73173         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            };"
73174     };
73175 })(ts || (ts = {}));
73176 var ts;
73177 (function (ts) {
73178     function transformModule(context) {
73179         function getTransformModuleDelegate(moduleKind) {
73180             switch (moduleKind) {
73181                 case ts.ModuleKind.AMD: return transformAMDModule;
73182                 case ts.ModuleKind.UMD: return transformUMDModule;
73183                 default: return transformCommonJSModule;
73184             }
73185         }
73186         var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
73187         var compilerOptions = context.getCompilerOptions();
73188         var resolver = context.getEmitResolver();
73189         var host = context.getEmitHost();
73190         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
73191         var moduleKind = ts.getEmitModuleKind(compilerOptions);
73192         var previousOnSubstituteNode = context.onSubstituteNode;
73193         var previousOnEmitNode = context.onEmitNode;
73194         context.onSubstituteNode = onSubstituteNode;
73195         context.onEmitNode = onEmitNode;
73196         context.enableSubstitution(75);
73197         context.enableSubstitution(209);
73198         context.enableSubstitution(207);
73199         context.enableSubstitution(208);
73200         context.enableSubstitution(282);
73201         context.enableEmitNotification(290);
73202         var moduleInfoMap = [];
73203         var deferredExports = [];
73204         var currentSourceFile;
73205         var currentModuleInfo;
73206         var noSubstitution;
73207         var needUMDDynamicImportHelper;
73208         return ts.chainBundle(transformSourceFile);
73209         function transformSourceFile(node) {
73210             if (node.isDeclarationFile ||
73211                 !(ts.isEffectiveExternalModule(node, compilerOptions) ||
73212                     node.transformFlags & 2097152 ||
73213                     (ts.isJsonSourceFile(node) && ts.hasJsonModuleEmitEnabled(compilerOptions) && (compilerOptions.out || compilerOptions.outFile)))) {
73214                 return node;
73215             }
73216             currentSourceFile = node;
73217             currentModuleInfo = ts.collectExternalModuleInfo(node, resolver, compilerOptions);
73218             moduleInfoMap[ts.getOriginalNodeId(node)] = currentModuleInfo;
73219             var transformModule = getTransformModuleDelegate(moduleKind);
73220             var updated = transformModule(node);
73221             currentSourceFile = undefined;
73222             currentModuleInfo = undefined;
73223             needUMDDynamicImportHelper = false;
73224             return ts.aggregateTransformFlags(updated);
73225         }
73226         function shouldEmitUnderscoreUnderscoreESModule() {
73227             if (!currentModuleInfo.exportEquals && ts.isExternalModule(currentSourceFile)) {
73228                 return true;
73229             }
73230             return false;
73231         }
73232         function transformCommonJSModule(node) {
73233             startLexicalEnvironment();
73234             var statements = [];
73235             var ensureUseStrict = ts.getStrictOptionValue(compilerOptions, "alwaysStrict") || (!compilerOptions.noImplicitUseStrict && ts.isExternalModule(currentSourceFile));
73236             var statementOffset = ts.addPrologue(statements, node.statements, ensureUseStrict && !ts.isJsonSourceFile(node), sourceElementVisitor);
73237             if (shouldEmitUnderscoreUnderscoreESModule()) {
73238                 ts.append(statements, createUnderscoreUnderscoreESModule());
73239             }
73240             if (ts.length(currentModuleInfo.exportedNames)) {
73241                 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())));
73242             }
73243             ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement));
73244             ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset));
73245             addExportEqualsIfNeeded(statements, false);
73246             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
73247             var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements));
73248             ts.addEmitHelpers(updated, context.readEmitHelpers());
73249             return updated;
73250         }
73251         function transformAMDModule(node) {
73252             var define = ts.createIdentifier("define");
73253             var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions);
73254             var jsonSourceFile = ts.isJsonSourceFile(node) && node;
73255             var _a = collectAsynchronousDependencies(node, true), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames;
73256             var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([
73257                 ts.createExpressionStatement(ts.createCall(define, undefined, __spreadArrays((moduleName ? [moduleName] : []), [
73258                     ts.createArrayLiteral(jsonSourceFile ? ts.emptyArray : __spreadArrays([
73259                         ts.createLiteral("require"),
73260                         ts.createLiteral("exports")
73261                     ], aliasedModuleNames, unaliasedModuleNames)),
73262                     jsonSourceFile ?
73263                         jsonSourceFile.statements.length ? jsonSourceFile.statements[0].expression : ts.createObjectLiteral() :
73264                         ts.createFunctionExpression(undefined, undefined, undefined, undefined, __spreadArrays([
73265                             ts.createParameter(undefined, undefined, undefined, "require"),
73266                             ts.createParameter(undefined, undefined, undefined, "exports")
73267                         ], importAliasNames), undefined, transformAsynchronousModuleBody(node))
73268                 ])))
73269             ]), node.statements));
73270             ts.addEmitHelpers(updated, context.readEmitHelpers());
73271             return updated;
73272         }
73273         function transformUMDModule(node) {
73274             var _a = collectAsynchronousDependencies(node, false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames;
73275             var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions);
73276             var umdHeader = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, "factory")], undefined, ts.setTextRange(ts.createBlock([
73277                 ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("module"), "object"), ts.createTypeCheck(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), "object")), ts.createBlock([
73278                     ts.createVariableStatement(undefined, [
73279                         ts.createVariableDeclaration("v", undefined, ts.createCall(ts.createIdentifier("factory"), undefined, [
73280                             ts.createIdentifier("require"),
73281                             ts.createIdentifier("exports")
73282                         ]))
73283                     ]),
73284                     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)
73285                 ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([
73286                     ts.createExpressionStatement(ts.createCall(ts.createIdentifier("define"), undefined, __spreadArrays((moduleName ? [moduleName] : []), [
73287                         ts.createArrayLiteral(__spreadArrays([
73288                             ts.createLiteral("require"),
73289                             ts.createLiteral("exports")
73290                         ], aliasedModuleNames, unaliasedModuleNames)),
73291                         ts.createIdentifier("factory")
73292                     ])))
73293                 ])))
73294             ], true), undefined));
73295             var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([
73296                 ts.createExpressionStatement(ts.createCall(umdHeader, undefined, [
73297                     ts.createFunctionExpression(undefined, undefined, undefined, undefined, __spreadArrays([
73298                         ts.createParameter(undefined, undefined, undefined, "require"),
73299                         ts.createParameter(undefined, undefined, undefined, "exports")
73300                     ], importAliasNames), undefined, transformAsynchronousModuleBody(node))
73301                 ]))
73302             ]), node.statements));
73303             ts.addEmitHelpers(updated, context.readEmitHelpers());
73304             return updated;
73305         }
73306         function collectAsynchronousDependencies(node, includeNonAmdDependencies) {
73307             var aliasedModuleNames = [];
73308             var unaliasedModuleNames = [];
73309             var importAliasNames = [];
73310             for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) {
73311                 var amdDependency = _a[_i];
73312                 if (amdDependency.name) {
73313                     aliasedModuleNames.push(ts.createLiteral(amdDependency.path));
73314                     importAliasNames.push(ts.createParameter(undefined, undefined, undefined, amdDependency.name));
73315                 }
73316                 else {
73317                     unaliasedModuleNames.push(ts.createLiteral(amdDependency.path));
73318                 }
73319             }
73320             for (var _b = 0, _c = currentModuleInfo.externalImports; _b < _c.length; _b++) {
73321                 var importNode = _c[_b];
73322                 var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions);
73323                 var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile);
73324                 if (externalModuleName) {
73325                     if (includeNonAmdDependencies && importAliasName) {
73326                         ts.setEmitFlags(importAliasName, 4);
73327                         aliasedModuleNames.push(externalModuleName);
73328                         importAliasNames.push(ts.createParameter(undefined, undefined, undefined, importAliasName));
73329                     }
73330                     else {
73331                         unaliasedModuleNames.push(externalModuleName);
73332                     }
73333                 }
73334             }
73335             return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames };
73336         }
73337         function getAMDImportExpressionForImport(node) {
73338             if (ts.isImportEqualsDeclaration(node) || ts.isExportDeclaration(node) || !ts.getExternalModuleNameLiteral(node, currentSourceFile, host, resolver, compilerOptions)) {
73339                 return undefined;
73340             }
73341             var name = ts.getLocalNameForExternalImport(node, currentSourceFile);
73342             var expr = getHelperExpressionForImport(node, name);
73343             if (expr === name) {
73344                 return undefined;
73345             }
73346             return ts.createExpressionStatement(ts.createAssignment(name, expr));
73347         }
73348         function transformAsynchronousModuleBody(node) {
73349             startLexicalEnvironment();
73350             var statements = [];
73351             var statementOffset = ts.addPrologue(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor);
73352             if (shouldEmitUnderscoreUnderscoreESModule()) {
73353                 ts.append(statements, createUnderscoreUnderscoreESModule());
73354             }
73355             if (ts.length(currentModuleInfo.exportedNames)) {
73356                 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())));
73357             }
73358             ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement));
73359             if (moduleKind === ts.ModuleKind.AMD) {
73360                 ts.addRange(statements, ts.mapDefined(currentModuleInfo.externalImports, getAMDImportExpressionForImport));
73361             }
73362             ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset));
73363             addExportEqualsIfNeeded(statements, true);
73364             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
73365             var body = ts.createBlock(statements, true);
73366             if (needUMDDynamicImportHelper) {
73367                 ts.addEmitHelper(body, dynamicImportUMDHelper);
73368             }
73369             return body;
73370         }
73371         function addExportEqualsIfNeeded(statements, emitAsReturn) {
73372             if (currentModuleInfo.exportEquals) {
73373                 var expressionResult = ts.visitNode(currentModuleInfo.exportEquals.expression, moduleExpressionElementVisitor);
73374                 if (expressionResult) {
73375                     if (emitAsReturn) {
73376                         var statement = ts.createReturn(expressionResult);
73377                         ts.setTextRange(statement, currentModuleInfo.exportEquals);
73378                         ts.setEmitFlags(statement, 384 | 1536);
73379                         statements.push(statement);
73380                     }
73381                     else {
73382                         var statement = ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), expressionResult));
73383                         ts.setTextRange(statement, currentModuleInfo.exportEquals);
73384                         ts.setEmitFlags(statement, 1536);
73385                         statements.push(statement);
73386                     }
73387                 }
73388             }
73389         }
73390         function sourceElementVisitor(node) {
73391             switch (node.kind) {
73392                 case 254:
73393                     return visitImportDeclaration(node);
73394                 case 253:
73395                     return visitImportEqualsDeclaration(node);
73396                 case 260:
73397                     return visitExportDeclaration(node);
73398                 case 259:
73399                     return visitExportAssignment(node);
73400                 case 225:
73401                     return visitVariableStatement(node);
73402                 case 244:
73403                     return visitFunctionDeclaration(node);
73404                 case 245:
73405                     return visitClassDeclaration(node);
73406                 case 328:
73407                     return visitMergeDeclarationMarker(node);
73408                 case 329:
73409                     return visitEndOfDeclarationMarker(node);
73410                 default:
73411                     return ts.visitEachChild(node, moduleExpressionElementVisitor, context);
73412             }
73413         }
73414         function moduleExpressionElementVisitor(node) {
73415             if (!(node.transformFlags & 2097152) && !(node.transformFlags & 1024)) {
73416                 return node;
73417             }
73418             if (ts.isImportCall(node)) {
73419                 return visitImportCallExpression(node);
73420             }
73421             else if (ts.isDestructuringAssignment(node)) {
73422                 return visitDestructuringAssignment(node);
73423             }
73424             else {
73425                 return ts.visitEachChild(node, moduleExpressionElementVisitor, context);
73426             }
73427         }
73428         function destructuringNeedsFlattening(node) {
73429             if (ts.isObjectLiteralExpression(node)) {
73430                 for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
73431                     var elem = _a[_i];
73432                     switch (elem.kind) {
73433                         case 281:
73434                             if (destructuringNeedsFlattening(elem.initializer)) {
73435                                 return true;
73436                             }
73437                             break;
73438                         case 282:
73439                             if (destructuringNeedsFlattening(elem.name)) {
73440                                 return true;
73441                             }
73442                             break;
73443                         case 283:
73444                             if (destructuringNeedsFlattening(elem.expression)) {
73445                                 return true;
73446                             }
73447                             break;
73448                         case 161:
73449                         case 163:
73450                         case 164:
73451                             return false;
73452                         default: ts.Debug.assertNever(elem, "Unhandled object member kind");
73453                     }
73454                 }
73455             }
73456             else if (ts.isArrayLiteralExpression(node)) {
73457                 for (var _b = 0, _c = node.elements; _b < _c.length; _b++) {
73458                     var elem = _c[_b];
73459                     if (ts.isSpreadElement(elem)) {
73460                         if (destructuringNeedsFlattening(elem.expression)) {
73461                             return true;
73462                         }
73463                     }
73464                     else if (destructuringNeedsFlattening(elem)) {
73465                         return true;
73466                     }
73467                 }
73468             }
73469             else if (ts.isIdentifier(node)) {
73470                 return ts.length(getExports(node)) > (ts.isExportName(node) ? 1 : 0);
73471             }
73472             return false;
73473         }
73474         function visitDestructuringAssignment(node) {
73475             if (destructuringNeedsFlattening(node.left)) {
73476                 return ts.flattenDestructuringAssignment(node, moduleExpressionElementVisitor, context, 0, false, createAllExportExpressions);
73477             }
73478             return ts.visitEachChild(node, moduleExpressionElementVisitor, context);
73479         }
73480         function visitImportCallExpression(node) {
73481             var argument = ts.visitNode(ts.firstOrUndefined(node.arguments), moduleExpressionElementVisitor);
73482             var containsLexicalThis = !!(node.transformFlags & 4096);
73483             switch (compilerOptions.module) {
73484                 case ts.ModuleKind.AMD:
73485                     return createImportCallExpressionAMD(argument, containsLexicalThis);
73486                 case ts.ModuleKind.UMD:
73487                     return createImportCallExpressionUMD(argument, containsLexicalThis);
73488                 case ts.ModuleKind.CommonJS:
73489                 default:
73490                     return createImportCallExpressionCommonJS(argument, containsLexicalThis);
73491             }
73492         }
73493         function createImportCallExpressionUMD(arg, containsLexicalThis) {
73494             needUMDDynamicImportHelper = true;
73495             if (ts.isSimpleCopiableExpression(arg)) {
73496                 var argClone = ts.isGeneratedIdentifier(arg) ? arg : ts.isStringLiteral(arg) ? ts.createLiteral(arg) : ts.setEmitFlags(ts.setTextRange(ts.getSynthesizedClone(arg), arg), 1536);
73497                 return ts.createConditional(ts.createIdentifier("__syncRequire"), createImportCallExpressionCommonJS(arg, containsLexicalThis), createImportCallExpressionAMD(argClone, containsLexicalThis));
73498             }
73499             else {
73500                 var temp = ts.createTempVariable(hoistVariableDeclaration);
73501                 return ts.createComma(ts.createAssignment(temp, arg), ts.createConditional(ts.createIdentifier("__syncRequire"), createImportCallExpressionCommonJS(temp, containsLexicalThis), createImportCallExpressionAMD(temp, containsLexicalThis)));
73502             }
73503         }
73504         function createImportCallExpressionAMD(arg, containsLexicalThis) {
73505             var resolve = ts.createUniqueName("resolve");
73506             var reject = ts.createUniqueName("reject");
73507             var parameters = [
73508                 ts.createParameter(undefined, undefined, undefined, resolve),
73509                 ts.createParameter(undefined, undefined, undefined, reject)
73510             ];
73511             var body = ts.createBlock([
73512                 ts.createExpressionStatement(ts.createCall(ts.createIdentifier("require"), undefined, [ts.createArrayLiteral([arg || ts.createOmittedExpression()]), resolve, reject]))
73513             ]);
73514             var func;
73515             if (languageVersion >= 2) {
73516                 func = ts.createArrowFunction(undefined, undefined, parameters, undefined, undefined, body);
73517             }
73518             else {
73519                 func = ts.createFunctionExpression(undefined, undefined, undefined, undefined, parameters, undefined, body);
73520                 if (containsLexicalThis) {
73521                     ts.setEmitFlags(func, 8);
73522                 }
73523             }
73524             var promise = ts.createNew(ts.createIdentifier("Promise"), undefined, [func]);
73525             if (compilerOptions.esModuleInterop) {
73526                 context.requestEmitHelper(ts.importStarHelper);
73527                 return ts.createCall(ts.createPropertyAccess(promise, ts.createIdentifier("then")), undefined, [ts.getUnscopedHelperName("__importStar")]);
73528             }
73529             return promise;
73530         }
73531         function createImportCallExpressionCommonJS(arg, containsLexicalThis) {
73532             var promiseResolveCall = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Promise"), "resolve"), undefined, []);
73533             var requireCall = ts.createCall(ts.createIdentifier("require"), undefined, arg ? [arg] : []);
73534             if (compilerOptions.esModuleInterop) {
73535                 context.requestEmitHelper(ts.importStarHelper);
73536                 requireCall = ts.createCall(ts.getUnscopedHelperName("__importStar"), undefined, [requireCall]);
73537             }
73538             var func;
73539             if (languageVersion >= 2) {
73540                 func = ts.createArrowFunction(undefined, undefined, [], undefined, undefined, requireCall);
73541             }
73542             else {
73543                 func = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, ts.createBlock([ts.createReturn(requireCall)]));
73544                 if (containsLexicalThis) {
73545                     ts.setEmitFlags(func, 8);
73546                 }
73547             }
73548             return ts.createCall(ts.createPropertyAccess(promiseResolveCall, "then"), undefined, [func]);
73549         }
73550         function getHelperExpressionForExport(node, innerExpr) {
73551             if (!compilerOptions.esModuleInterop || ts.getEmitFlags(node) & 67108864) {
73552                 return innerExpr;
73553             }
73554             if (ts.getExportNeedsImportStarHelper(node)) {
73555                 context.requestEmitHelper(ts.importStarHelper);
73556                 return ts.createCall(ts.getUnscopedHelperName("__importStar"), undefined, [innerExpr]);
73557             }
73558             return innerExpr;
73559         }
73560         function getHelperExpressionForImport(node, innerExpr) {
73561             if (!compilerOptions.esModuleInterop || ts.getEmitFlags(node) & 67108864) {
73562                 return innerExpr;
73563             }
73564             if (ts.getImportNeedsImportStarHelper(node)) {
73565                 context.requestEmitHelper(ts.importStarHelper);
73566                 return ts.createCall(ts.getUnscopedHelperName("__importStar"), undefined, [innerExpr]);
73567             }
73568             if (ts.getImportNeedsImportDefaultHelper(node)) {
73569                 context.requestEmitHelper(ts.importDefaultHelper);
73570                 return ts.createCall(ts.getUnscopedHelperName("__importDefault"), undefined, [innerExpr]);
73571             }
73572             return innerExpr;
73573         }
73574         function visitImportDeclaration(node) {
73575             var statements;
73576             var namespaceDeclaration = ts.getNamespaceDeclarationNode(node);
73577             if (moduleKind !== ts.ModuleKind.AMD) {
73578                 if (!node.importClause) {
73579                     return ts.setOriginalNode(ts.setTextRange(ts.createExpressionStatement(createRequireCall(node)), node), node);
73580                 }
73581                 else {
73582                     var variables = [];
73583                     if (namespaceDeclaration && !ts.isDefaultImport(node)) {
73584                         variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, getHelperExpressionForImport(node, createRequireCall(node))));
73585                     }
73586                     else {
73587                         variables.push(ts.createVariableDeclaration(ts.getGeneratedNameForNode(node), undefined, getHelperExpressionForImport(node, createRequireCall(node))));
73588                         if (namespaceDeclaration && ts.isDefaultImport(node)) {
73589                             variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node)));
73590                         }
73591                     }
73592                     statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(variables, languageVersion >= 2 ? 2 : 0)), node), node));
73593                 }
73594             }
73595             else if (namespaceDeclaration && ts.isDefaultImport(node)) {
73596                 statements = ts.append(statements, ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
73597                     ts.setOriginalNode(ts.setTextRange(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node)), node), node)
73598                 ], languageVersion >= 2 ? 2 : 0)));
73599             }
73600             if (hasAssociatedEndOfDeclarationMarker(node)) {
73601                 var id = ts.getOriginalNodeId(node);
73602                 deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node);
73603             }
73604             else {
73605                 statements = appendExportsOfImportDeclaration(statements, node);
73606             }
73607             return ts.singleOrMany(statements);
73608         }
73609         function createRequireCall(importNode) {
73610             var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions);
73611             var args = [];
73612             if (moduleName) {
73613                 args.push(moduleName);
73614             }
73615             return ts.createCall(ts.createIdentifier("require"), undefined, args);
73616         }
73617         function visitImportEqualsDeclaration(node) {
73618             ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer.");
73619             var statements;
73620             if (moduleKind !== ts.ModuleKind.AMD) {
73621                 if (ts.hasModifier(node, 1)) {
73622                     statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createExpressionStatement(createExportExpression(node.name, createRequireCall(node))), node), node));
73623                 }
73624                 else {
73625                     statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
73626                         ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), undefined, createRequireCall(node))
73627                     ], languageVersion >= 2 ? 2 : 0)), node), node));
73628                 }
73629             }
73630             else {
73631                 if (ts.hasModifier(node, 1)) {
73632                     statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createExpressionStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node))), node), node));
73633                 }
73634             }
73635             if (hasAssociatedEndOfDeclarationMarker(node)) {
73636                 var id = ts.getOriginalNodeId(node);
73637                 deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node);
73638             }
73639             else {
73640                 statements = appendExportsOfImportEqualsDeclaration(statements, node);
73641             }
73642             return ts.singleOrMany(statements);
73643         }
73644         function visitExportDeclaration(node) {
73645             if (!node.moduleSpecifier) {
73646                 return undefined;
73647             }
73648             var generatedName = ts.getGeneratedNameForNode(node);
73649             if (node.exportClause && ts.isNamedExports(node.exportClause)) {
73650                 var statements = [];
73651                 if (moduleKind !== ts.ModuleKind.AMD) {
73652                     statements.push(ts.setOriginalNode(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
73653                         ts.createVariableDeclaration(generatedName, undefined, createRequireCall(node))
73654                     ])), node), node));
73655                 }
73656                 for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) {
73657                     var specifier = _a[_i];
73658                     if (languageVersion === 0) {
73659                         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));
73660                     }
73661                     else {
73662                         var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name);
73663                         statements.push(ts.setOriginalNode(ts.setTextRange(ts.createExpressionStatement(createExportExpression(ts.getExportName(specifier), exportedValue, undefined, true)), specifier), specifier));
73664                     }
73665                 }
73666                 return ts.singleOrMany(statements);
73667             }
73668             else if (node.exportClause) {
73669                 var statements = [];
73670                 statements.push(ts.setOriginalNode(ts.setTextRange(ts.createExpressionStatement(createExportExpression(ts.getSynthesizedClone(node.exportClause.name), moduleKind !== ts.ModuleKind.AMD ?
73671                     getHelperExpressionForExport(node, createRequireCall(node)) :
73672                     ts.createIdentifier(ts.idText(node.exportClause.name)))), node), node));
73673                 return ts.singleOrMany(statements);
73674             }
73675             else {
73676                 return ts.setOriginalNode(ts.setTextRange(ts.createExpressionStatement(createExportStarHelper(context, moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) : generatedName)), node), node);
73677             }
73678         }
73679         function visitExportAssignment(node) {
73680             if (node.isExportEquals) {
73681                 return undefined;
73682             }
73683             var statements;
73684             var original = node.original;
73685             if (original && hasAssociatedEndOfDeclarationMarker(original)) {
73686                 var id = ts.getOriginalNodeId(node);
73687                 deferredExports[id] = appendExportStatement(deferredExports[id], ts.createIdentifier("default"), ts.visitNode(node.expression, moduleExpressionElementVisitor), node, true);
73688             }
73689             else {
73690                 statements = appendExportStatement(statements, ts.createIdentifier("default"), ts.visitNode(node.expression, moduleExpressionElementVisitor), node, true);
73691             }
73692             return ts.singleOrMany(statements);
73693         }
73694         function visitFunctionDeclaration(node) {
73695             var statements;
73696             if (ts.hasModifier(node, 1)) {
73697                 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));
73698             }
73699             else {
73700                 statements = ts.append(statements, ts.visitEachChild(node, moduleExpressionElementVisitor, context));
73701             }
73702             if (hasAssociatedEndOfDeclarationMarker(node)) {
73703                 var id = ts.getOriginalNodeId(node);
73704                 deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node);
73705             }
73706             else {
73707                 statements = appendExportsOfHoistedDeclaration(statements, node);
73708             }
73709             return ts.singleOrMany(statements);
73710         }
73711         function visitClassDeclaration(node) {
73712             var statements;
73713             if (ts.hasModifier(node, 1)) {
73714                 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));
73715             }
73716             else {
73717                 statements = ts.append(statements, ts.visitEachChild(node, moduleExpressionElementVisitor, context));
73718             }
73719             if (hasAssociatedEndOfDeclarationMarker(node)) {
73720                 var id = ts.getOriginalNodeId(node);
73721                 deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node);
73722             }
73723             else {
73724                 statements = appendExportsOfHoistedDeclaration(statements, node);
73725             }
73726             return ts.singleOrMany(statements);
73727         }
73728         function visitVariableStatement(node) {
73729             var statements;
73730             var variables;
73731             var expressions;
73732             if (ts.hasModifier(node, 1)) {
73733                 var modifiers = void 0;
73734                 for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
73735                     var variable = _a[_i];
73736                     if (ts.isIdentifier(variable.name) && ts.isLocalName(variable.name)) {
73737                         if (!modifiers) {
73738                             modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier);
73739                         }
73740                         variables = ts.append(variables, variable);
73741                     }
73742                     else if (variable.initializer) {
73743                         expressions = ts.append(expressions, transformInitializedVariable(variable));
73744                     }
73745                 }
73746                 if (variables) {
73747                     statements = ts.append(statements, ts.updateVariableStatement(node, modifiers, ts.updateVariableDeclarationList(node.declarationList, variables)));
73748                 }
73749                 if (expressions) {
73750                     statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(expressions)), node), node));
73751                 }
73752             }
73753             else {
73754                 statements = ts.append(statements, ts.visitEachChild(node, moduleExpressionElementVisitor, context));
73755             }
73756             if (hasAssociatedEndOfDeclarationMarker(node)) {
73757                 var id = ts.getOriginalNodeId(node);
73758                 deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node);
73759             }
73760             else {
73761                 statements = appendExportsOfVariableStatement(statements, node);
73762             }
73763             return ts.singleOrMany(statements);
73764         }
73765         function createAllExportExpressions(name, value, location) {
73766             var exportedNames = getExports(name);
73767             if (exportedNames) {
73768                 var expression = ts.isExportName(name) ? value : ts.createAssignment(name, value);
73769                 for (var _i = 0, exportedNames_1 = exportedNames; _i < exportedNames_1.length; _i++) {
73770                     var exportName = exportedNames_1[_i];
73771                     ts.setEmitFlags(expression, 4);
73772                     expression = createExportExpression(exportName, expression, location);
73773                 }
73774                 return expression;
73775             }
73776             return ts.createAssignment(name, value);
73777         }
73778         function transformInitializedVariable(node) {
73779             if (ts.isBindingPattern(node.name)) {
73780                 return ts.flattenDestructuringAssignment(ts.visitNode(node, moduleExpressionElementVisitor), undefined, context, 0, false, createAllExportExpressions);
73781             }
73782             else {
73783                 return ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), node.name), node.name), node.initializer ? ts.visitNode(node.initializer, moduleExpressionElementVisitor) : ts.createVoidZero());
73784             }
73785         }
73786         function visitMergeDeclarationMarker(node) {
73787             if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 225) {
73788                 var id = ts.getOriginalNodeId(node);
73789                 deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original);
73790             }
73791             return node;
73792         }
73793         function hasAssociatedEndOfDeclarationMarker(node) {
73794             return (ts.getEmitFlags(node) & 4194304) !== 0;
73795         }
73796         function visitEndOfDeclarationMarker(node) {
73797             var id = ts.getOriginalNodeId(node);
73798             var statements = deferredExports[id];
73799             if (statements) {
73800                 delete deferredExports[id];
73801                 return ts.append(statements, node);
73802             }
73803             return node;
73804         }
73805         function appendExportsOfImportDeclaration(statements, decl) {
73806             if (currentModuleInfo.exportEquals) {
73807                 return statements;
73808             }
73809             var importClause = decl.importClause;
73810             if (!importClause) {
73811                 return statements;
73812             }
73813             if (importClause.name) {
73814                 statements = appendExportsOfDeclaration(statements, importClause);
73815             }
73816             var namedBindings = importClause.namedBindings;
73817             if (namedBindings) {
73818                 switch (namedBindings.kind) {
73819                     case 256:
73820                         statements = appendExportsOfDeclaration(statements, namedBindings);
73821                         break;
73822                     case 257:
73823                         for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) {
73824                             var importBinding = _a[_i];
73825                             statements = appendExportsOfDeclaration(statements, importBinding, true);
73826                         }
73827                         break;
73828                 }
73829             }
73830             return statements;
73831         }
73832         function appendExportsOfImportEqualsDeclaration(statements, decl) {
73833             if (currentModuleInfo.exportEquals) {
73834                 return statements;
73835             }
73836             return appendExportsOfDeclaration(statements, decl);
73837         }
73838         function appendExportsOfVariableStatement(statements, node) {
73839             if (currentModuleInfo.exportEquals) {
73840                 return statements;
73841             }
73842             for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
73843                 var decl = _a[_i];
73844                 statements = appendExportsOfBindingElement(statements, decl);
73845             }
73846             return statements;
73847         }
73848         function appendExportsOfBindingElement(statements, decl) {
73849             if (currentModuleInfo.exportEquals) {
73850                 return statements;
73851             }
73852             if (ts.isBindingPattern(decl.name)) {
73853                 for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) {
73854                     var element = _a[_i];
73855                     if (!ts.isOmittedExpression(element)) {
73856                         statements = appendExportsOfBindingElement(statements, element);
73857                     }
73858                 }
73859             }
73860             else if (!ts.isGeneratedIdentifier(decl.name)) {
73861                 statements = appendExportsOfDeclaration(statements, decl);
73862             }
73863             return statements;
73864         }
73865         function appendExportsOfHoistedDeclaration(statements, decl) {
73866             if (currentModuleInfo.exportEquals) {
73867                 return statements;
73868             }
73869             if (ts.hasModifier(decl, 1)) {
73870                 var exportName = ts.hasModifier(decl, 512) ? ts.createIdentifier("default") : ts.getDeclarationName(decl);
73871                 statements = appendExportStatement(statements, exportName, ts.getLocalName(decl), decl);
73872             }
73873             if (decl.name) {
73874                 statements = appendExportsOfDeclaration(statements, decl);
73875             }
73876             return statements;
73877         }
73878         function appendExportsOfDeclaration(statements, decl, liveBinding) {
73879             var name = ts.getDeclarationName(decl);
73880             var exportSpecifiers = currentModuleInfo.exportSpecifiers.get(ts.idText(name));
73881             if (exportSpecifiers) {
73882                 for (var _i = 0, exportSpecifiers_1 = exportSpecifiers; _i < exportSpecifiers_1.length; _i++) {
73883                     var exportSpecifier = exportSpecifiers_1[_i];
73884                     statements = appendExportStatement(statements, exportSpecifier.name, name, exportSpecifier.name, undefined, liveBinding);
73885                 }
73886             }
73887             return statements;
73888         }
73889         function appendExportStatement(statements, exportName, expression, location, allowComments, liveBinding) {
73890             statements = ts.append(statements, createExportStatement(exportName, expression, location, allowComments, liveBinding));
73891             return statements;
73892         }
73893         function createUnderscoreUnderscoreESModule() {
73894             var statement;
73895             if (languageVersion === 0) {
73896                 statement = ts.createExpressionStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(true)));
73897             }
73898             else {
73899                 statement = ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [
73900                     ts.createIdentifier("exports"),
73901                     ts.createLiteral("__esModule"),
73902                     ts.createObjectLiteral([
73903                         ts.createPropertyAssignment("value", ts.createLiteral(true))
73904                     ])
73905                 ]));
73906             }
73907             ts.setEmitFlags(statement, 1048576);
73908             return statement;
73909         }
73910         function createExportStatement(name, value, location, allowComments, liveBinding) {
73911             var statement = ts.setTextRange(ts.createExpressionStatement(createExportExpression(name, value, undefined, liveBinding)), location);
73912             ts.startOnNewLine(statement);
73913             if (!allowComments) {
73914                 ts.setEmitFlags(statement, 1536);
73915             }
73916             return statement;
73917         }
73918         function createExportExpression(name, value, location, liveBinding) {
73919             return ts.setTextRange(liveBinding && languageVersion !== 0 ? ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [
73920                 ts.createIdentifier("exports"),
73921                 ts.createLiteral(name),
73922                 ts.createObjectLiteral([
73923                     ts.createPropertyAssignment("enumerable", ts.createLiteral(true)),
73924                     ts.createPropertyAssignment("get", ts.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, ts.createBlock([ts.createReturn(value)])))
73925                 ])
73926             ]) : ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value), location);
73927         }
73928         function modifierVisitor(node) {
73929             switch (node.kind) {
73930                 case 89:
73931                 case 84:
73932                     return undefined;
73933             }
73934             return node;
73935         }
73936         function onEmitNode(hint, node, emitCallback) {
73937             if (node.kind === 290) {
73938                 currentSourceFile = node;
73939                 currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)];
73940                 noSubstitution = [];
73941                 previousOnEmitNode(hint, node, emitCallback);
73942                 currentSourceFile = undefined;
73943                 currentModuleInfo = undefined;
73944                 noSubstitution = undefined;
73945             }
73946             else {
73947                 previousOnEmitNode(hint, node, emitCallback);
73948             }
73949         }
73950         function onSubstituteNode(hint, node) {
73951             node = previousOnSubstituteNode(hint, node);
73952             if (node.id && noSubstitution[node.id]) {
73953                 return node;
73954             }
73955             if (hint === 1) {
73956                 return substituteExpression(node);
73957             }
73958             else if (ts.isShorthandPropertyAssignment(node)) {
73959                 return substituteShorthandPropertyAssignment(node);
73960             }
73961             return node;
73962         }
73963         function substituteShorthandPropertyAssignment(node) {
73964             var name = node.name;
73965             var exportedOrImportedName = substituteExpressionIdentifier(name);
73966             if (exportedOrImportedName !== name) {
73967                 if (node.objectAssignmentInitializer) {
73968                     var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer);
73969                     return ts.setTextRange(ts.createPropertyAssignment(name, initializer), node);
73970                 }
73971                 return ts.setTextRange(ts.createPropertyAssignment(name, exportedOrImportedName), node);
73972             }
73973             return node;
73974         }
73975         function substituteExpression(node) {
73976             switch (node.kind) {
73977                 case 75:
73978                     return substituteExpressionIdentifier(node);
73979                 case 209:
73980                     return substituteBinaryExpression(node);
73981                 case 208:
73982                 case 207:
73983                     return substituteUnaryExpression(node);
73984             }
73985             return node;
73986         }
73987         function substituteExpressionIdentifier(node) {
73988             if (ts.getEmitFlags(node) & 4096) {
73989                 var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile);
73990                 if (externalHelpersModuleName) {
73991                     return ts.createPropertyAccess(externalHelpersModuleName, node);
73992                 }
73993                 return node;
73994             }
73995             if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) {
73996                 var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node));
73997                 if (exportContainer && exportContainer.kind === 290) {
73998                     return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), node);
73999                 }
74000                 var importDeclaration = resolver.getReferencedImportDeclaration(node);
74001                 if (importDeclaration) {
74002                     if (ts.isImportClause(importDeclaration)) {
74003                         return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default")), node);
74004                     }
74005                     else if (ts.isImportSpecifier(importDeclaration)) {
74006                         var name = importDeclaration.propertyName || importDeclaration.name;
74007                         return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name)), node);
74008                     }
74009                 }
74010             }
74011             return node;
74012         }
74013         function substituteBinaryExpression(node) {
74014             if (ts.isAssignmentOperator(node.operatorToken.kind)
74015                 && ts.isIdentifier(node.left)
74016                 && !ts.isGeneratedIdentifier(node.left)
74017                 && !ts.isLocalName(node.left)
74018                 && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) {
74019                 var exportedNames = getExports(node.left);
74020                 if (exportedNames) {
74021                     var expression = node;
74022                     for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) {
74023                         var exportName = exportedNames_2[_i];
74024                         noSubstitution[ts.getNodeId(expression)] = true;
74025                         expression = createExportExpression(exportName, expression, node);
74026                     }
74027                     return expression;
74028                 }
74029             }
74030             return node;
74031         }
74032         function substituteUnaryExpression(node) {
74033             if ((node.operator === 45 || node.operator === 46)
74034                 && ts.isIdentifier(node.operand)
74035                 && !ts.isGeneratedIdentifier(node.operand)
74036                 && !ts.isLocalName(node.operand)
74037                 && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) {
74038                 var exportedNames = getExports(node.operand);
74039                 if (exportedNames) {
74040                     var expression = node.kind === 208
74041                         ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 45 ? 63 : 64), ts.createLiteral(1)), node)
74042                         : node;
74043                     for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) {
74044                         var exportName = exportedNames_3[_i];
74045                         noSubstitution[ts.getNodeId(expression)] = true;
74046                         expression = createExportExpression(exportName, expression);
74047                     }
74048                     return expression;
74049                 }
74050             }
74051             return node;
74052         }
74053         function getExports(name) {
74054             if (!ts.isGeneratedIdentifier(name)) {
74055                 var valueDeclaration = resolver.getReferencedImportDeclaration(name)
74056                     || resolver.getReferencedValueDeclaration(name);
74057                 if (valueDeclaration) {
74058                     return currentModuleInfo
74059                         && currentModuleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)];
74060                 }
74061             }
74062         }
74063     }
74064     ts.transformModule = transformModule;
74065     ts.createBindingHelper = {
74066         name: "typescript:commonjscreatebinding",
74067         importName: "__createBinding",
74068         scoped: false,
74069         priority: 1,
74070         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}));"
74071     };
74072     function createCreateBindingHelper(context, module, inputName, outputName) {
74073         context.requestEmitHelper(ts.createBindingHelper);
74074         return ts.createCall(ts.getUnscopedHelperName("__createBinding"), undefined, __spreadArrays([ts.createIdentifier("exports"), module, inputName], (outputName ? [outputName] : [])));
74075     }
74076     ts.setModuleDefaultHelper = {
74077         name: "typescript:commonjscreatevalue",
74078         importName: "__setModuleDefault",
74079         scoped: false,
74080         priority: 1,
74081         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});"
74082     };
74083     var exportStarHelper = {
74084         name: "typescript:export-star",
74085         importName: "__exportStar",
74086         scoped: false,
74087         dependencies: [ts.createBindingHelper],
74088         priority: 2,
74089         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            };"
74090     };
74091     function createExportStarHelper(context, module) {
74092         context.requestEmitHelper(exportStarHelper);
74093         return ts.createCall(ts.getUnscopedHelperName("__exportStar"), undefined, [module, ts.createIdentifier("exports")]);
74094     }
74095     var dynamicImportUMDHelper = {
74096         name: "typescript:dynamicimport-sync-require",
74097         scoped: true,
74098         text: "\n            var __syncRequire = typeof module === \"object\" && typeof module.exports === \"object\";"
74099     };
74100     ts.importStarHelper = {
74101         name: "typescript:commonjsimportstar",
74102         importName: "__importStar",
74103         scoped: false,
74104         dependencies: [ts.createBindingHelper, ts.setModuleDefaultHelper],
74105         priority: 2,
74106         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};"
74107     };
74108     ts.importDefaultHelper = {
74109         name: "typescript:commonjsimportdefault",
74110         importName: "__importDefault",
74111         scoped: false,
74112         text: "\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n    return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};"
74113     };
74114 })(ts || (ts = {}));
74115 var ts;
74116 (function (ts) {
74117     function transformSystemModule(context) {
74118         var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
74119         var compilerOptions = context.getCompilerOptions();
74120         var resolver = context.getEmitResolver();
74121         var host = context.getEmitHost();
74122         var previousOnSubstituteNode = context.onSubstituteNode;
74123         var previousOnEmitNode = context.onEmitNode;
74124         context.onSubstituteNode = onSubstituteNode;
74125         context.onEmitNode = onEmitNode;
74126         context.enableSubstitution(75);
74127         context.enableSubstitution(282);
74128         context.enableSubstitution(209);
74129         context.enableSubstitution(207);
74130         context.enableSubstitution(208);
74131         context.enableSubstitution(219);
74132         context.enableEmitNotification(290);
74133         var moduleInfoMap = [];
74134         var deferredExports = [];
74135         var exportFunctionsMap = [];
74136         var noSubstitutionMap = [];
74137         var contextObjectMap = [];
74138         var currentSourceFile;
74139         var moduleInfo;
74140         var exportFunction;
74141         var contextObject;
74142         var hoistedStatements;
74143         var enclosingBlockScopedContainer;
74144         var noSubstitution;
74145         return ts.chainBundle(transformSourceFile);
74146         function transformSourceFile(node) {
74147             if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 2097152)) {
74148                 return node;
74149             }
74150             var id = ts.getOriginalNodeId(node);
74151             currentSourceFile = node;
74152             enclosingBlockScopedContainer = node;
74153             moduleInfo = moduleInfoMap[id] = ts.collectExternalModuleInfo(node, resolver, compilerOptions);
74154             exportFunction = ts.createUniqueName("exports");
74155             exportFunctionsMap[id] = exportFunction;
74156             contextObject = contextObjectMap[id] = ts.createUniqueName("context");
74157             var dependencyGroups = collectDependencyGroups(moduleInfo.externalImports);
74158             var moduleBodyBlock = createSystemModuleBody(node, dependencyGroups);
74159             var moduleBodyFunction = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [
74160                 ts.createParameter(undefined, undefined, undefined, exportFunction),
74161                 ts.createParameter(undefined, undefined, undefined, contextObject)
74162             ], undefined, moduleBodyBlock);
74163             var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions);
74164             var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, function (dependencyGroup) { return dependencyGroup.name; }));
74165             var updated = ts.setEmitFlags(ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([
74166                 ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), undefined, moduleName
74167                     ? [moduleName, dependencies, moduleBodyFunction]
74168                     : [dependencies, moduleBodyFunction]))
74169             ]), node.statements)), 1024);
74170             if (!(compilerOptions.outFile || compilerOptions.out)) {
74171                 ts.moveEmitHelpers(updated, moduleBodyBlock, function (helper) { return !helper.scoped; });
74172             }
74173             if (noSubstitution) {
74174                 noSubstitutionMap[id] = noSubstitution;
74175                 noSubstitution = undefined;
74176             }
74177             currentSourceFile = undefined;
74178             moduleInfo = undefined;
74179             exportFunction = undefined;
74180             contextObject = undefined;
74181             hoistedStatements = undefined;
74182             enclosingBlockScopedContainer = undefined;
74183             return ts.aggregateTransformFlags(updated);
74184         }
74185         function collectDependencyGroups(externalImports) {
74186             var groupIndices = ts.createMap();
74187             var dependencyGroups = [];
74188             for (var _i = 0, externalImports_1 = externalImports; _i < externalImports_1.length; _i++) {
74189                 var externalImport = externalImports_1[_i];
74190                 var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions);
74191                 if (externalModuleName) {
74192                     var text = externalModuleName.text;
74193                     var groupIndex = groupIndices.get(text);
74194                     if (groupIndex !== undefined) {
74195                         dependencyGroups[groupIndex].externalImports.push(externalImport);
74196                     }
74197                     else {
74198                         groupIndices.set(text, dependencyGroups.length);
74199                         dependencyGroups.push({
74200                             name: externalModuleName,
74201                             externalImports: [externalImport]
74202                         });
74203                     }
74204                 }
74205             }
74206             return dependencyGroups;
74207         }
74208         function createSystemModuleBody(node, dependencyGroups) {
74209             var statements = [];
74210             startLexicalEnvironment();
74211             var ensureUseStrict = ts.getStrictOptionValue(compilerOptions, "alwaysStrict") || (!compilerOptions.noImplicitUseStrict && ts.isExternalModule(currentSourceFile));
74212             var statementOffset = ts.addPrologue(statements, node.statements, ensureUseStrict, sourceElementVisitor);
74213             statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
74214                 ts.createVariableDeclaration("__moduleName", undefined, ts.createLogicalAnd(contextObject, ts.createPropertyAccess(contextObject, "id")))
74215             ])));
74216             ts.visitNode(moduleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement);
74217             var executeStatements = ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset);
74218             ts.addRange(statements, hoistedStatements);
74219             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
74220             var exportStarFunction = addExportStarIfNeeded(statements);
74221             var modifiers = node.transformFlags & 524288 ?
74222                 ts.createModifiersFromModifierFlags(256) :
74223                 undefined;
74224             var moduleObject = ts.createObjectLiteral([
74225                 ts.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)),
74226                 ts.createPropertyAssignment("execute", ts.createFunctionExpression(modifiers, undefined, undefined, undefined, [], undefined, ts.createBlock(executeStatements, true)))
74227             ]);
74228             moduleObject.multiLine = true;
74229             statements.push(ts.createReturn(moduleObject));
74230             return ts.createBlock(statements, true);
74231         }
74232         function addExportStarIfNeeded(statements) {
74233             if (!moduleInfo.hasExportStarsToExportValues) {
74234                 return;
74235             }
74236             if (!moduleInfo.exportedNames && moduleInfo.exportSpecifiers.size === 0) {
74237                 var hasExportDeclarationWithExportClause = false;
74238                 for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) {
74239                     var externalImport = _a[_i];
74240                     if (externalImport.kind === 260 && externalImport.exportClause) {
74241                         hasExportDeclarationWithExportClause = true;
74242                         break;
74243                     }
74244                 }
74245                 if (!hasExportDeclarationWithExportClause) {
74246                     var exportStarFunction_1 = createExportStarFunction(undefined);
74247                     statements.push(exportStarFunction_1);
74248                     return exportStarFunction_1.name;
74249                 }
74250             }
74251             var exportedNames = [];
74252             if (moduleInfo.exportedNames) {
74253                 for (var _b = 0, _c = moduleInfo.exportedNames; _b < _c.length; _b++) {
74254                     var exportedLocalName = _c[_b];
74255                     if (exportedLocalName.escapedText === "default") {
74256                         continue;
74257                     }
74258                     exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName), ts.createTrue()));
74259                 }
74260             }
74261             for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) {
74262                 var externalImport = _e[_d];
74263                 if (externalImport.kind !== 260) {
74264                     continue;
74265                 }
74266                 if (!externalImport.exportClause) {
74267                     continue;
74268                 }
74269                 if (ts.isNamedExports(externalImport.exportClause)) {
74270                     for (var _f = 0, _g = externalImport.exportClause.elements; _f < _g.length; _f++) {
74271                         var element = _g[_f];
74272                         exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(ts.idText(element.name || element.propertyName)), ts.createTrue()));
74273                     }
74274                 }
74275                 else {
74276                     exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(ts.idText(externalImport.exportClause.name)), ts.createTrue()));
74277                 }
74278             }
74279             var exportedNamesStorageRef = ts.createUniqueName("exportedNames");
74280             statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
74281                 ts.createVariableDeclaration(exportedNamesStorageRef, undefined, ts.createObjectLiteral(exportedNames, true))
74282             ])));
74283             var exportStarFunction = createExportStarFunction(exportedNamesStorageRef);
74284             statements.push(exportStarFunction);
74285             return exportStarFunction.name;
74286         }
74287         function createExportStarFunction(localNames) {
74288             var exportStarFunction = ts.createUniqueName("exportStar");
74289             var m = ts.createIdentifier("m");
74290             var n = ts.createIdentifier("n");
74291             var exports = ts.createIdentifier("exports");
74292             var condition = ts.createStrictInequality(n, ts.createLiteral("default"));
74293             if (localNames) {
74294                 condition = ts.createLogicalAnd(condition, ts.createLogicalNot(ts.createCall(ts.createPropertyAccess(localNames, "hasOwnProperty"), undefined, [n])));
74295             }
74296             return ts.createFunctionDeclaration(undefined, undefined, undefined, exportStarFunction, undefined, [ts.createParameter(undefined, undefined, undefined, m)], undefined, ts.createBlock([
74297                 ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
74298                     ts.createVariableDeclaration(exports, undefined, ts.createObjectLiteral([]))
74299                 ])),
74300                 ts.createForIn(ts.createVariableDeclarationList([
74301                     ts.createVariableDeclaration(n, undefined)
74302                 ]), m, ts.createBlock([
74303                     ts.setEmitFlags(ts.createIf(condition, ts.createExpressionStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 1)
74304                 ])),
74305                 ts.createExpressionStatement(ts.createCall(exportFunction, undefined, [exports]))
74306             ], true));
74307         }
74308         function createSettersArray(exportStarFunction, dependencyGroups) {
74309             var setters = [];
74310             for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) {
74311                 var group_2 = dependencyGroups_1[_i];
74312                 var localName = ts.forEach(group_2.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); });
74313                 var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName("");
74314                 var statements = [];
74315                 for (var _a = 0, _b = group_2.externalImports; _a < _b.length; _a++) {
74316                     var entry = _b[_a];
74317                     var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile);
74318                     switch (entry.kind) {
74319                         case 254:
74320                             if (!entry.importClause) {
74321                                 break;
74322                             }
74323                         case 253:
74324                             ts.Debug.assert(importVariableName !== undefined);
74325                             statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName)));
74326                             break;
74327                         case 260:
74328                             ts.Debug.assert(importVariableName !== undefined);
74329                             if (entry.exportClause) {
74330                                 if (ts.isNamedExports(entry.exportClause)) {
74331                                     var properties = [];
74332                                     for (var _c = 0, _d = entry.exportClause.elements; _c < _d.length; _c++) {
74333                                         var e = _d[_c];
74334                                         properties.push(ts.createPropertyAssignment(ts.createLiteral(ts.idText(e.name)), ts.createElementAccess(parameterName, ts.createLiteral(ts.idText(e.propertyName || e.name)))));
74335                                     }
74336                                     statements.push(ts.createExpressionStatement(ts.createCall(exportFunction, undefined, [ts.createObjectLiteral(properties, true)])));
74337                                 }
74338                                 else {
74339                                     statements.push(ts.createExpressionStatement(ts.createCall(exportFunction, undefined, [
74340                                         ts.createLiteral(ts.idText(entry.exportClause.name)),
74341                                         parameterName
74342                                     ])));
74343                                 }
74344                             }
74345                             else {
74346                                 statements.push(ts.createExpressionStatement(ts.createCall(exportStarFunction, undefined, [parameterName])));
74347                             }
74348                             break;
74349                     }
74350                 }
74351                 setters.push(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, ts.createBlock(statements, true)));
74352             }
74353             return ts.createArrayLiteral(setters, true);
74354         }
74355         function sourceElementVisitor(node) {
74356             switch (node.kind) {
74357                 case 254:
74358                     return visitImportDeclaration(node);
74359                 case 253:
74360                     return visitImportEqualsDeclaration(node);
74361                 case 260:
74362                     return visitExportDeclaration(node);
74363                 case 259:
74364                     return visitExportAssignment(node);
74365                 default:
74366                     return nestedElementVisitor(node);
74367             }
74368         }
74369         function visitImportDeclaration(node) {
74370             var statements;
74371             if (node.importClause) {
74372                 hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile));
74373             }
74374             if (hasAssociatedEndOfDeclarationMarker(node)) {
74375                 var id = ts.getOriginalNodeId(node);
74376                 deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node);
74377             }
74378             else {
74379                 statements = appendExportsOfImportDeclaration(statements, node);
74380             }
74381             return ts.singleOrMany(statements);
74382         }
74383         function visitExportDeclaration(node) {
74384             ts.Debug.assertIsDefined(node);
74385             return undefined;
74386         }
74387         function visitImportEqualsDeclaration(node) {
74388             ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer.");
74389             var statements;
74390             hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile));
74391             if (hasAssociatedEndOfDeclarationMarker(node)) {
74392                 var id = ts.getOriginalNodeId(node);
74393                 deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node);
74394             }
74395             else {
74396                 statements = appendExportsOfImportEqualsDeclaration(statements, node);
74397             }
74398             return ts.singleOrMany(statements);
74399         }
74400         function visitExportAssignment(node) {
74401             if (node.isExportEquals) {
74402                 return undefined;
74403             }
74404             var expression = ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression);
74405             var original = node.original;
74406             if (original && hasAssociatedEndOfDeclarationMarker(original)) {
74407                 var id = ts.getOriginalNodeId(node);
74408                 deferredExports[id] = appendExportStatement(deferredExports[id], ts.createIdentifier("default"), expression, true);
74409             }
74410             else {
74411                 return createExportStatement(ts.createIdentifier("default"), expression, true);
74412             }
74413         }
74414         function visitFunctionDeclaration(node) {
74415             if (ts.hasModifier(node, 1)) {
74416                 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)));
74417             }
74418             else {
74419                 hoistedStatements = ts.append(hoistedStatements, ts.visitEachChild(node, destructuringAndImportCallVisitor, context));
74420             }
74421             if (hasAssociatedEndOfDeclarationMarker(node)) {
74422                 var id = ts.getOriginalNodeId(node);
74423                 deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node);
74424             }
74425             else {
74426                 hoistedStatements = appendExportsOfHoistedDeclaration(hoistedStatements, node);
74427             }
74428             return undefined;
74429         }
74430         function visitClassDeclaration(node) {
74431             var statements;
74432             var name = ts.getLocalName(node);
74433             hoistVariableDeclaration(name);
74434             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));
74435             if (hasAssociatedEndOfDeclarationMarker(node)) {
74436                 var id = ts.getOriginalNodeId(node);
74437                 deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node);
74438             }
74439             else {
74440                 statements = appendExportsOfHoistedDeclaration(statements, node);
74441             }
74442             return ts.singleOrMany(statements);
74443         }
74444         function visitVariableStatement(node) {
74445             if (!shouldHoistVariableDeclarationList(node.declarationList)) {
74446                 return ts.visitNode(node, destructuringAndImportCallVisitor, ts.isStatement);
74447             }
74448             var expressions;
74449             var isExportedDeclaration = ts.hasModifier(node, 1);
74450             var isMarkedDeclaration = hasAssociatedEndOfDeclarationMarker(node);
74451             for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
74452                 var variable = _a[_i];
74453                 if (variable.initializer) {
74454                     expressions = ts.append(expressions, transformInitializedVariable(variable, isExportedDeclaration && !isMarkedDeclaration));
74455                 }
74456                 else {
74457                     hoistBindingElement(variable);
74458                 }
74459             }
74460             var statements;
74461             if (expressions) {
74462                 statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(expressions)), node));
74463             }
74464             if (isMarkedDeclaration) {
74465                 var id = ts.getOriginalNodeId(node);
74466                 deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node, isExportedDeclaration);
74467             }
74468             else {
74469                 statements = appendExportsOfVariableStatement(statements, node, false);
74470             }
74471             return ts.singleOrMany(statements);
74472         }
74473         function hoistBindingElement(node) {
74474             if (ts.isBindingPattern(node.name)) {
74475                 for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) {
74476                     var element = _a[_i];
74477                     if (!ts.isOmittedExpression(element)) {
74478                         hoistBindingElement(element);
74479                     }
74480                 }
74481             }
74482             else {
74483                 hoistVariableDeclaration(ts.getSynthesizedClone(node.name));
74484             }
74485         }
74486         function shouldHoistVariableDeclarationList(node) {
74487             return (ts.getEmitFlags(node) & 2097152) === 0
74488                 && (enclosingBlockScopedContainer.kind === 290
74489                     || (ts.getOriginalNode(node).flags & 3) === 0);
74490         }
74491         function transformInitializedVariable(node, isExportedDeclaration) {
74492             var createAssignment = isExportedDeclaration ? createExportedVariableAssignment : createNonExportedVariableAssignment;
74493             return ts.isBindingPattern(node.name)
74494                 ? ts.flattenDestructuringAssignment(node, destructuringAndImportCallVisitor, context, 0, false, createAssignment)
74495                 : node.initializer ? createAssignment(node.name, ts.visitNode(node.initializer, destructuringAndImportCallVisitor, ts.isExpression)) : node.name;
74496         }
74497         function createExportedVariableAssignment(name, value, location) {
74498             return createVariableAssignment(name, value, location, true);
74499         }
74500         function createNonExportedVariableAssignment(name, value, location) {
74501             return createVariableAssignment(name, value, location, false);
74502         }
74503         function createVariableAssignment(name, value, location, isExportedDeclaration) {
74504             hoistVariableDeclaration(ts.getSynthesizedClone(name));
74505             return isExportedDeclaration
74506                 ? createExportExpression(name, preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location)))
74507                 : preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location));
74508         }
74509         function visitMergeDeclarationMarker(node) {
74510             if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 225) {
74511                 var id = ts.getOriginalNodeId(node);
74512                 var isExportedDeclaration = ts.hasModifier(node.original, 1);
74513                 deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration);
74514             }
74515             return node;
74516         }
74517         function hasAssociatedEndOfDeclarationMarker(node) {
74518             return (ts.getEmitFlags(node) & 4194304) !== 0;
74519         }
74520         function visitEndOfDeclarationMarker(node) {
74521             var id = ts.getOriginalNodeId(node);
74522             var statements = deferredExports[id];
74523             if (statements) {
74524                 delete deferredExports[id];
74525                 return ts.append(statements, node);
74526             }
74527             else {
74528                 var original = ts.getOriginalNode(node);
74529                 if (ts.isModuleOrEnumDeclaration(original)) {
74530                     return ts.append(appendExportsOfDeclaration(statements, original), node);
74531                 }
74532             }
74533             return node;
74534         }
74535         function appendExportsOfImportDeclaration(statements, decl) {
74536             if (moduleInfo.exportEquals) {
74537                 return statements;
74538             }
74539             var importClause = decl.importClause;
74540             if (!importClause) {
74541                 return statements;
74542             }
74543             if (importClause.name) {
74544                 statements = appendExportsOfDeclaration(statements, importClause);
74545             }
74546             var namedBindings = importClause.namedBindings;
74547             if (namedBindings) {
74548                 switch (namedBindings.kind) {
74549                     case 256:
74550                         statements = appendExportsOfDeclaration(statements, namedBindings);
74551                         break;
74552                     case 257:
74553                         for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) {
74554                             var importBinding = _a[_i];
74555                             statements = appendExportsOfDeclaration(statements, importBinding);
74556                         }
74557                         break;
74558                 }
74559             }
74560             return statements;
74561         }
74562         function appendExportsOfImportEqualsDeclaration(statements, decl) {
74563             if (moduleInfo.exportEquals) {
74564                 return statements;
74565             }
74566             return appendExportsOfDeclaration(statements, decl);
74567         }
74568         function appendExportsOfVariableStatement(statements, node, exportSelf) {
74569             if (moduleInfo.exportEquals) {
74570                 return statements;
74571             }
74572             for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
74573                 var decl = _a[_i];
74574                 if (decl.initializer || exportSelf) {
74575                     statements = appendExportsOfBindingElement(statements, decl, exportSelf);
74576                 }
74577             }
74578             return statements;
74579         }
74580         function appendExportsOfBindingElement(statements, decl, exportSelf) {
74581             if (moduleInfo.exportEquals) {
74582                 return statements;
74583             }
74584             if (ts.isBindingPattern(decl.name)) {
74585                 for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) {
74586                     var element = _a[_i];
74587                     if (!ts.isOmittedExpression(element)) {
74588                         statements = appendExportsOfBindingElement(statements, element, exportSelf);
74589                     }
74590                 }
74591             }
74592             else if (!ts.isGeneratedIdentifier(decl.name)) {
74593                 var excludeName = void 0;
74594                 if (exportSelf) {
74595                     statements = appendExportStatement(statements, decl.name, ts.getLocalName(decl));
74596                     excludeName = ts.idText(decl.name);
74597                 }
74598                 statements = appendExportsOfDeclaration(statements, decl, excludeName);
74599             }
74600             return statements;
74601         }
74602         function appendExportsOfHoistedDeclaration(statements, decl) {
74603             if (moduleInfo.exportEquals) {
74604                 return statements;
74605             }
74606             var excludeName;
74607             if (ts.hasModifier(decl, 1)) {
74608                 var exportName = ts.hasModifier(decl, 512) ? ts.createLiteral("default") : decl.name;
74609                 statements = appendExportStatement(statements, exportName, ts.getLocalName(decl));
74610                 excludeName = ts.getTextOfIdentifierOrLiteral(exportName);
74611             }
74612             if (decl.name) {
74613                 statements = appendExportsOfDeclaration(statements, decl, excludeName);
74614             }
74615             return statements;
74616         }
74617         function appendExportsOfDeclaration(statements, decl, excludeName) {
74618             if (moduleInfo.exportEquals) {
74619                 return statements;
74620             }
74621             var name = ts.getDeclarationName(decl);
74622             var exportSpecifiers = moduleInfo.exportSpecifiers.get(ts.idText(name));
74623             if (exportSpecifiers) {
74624                 for (var _i = 0, exportSpecifiers_2 = exportSpecifiers; _i < exportSpecifiers_2.length; _i++) {
74625                     var exportSpecifier = exportSpecifiers_2[_i];
74626                     if (exportSpecifier.name.escapedText !== excludeName) {
74627                         statements = appendExportStatement(statements, exportSpecifier.name, name);
74628                     }
74629                 }
74630             }
74631             return statements;
74632         }
74633         function appendExportStatement(statements, exportName, expression, allowComments) {
74634             statements = ts.append(statements, createExportStatement(exportName, expression, allowComments));
74635             return statements;
74636         }
74637         function createExportStatement(name, value, allowComments) {
74638             var statement = ts.createExpressionStatement(createExportExpression(name, value));
74639             ts.startOnNewLine(statement);
74640             if (!allowComments) {
74641                 ts.setEmitFlags(statement, 1536);
74642             }
74643             return statement;
74644         }
74645         function createExportExpression(name, value) {
74646             var exportName = ts.isIdentifier(name) ? ts.createLiteral(name) : name;
74647             ts.setEmitFlags(value, ts.getEmitFlags(value) | 1536);
74648             return ts.setCommentRange(ts.createCall(exportFunction, undefined, [exportName, value]), value);
74649         }
74650         function nestedElementVisitor(node) {
74651             switch (node.kind) {
74652                 case 225:
74653                     return visitVariableStatement(node);
74654                 case 244:
74655                     return visitFunctionDeclaration(node);
74656                 case 245:
74657                     return visitClassDeclaration(node);
74658                 case 230:
74659                     return visitForStatement(node);
74660                 case 231:
74661                     return visitForInStatement(node);
74662                 case 232:
74663                     return visitForOfStatement(node);
74664                 case 228:
74665                     return visitDoStatement(node);
74666                 case 229:
74667                     return visitWhileStatement(node);
74668                 case 238:
74669                     return visitLabeledStatement(node);
74670                 case 236:
74671                     return visitWithStatement(node);
74672                 case 237:
74673                     return visitSwitchStatement(node);
74674                 case 251:
74675                     return visitCaseBlock(node);
74676                 case 277:
74677                     return visitCaseClause(node);
74678                 case 278:
74679                     return visitDefaultClause(node);
74680                 case 240:
74681                     return visitTryStatement(node);
74682                 case 280:
74683                     return visitCatchClause(node);
74684                 case 223:
74685                     return visitBlock(node);
74686                 case 328:
74687                     return visitMergeDeclarationMarker(node);
74688                 case 329:
74689                     return visitEndOfDeclarationMarker(node);
74690                 default:
74691                     return destructuringAndImportCallVisitor(node);
74692             }
74693         }
74694         function visitForStatement(node) {
74695             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
74696             enclosingBlockScopedContainer = node;
74697             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));
74698             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
74699             return node;
74700         }
74701         function visitForInStatement(node) {
74702             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
74703             enclosingBlockScopedContainer = node;
74704             node = ts.updateForIn(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock));
74705             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
74706             return node;
74707         }
74708         function visitForOfStatement(node) {
74709             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
74710             enclosingBlockScopedContainer = node;
74711             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));
74712             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
74713             return node;
74714         }
74715         function shouldHoistForInitializer(node) {
74716             return ts.isVariableDeclarationList(node)
74717                 && shouldHoistVariableDeclarationList(node);
74718         }
74719         function visitForInitializer(node) {
74720             if (shouldHoistForInitializer(node)) {
74721                 var expressions = void 0;
74722                 for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) {
74723                     var variable = _a[_i];
74724                     expressions = ts.append(expressions, transformInitializedVariable(variable, false));
74725                     if (!variable.initializer) {
74726                         hoistBindingElement(variable);
74727                     }
74728                 }
74729                 return expressions ? ts.inlineExpressions(expressions) : ts.createOmittedExpression();
74730             }
74731             else {
74732                 return ts.visitEachChild(node, nestedElementVisitor, context);
74733             }
74734         }
74735         function visitDoStatement(node) {
74736             return ts.updateDo(node, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression));
74737         }
74738         function visitWhileStatement(node) {
74739             return ts.updateWhile(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock));
74740         }
74741         function visitLabeledStatement(node) {
74742             return ts.updateLabel(node, node.label, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock));
74743         }
74744         function visitWithStatement(node) {
74745             return ts.updateWith(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock));
74746         }
74747         function visitSwitchStatement(node) {
74748             return ts.updateSwitch(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.caseBlock, nestedElementVisitor, ts.isCaseBlock));
74749         }
74750         function visitCaseBlock(node) {
74751             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
74752             enclosingBlockScopedContainer = node;
74753             node = ts.updateCaseBlock(node, ts.visitNodes(node.clauses, nestedElementVisitor, ts.isCaseOrDefaultClause));
74754             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
74755             return node;
74756         }
74757         function visitCaseClause(node) {
74758             return ts.updateCaseClause(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNodes(node.statements, nestedElementVisitor, ts.isStatement));
74759         }
74760         function visitDefaultClause(node) {
74761             return ts.visitEachChild(node, nestedElementVisitor, context);
74762         }
74763         function visitTryStatement(node) {
74764             return ts.visitEachChild(node, nestedElementVisitor, context);
74765         }
74766         function visitCatchClause(node) {
74767             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
74768             enclosingBlockScopedContainer = node;
74769             node = ts.updateCatchClause(node, node.variableDeclaration, ts.visitNode(node.block, nestedElementVisitor, ts.isBlock));
74770             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
74771             return node;
74772         }
74773         function visitBlock(node) {
74774             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
74775             enclosingBlockScopedContainer = node;
74776             node = ts.visitEachChild(node, nestedElementVisitor, context);
74777             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
74778             return node;
74779         }
74780         function destructuringAndImportCallVisitor(node) {
74781             if (ts.isDestructuringAssignment(node)) {
74782                 return visitDestructuringAssignment(node);
74783             }
74784             else if (ts.isImportCall(node)) {
74785                 return visitImportCallExpression(node);
74786             }
74787             else if ((node.transformFlags & 1024) || (node.transformFlags & 2097152)) {
74788                 return ts.visitEachChild(node, destructuringAndImportCallVisitor, context);
74789             }
74790             else {
74791                 return node;
74792             }
74793         }
74794         function visitImportCallExpression(node) {
74795             return ts.createCall(ts.createPropertyAccess(contextObject, ts.createIdentifier("import")), undefined, ts.some(node.arguments) ? [ts.visitNode(node.arguments[0], destructuringAndImportCallVisitor)] : []);
74796         }
74797         function visitDestructuringAssignment(node) {
74798             if (hasExportedReferenceInDestructuringTarget(node.left)) {
74799                 return ts.flattenDestructuringAssignment(node, destructuringAndImportCallVisitor, context, 0, true);
74800             }
74801             return ts.visitEachChild(node, destructuringAndImportCallVisitor, context);
74802         }
74803         function hasExportedReferenceInDestructuringTarget(node) {
74804             if (ts.isAssignmentExpression(node, true)) {
74805                 return hasExportedReferenceInDestructuringTarget(node.left);
74806             }
74807             else if (ts.isSpreadElement(node)) {
74808                 return hasExportedReferenceInDestructuringTarget(node.expression);
74809             }
74810             else if (ts.isObjectLiteralExpression(node)) {
74811                 return ts.some(node.properties, hasExportedReferenceInDestructuringTarget);
74812             }
74813             else if (ts.isArrayLiteralExpression(node)) {
74814                 return ts.some(node.elements, hasExportedReferenceInDestructuringTarget);
74815             }
74816             else if (ts.isShorthandPropertyAssignment(node)) {
74817                 return hasExportedReferenceInDestructuringTarget(node.name);
74818             }
74819             else if (ts.isPropertyAssignment(node)) {
74820                 return hasExportedReferenceInDestructuringTarget(node.initializer);
74821             }
74822             else if (ts.isIdentifier(node)) {
74823                 var container = resolver.getReferencedExportContainer(node);
74824                 return container !== undefined && container.kind === 290;
74825             }
74826             else {
74827                 return false;
74828             }
74829         }
74830         function modifierVisitor(node) {
74831             switch (node.kind) {
74832                 case 89:
74833                 case 84:
74834                     return undefined;
74835             }
74836             return node;
74837         }
74838         function onEmitNode(hint, node, emitCallback) {
74839             if (node.kind === 290) {
74840                 var id = ts.getOriginalNodeId(node);
74841                 currentSourceFile = node;
74842                 moduleInfo = moduleInfoMap[id];
74843                 exportFunction = exportFunctionsMap[id];
74844                 noSubstitution = noSubstitutionMap[id];
74845                 contextObject = contextObjectMap[id];
74846                 if (noSubstitution) {
74847                     delete noSubstitutionMap[id];
74848                 }
74849                 previousOnEmitNode(hint, node, emitCallback);
74850                 currentSourceFile = undefined;
74851                 moduleInfo = undefined;
74852                 exportFunction = undefined;
74853                 contextObject = undefined;
74854                 noSubstitution = undefined;
74855             }
74856             else {
74857                 previousOnEmitNode(hint, node, emitCallback);
74858             }
74859         }
74860         function onSubstituteNode(hint, node) {
74861             node = previousOnSubstituteNode(hint, node);
74862             if (isSubstitutionPrevented(node)) {
74863                 return node;
74864             }
74865             if (hint === 1) {
74866                 return substituteExpression(node);
74867             }
74868             else if (hint === 4) {
74869                 return substituteUnspecified(node);
74870             }
74871             return node;
74872         }
74873         function substituteUnspecified(node) {
74874             switch (node.kind) {
74875                 case 282:
74876                     return substituteShorthandPropertyAssignment(node);
74877             }
74878             return node;
74879         }
74880         function substituteShorthandPropertyAssignment(node) {
74881             var name = node.name;
74882             if (!ts.isGeneratedIdentifier(name) && !ts.isLocalName(name)) {
74883                 var importDeclaration = resolver.getReferencedImportDeclaration(name);
74884                 if (importDeclaration) {
74885                     if (ts.isImportClause(importDeclaration)) {
74886                         return ts.setTextRange(ts.createPropertyAssignment(ts.getSynthesizedClone(name), ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"))), node);
74887                     }
74888                     else if (ts.isImportSpecifier(importDeclaration)) {
74889                         return ts.setTextRange(ts.createPropertyAssignment(ts.getSynthesizedClone(name), ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(importDeclaration.propertyName || importDeclaration.name))), node);
74890                     }
74891                 }
74892             }
74893             return node;
74894         }
74895         function substituteExpression(node) {
74896             switch (node.kind) {
74897                 case 75:
74898                     return substituteExpressionIdentifier(node);
74899                 case 209:
74900                     return substituteBinaryExpression(node);
74901                 case 207:
74902                 case 208:
74903                     return substituteUnaryExpression(node);
74904                 case 219:
74905                     return substituteMetaProperty(node);
74906             }
74907             return node;
74908         }
74909         function substituteExpressionIdentifier(node) {
74910             if (ts.getEmitFlags(node) & 4096) {
74911                 var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile);
74912                 if (externalHelpersModuleName) {
74913                     return ts.createPropertyAccess(externalHelpersModuleName, node);
74914                 }
74915                 return node;
74916             }
74917             if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) {
74918                 var importDeclaration = resolver.getReferencedImportDeclaration(node);
74919                 if (importDeclaration) {
74920                     if (ts.isImportClause(importDeclaration)) {
74921                         return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default")), node);
74922                     }
74923                     else if (ts.isImportSpecifier(importDeclaration)) {
74924                         return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(importDeclaration.propertyName || importDeclaration.name)), node);
74925                     }
74926                 }
74927             }
74928             return node;
74929         }
74930         function substituteBinaryExpression(node) {
74931             if (ts.isAssignmentOperator(node.operatorToken.kind)
74932                 && ts.isIdentifier(node.left)
74933                 && !ts.isGeneratedIdentifier(node.left)
74934                 && !ts.isLocalName(node.left)
74935                 && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) {
74936                 var exportedNames = getExports(node.left);
74937                 if (exportedNames) {
74938                     var expression = node;
74939                     for (var _i = 0, exportedNames_4 = exportedNames; _i < exportedNames_4.length; _i++) {
74940                         var exportName = exportedNames_4[_i];
74941                         expression = createExportExpression(exportName, preventSubstitution(expression));
74942                     }
74943                     return expression;
74944                 }
74945             }
74946             return node;
74947         }
74948         function substituteUnaryExpression(node) {
74949             if ((node.operator === 45 || node.operator === 46)
74950                 && ts.isIdentifier(node.operand)
74951                 && !ts.isGeneratedIdentifier(node.operand)
74952                 && !ts.isLocalName(node.operand)
74953                 && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) {
74954                 var exportedNames = getExports(node.operand);
74955                 if (exportedNames) {
74956                     var expression = node.kind === 208
74957                         ? ts.setTextRange(ts.createPrefix(node.operator, node.operand), node)
74958                         : node;
74959                     for (var _i = 0, exportedNames_5 = exportedNames; _i < exportedNames_5.length; _i++) {
74960                         var exportName = exportedNames_5[_i];
74961                         expression = createExportExpression(exportName, preventSubstitution(expression));
74962                     }
74963                     if (node.kind === 208) {
74964                         expression = node.operator === 45
74965                             ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1))
74966                             : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1));
74967                     }
74968                     return expression;
74969                 }
74970             }
74971             return node;
74972         }
74973         function substituteMetaProperty(node) {
74974             if (ts.isImportMeta(node)) {
74975                 return ts.createPropertyAccess(contextObject, ts.createIdentifier("meta"));
74976             }
74977             return node;
74978         }
74979         function getExports(name) {
74980             var exportedNames;
74981             if (!ts.isGeneratedIdentifier(name)) {
74982                 var valueDeclaration = resolver.getReferencedImportDeclaration(name)
74983                     || resolver.getReferencedValueDeclaration(name);
74984                 if (valueDeclaration) {
74985                     var exportContainer = resolver.getReferencedExportContainer(name, false);
74986                     if (exportContainer && exportContainer.kind === 290) {
74987                         exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration));
74988                     }
74989                     exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]);
74990                 }
74991             }
74992             return exportedNames;
74993         }
74994         function preventSubstitution(node) {
74995             if (noSubstitution === undefined)
74996                 noSubstitution = [];
74997             noSubstitution[ts.getNodeId(node)] = true;
74998             return node;
74999         }
75000         function isSubstitutionPrevented(node) {
75001             return noSubstitution && node.id && noSubstitution[node.id];
75002         }
75003     }
75004     ts.transformSystemModule = transformSystemModule;
75005 })(ts || (ts = {}));
75006 var ts;
75007 (function (ts) {
75008     function transformECMAScriptModule(context) {
75009         var compilerOptions = context.getCompilerOptions();
75010         var previousOnEmitNode = context.onEmitNode;
75011         var previousOnSubstituteNode = context.onSubstituteNode;
75012         context.onEmitNode = onEmitNode;
75013         context.onSubstituteNode = onSubstituteNode;
75014         context.enableEmitNotification(290);
75015         context.enableSubstitution(75);
75016         var helperNameSubstitutions;
75017         return ts.chainBundle(transformSourceFile);
75018         function transformSourceFile(node) {
75019             if (node.isDeclarationFile) {
75020                 return node;
75021             }
75022             if (ts.isExternalModule(node) || compilerOptions.isolatedModules) {
75023                 var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(node, compilerOptions);
75024                 if (externalHelpersImportDeclaration) {
75025                     var statements = [];
75026                     var statementOffset = ts.addPrologue(statements, node.statements);
75027                     ts.append(statements, externalHelpersImportDeclaration);
75028                     ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset));
75029                     return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements));
75030                 }
75031                 else {
75032                     return ts.visitEachChild(node, visitor, context);
75033                 }
75034             }
75035             return node;
75036         }
75037         function visitor(node) {
75038             switch (node.kind) {
75039                 case 253:
75040                     return undefined;
75041                 case 259:
75042                     return visitExportAssignment(node);
75043                 case 260:
75044                     var exportDecl = node;
75045                     return visitExportDeclaration(exportDecl);
75046             }
75047             return node;
75048         }
75049         function visitExportAssignment(node) {
75050             return node.isExportEquals ? undefined : node;
75051         }
75052         function visitExportDeclaration(node) {
75053             if (compilerOptions.module !== undefined && compilerOptions.module > ts.ModuleKind.ES2015) {
75054                 return node;
75055             }
75056             if (!node.exportClause || !ts.isNamespaceExport(node.exportClause) || !node.moduleSpecifier) {
75057                 return node;
75058             }
75059             var oldIdentifier = node.exportClause.name;
75060             var synthName = ts.getGeneratedNameForNode(oldIdentifier);
75061             var importDecl = ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamespaceImport(synthName)), node.moduleSpecifier);
75062             ts.setOriginalNode(importDecl, node.exportClause);
75063             var exportDecl = ts.createExportDeclaration(undefined, undefined, ts.createNamedExports([ts.createExportSpecifier(synthName, oldIdentifier)]));
75064             ts.setOriginalNode(exportDecl, node);
75065             return [importDecl, exportDecl];
75066         }
75067         function onEmitNode(hint, node, emitCallback) {
75068             if (ts.isSourceFile(node)) {
75069                 if ((ts.isExternalModule(node) || compilerOptions.isolatedModules) && compilerOptions.importHelpers) {
75070                     helperNameSubstitutions = ts.createMap();
75071                 }
75072                 previousOnEmitNode(hint, node, emitCallback);
75073                 helperNameSubstitutions = undefined;
75074             }
75075             else {
75076                 previousOnEmitNode(hint, node, emitCallback);
75077             }
75078         }
75079         function onSubstituteNode(hint, node) {
75080             node = previousOnSubstituteNode(hint, node);
75081             if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096) {
75082                 return substituteHelperName(node);
75083             }
75084             return node;
75085         }
75086         function substituteHelperName(node) {
75087             var name = ts.idText(node);
75088             var substitution = helperNameSubstitutions.get(name);
75089             if (!substitution) {
75090                 helperNameSubstitutions.set(name, substitution = ts.createFileLevelUniqueName(name));
75091             }
75092             return substitution;
75093         }
75094     }
75095     ts.transformECMAScriptModule = transformECMAScriptModule;
75096 })(ts || (ts = {}));
75097 var ts;
75098 (function (ts) {
75099     function canProduceDiagnostics(node) {
75100         return ts.isVariableDeclaration(node) ||
75101             ts.isPropertyDeclaration(node) ||
75102             ts.isPropertySignature(node) ||
75103             ts.isBindingElement(node) ||
75104             ts.isSetAccessor(node) ||
75105             ts.isGetAccessor(node) ||
75106             ts.isConstructSignatureDeclaration(node) ||
75107             ts.isCallSignatureDeclaration(node) ||
75108             ts.isMethodDeclaration(node) ||
75109             ts.isMethodSignature(node) ||
75110             ts.isFunctionDeclaration(node) ||
75111             ts.isParameter(node) ||
75112             ts.isTypeParameterDeclaration(node) ||
75113             ts.isExpressionWithTypeArguments(node) ||
75114             ts.isImportEqualsDeclaration(node) ||
75115             ts.isTypeAliasDeclaration(node) ||
75116             ts.isConstructorDeclaration(node) ||
75117             ts.isIndexSignatureDeclaration(node) ||
75118             ts.isPropertyAccessExpression(node);
75119     }
75120     ts.canProduceDiagnostics = canProduceDiagnostics;
75121     function createGetSymbolAccessibilityDiagnosticForNodeName(node) {
75122         if (ts.isSetAccessor(node) || ts.isGetAccessor(node)) {
75123             return getAccessorNameVisibilityError;
75124         }
75125         else if (ts.isMethodSignature(node) || ts.isMethodDeclaration(node)) {
75126             return getMethodNameVisibilityError;
75127         }
75128         else {
75129             return createGetSymbolAccessibilityDiagnosticForNode(node);
75130         }
75131         function getAccessorNameVisibilityError(symbolAccessibilityResult) {
75132             var diagnosticMessage = getAccessorNameVisibilityDiagnosticMessage(symbolAccessibilityResult);
75133             return diagnosticMessage !== undefined ? {
75134                 diagnosticMessage: diagnosticMessage,
75135                 errorNode: node,
75136                 typeName: node.name
75137             } : undefined;
75138         }
75139         function getAccessorNameVisibilityDiagnosticMessage(symbolAccessibilityResult) {
75140             if (ts.hasModifier(node, 32)) {
75141                 return symbolAccessibilityResult.errorModuleName ?
75142                     symbolAccessibilityResult.accessibility === 2 ?
75143                         ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75144                         ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
75145                     ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1;
75146             }
75147             else if (node.parent.kind === 245) {
75148                 return symbolAccessibilityResult.errorModuleName ?
75149                     symbolAccessibilityResult.accessibility === 2 ?
75150                         ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75151                         ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
75152                     ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1;
75153             }
75154             else {
75155                 return symbolAccessibilityResult.errorModuleName ?
75156                     ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 :
75157                     ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1;
75158             }
75159         }
75160         function getMethodNameVisibilityError(symbolAccessibilityResult) {
75161             var diagnosticMessage = getMethodNameVisibilityDiagnosticMessage(symbolAccessibilityResult);
75162             return diagnosticMessage !== undefined ? {
75163                 diagnosticMessage: diagnosticMessage,
75164                 errorNode: node,
75165                 typeName: node.name
75166             } : undefined;
75167         }
75168         function getMethodNameVisibilityDiagnosticMessage(symbolAccessibilityResult) {
75169             if (ts.hasModifier(node, 32)) {
75170                 return symbolAccessibilityResult.errorModuleName ?
75171                     symbolAccessibilityResult.accessibility === 2 ?
75172                         ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75173                         ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
75174                     ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_private_name_1;
75175             }
75176             else if (node.parent.kind === 245) {
75177                 return symbolAccessibilityResult.errorModuleName ?
75178                     symbolAccessibilityResult.accessibility === 2 ?
75179                         ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75180                         ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
75181                     ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_private_name_1;
75182             }
75183             else {
75184                 return symbolAccessibilityResult.errorModuleName ?
75185                     ts.Diagnostics.Method_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 :
75186                     ts.Diagnostics.Method_0_of_exported_interface_has_or_is_using_private_name_1;
75187             }
75188         }
75189     }
75190     ts.createGetSymbolAccessibilityDiagnosticForNodeName = createGetSymbolAccessibilityDiagnosticForNodeName;
75191     function createGetSymbolAccessibilityDiagnosticForNode(node) {
75192         if (ts.isVariableDeclaration(node) || ts.isPropertyDeclaration(node) || ts.isPropertySignature(node) || ts.isPropertyAccessExpression(node) || ts.isBindingElement(node) || ts.isConstructorDeclaration(node)) {
75193             return getVariableDeclarationTypeVisibilityError;
75194         }
75195         else if (ts.isSetAccessor(node) || ts.isGetAccessor(node)) {
75196             return getAccessorDeclarationTypeVisibilityError;
75197         }
75198         else if (ts.isConstructSignatureDeclaration(node) || ts.isCallSignatureDeclaration(node) || ts.isMethodDeclaration(node) || ts.isMethodSignature(node) || ts.isFunctionDeclaration(node) || ts.isIndexSignatureDeclaration(node)) {
75199             return getReturnTypeVisibilityError;
75200         }
75201         else if (ts.isParameter(node)) {
75202             if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasModifier(node.parent, 8)) {
75203                 return getVariableDeclarationTypeVisibilityError;
75204             }
75205             return getParameterDeclarationTypeVisibilityError;
75206         }
75207         else if (ts.isTypeParameterDeclaration(node)) {
75208             return getTypeParameterConstraintVisibilityError;
75209         }
75210         else if (ts.isExpressionWithTypeArguments(node)) {
75211             return getHeritageClauseVisibilityError;
75212         }
75213         else if (ts.isImportEqualsDeclaration(node)) {
75214             return getImportEntityNameVisibilityError;
75215         }
75216         else if (ts.isTypeAliasDeclaration(node)) {
75217             return getTypeAliasDeclarationVisibilityError;
75218         }
75219         else {
75220             return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]);
75221         }
75222         function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) {
75223             if (node.kind === 242 || node.kind === 191) {
75224                 return symbolAccessibilityResult.errorModuleName ?
75225                     symbolAccessibilityResult.accessibility === 2 ?
75226                         ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75227                         ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 :
75228                     ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1;
75229             }
75230             else if (node.kind === 159 || node.kind === 194 || node.kind === 158 ||
75231                 (node.kind === 156 && ts.hasModifier(node.parent, 8))) {
75232                 if (ts.hasModifier(node, 32)) {
75233                     return symbolAccessibilityResult.errorModuleName ?
75234                         symbolAccessibilityResult.accessibility === 2 ?
75235                             ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75236                             ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
75237                         ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1;
75238                 }
75239                 else if (node.parent.kind === 245 || node.kind === 156) {
75240                     return symbolAccessibilityResult.errorModuleName ?
75241                         symbolAccessibilityResult.accessibility === 2 ?
75242                             ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75243                             ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
75244                         ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1;
75245                 }
75246                 else {
75247                     return symbolAccessibilityResult.errorModuleName ?
75248                         ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 :
75249                         ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1;
75250                 }
75251             }
75252         }
75253         function getVariableDeclarationTypeVisibilityError(symbolAccessibilityResult) {
75254             var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult);
75255             return diagnosticMessage !== undefined ? {
75256                 diagnosticMessage: diagnosticMessage,
75257                 errorNode: node,
75258                 typeName: node.name
75259             } : undefined;
75260         }
75261         function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) {
75262             var diagnosticMessage;
75263             if (node.kind === 164) {
75264                 if (ts.hasModifier(node, 32)) {
75265                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75266                         ts.Diagnostics.Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
75267                         ts.Diagnostics.Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_private_name_1;
75268                 }
75269                 else {
75270                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75271                         ts.Diagnostics.Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
75272                         ts.Diagnostics.Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_private_name_1;
75273                 }
75274             }
75275             else {
75276                 if (ts.hasModifier(node, 32)) {
75277                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75278                         symbolAccessibilityResult.accessibility === 2 ?
75279                             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 :
75280                             ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
75281                         ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_private_name_1;
75282                 }
75283                 else {
75284                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75285                         symbolAccessibilityResult.accessibility === 2 ?
75286                             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 :
75287                             ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
75288                         ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_private_name_1;
75289                 }
75290             }
75291             return {
75292                 diagnosticMessage: diagnosticMessage,
75293                 errorNode: node.name,
75294                 typeName: node.name
75295             };
75296         }
75297         function getReturnTypeVisibilityError(symbolAccessibilityResult) {
75298             var diagnosticMessage;
75299             switch (node.kind) {
75300                 case 166:
75301                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75302                         ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
75303                         ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0;
75304                     break;
75305                 case 165:
75306                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75307                         ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
75308                         ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0;
75309                     break;
75310                 case 167:
75311                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75312                         ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
75313                         ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0;
75314                     break;
75315                 case 161:
75316                 case 160:
75317                     if (ts.hasModifier(node, 32)) {
75318                         diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75319                             symbolAccessibilityResult.accessibility === 2 ?
75320                                 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 :
75321                                 ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 :
75322                             ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0;
75323                     }
75324                     else if (node.parent.kind === 245) {
75325                         diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75326                             symbolAccessibilityResult.accessibility === 2 ?
75327                                 ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
75328                                 ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 :
75329                             ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0;
75330                     }
75331                     else {
75332                         diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75333                             ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
75334                             ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0;
75335                     }
75336                     break;
75337                 case 244:
75338                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75339                         symbolAccessibilityResult.accessibility === 2 ?
75340                             ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
75341                             ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 :
75342                         ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0;
75343                     break;
75344                 default:
75345                     return ts.Debug.fail("This is unknown kind for signature: " + node.kind);
75346             }
75347             return {
75348                 diagnosticMessage: diagnosticMessage,
75349                 errorNode: node.name || node
75350             };
75351         }
75352         function getParameterDeclarationTypeVisibilityError(symbolAccessibilityResult) {
75353             var diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult);
75354             return diagnosticMessage !== undefined ? {
75355                 diagnosticMessage: diagnosticMessage,
75356                 errorNode: node,
75357                 typeName: node.name
75358             } : undefined;
75359         }
75360         function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) {
75361             switch (node.parent.kind) {
75362                 case 162:
75363                     return symbolAccessibilityResult.errorModuleName ?
75364                         symbolAccessibilityResult.accessibility === 2 ?
75365                             ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75366                             ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
75367                         ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1;
75368                 case 166:
75369                 case 171:
75370                     return symbolAccessibilityResult.errorModuleName ?
75371                         ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
75372                         ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1;
75373                 case 165:
75374                     return symbolAccessibilityResult.errorModuleName ?
75375                         ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
75376                         ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1;
75377                 case 167:
75378                     return symbolAccessibilityResult.errorModuleName ?
75379                         ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
75380                         ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1;
75381                 case 161:
75382                 case 160:
75383                     if (ts.hasModifier(node.parent, 32)) {
75384                         return symbolAccessibilityResult.errorModuleName ?
75385                             symbolAccessibilityResult.accessibility === 2 ?
75386                                 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 :
75387                                 ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
75388                             ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1;
75389                     }
75390                     else if (node.parent.parent.kind === 245) {
75391                         return symbolAccessibilityResult.errorModuleName ?
75392                             symbolAccessibilityResult.accessibility === 2 ?
75393                                 ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75394                                 ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
75395                             ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1;
75396                     }
75397                     else {
75398                         return symbolAccessibilityResult.errorModuleName ?
75399                             ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
75400                             ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1;
75401                     }
75402                 case 244:
75403                 case 170:
75404                     return symbolAccessibilityResult.errorModuleName ?
75405                         symbolAccessibilityResult.accessibility === 2 ?
75406                             ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75407                             ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 :
75408                         ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1;
75409                 case 164:
75410                 case 163:
75411                     return symbolAccessibilityResult.errorModuleName ?
75412                         symbolAccessibilityResult.accessibility === 2 ?
75413                             ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75414                             ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 :
75415                         ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1;
75416                 default:
75417                     return ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]);
75418             }
75419         }
75420         function getTypeParameterConstraintVisibilityError() {
75421             var diagnosticMessage;
75422             switch (node.parent.kind) {
75423                 case 245:
75424                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1;
75425                     break;
75426                 case 246:
75427                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1;
75428                     break;
75429                 case 186:
75430                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1;
75431                     break;
75432                 case 171:
75433                 case 166:
75434                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1;
75435                     break;
75436                 case 165:
75437                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1;
75438                     break;
75439                 case 161:
75440                 case 160:
75441                     if (ts.hasModifier(node.parent, 32)) {
75442                         diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1;
75443                     }
75444                     else if (node.parent.parent.kind === 245) {
75445                         diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1;
75446                     }
75447                     else {
75448                         diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1;
75449                     }
75450                     break;
75451                 case 170:
75452                 case 244:
75453                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1;
75454                     break;
75455                 case 247:
75456                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1;
75457                     break;
75458                 default:
75459                     return ts.Debug.fail("This is unknown parent for type parameter: " + node.parent.kind);
75460             }
75461             return {
75462                 diagnosticMessage: diagnosticMessage,
75463                 errorNode: node,
75464                 typeName: node.name
75465             };
75466         }
75467         function getHeritageClauseVisibilityError() {
75468             var diagnosticMessage;
75469             if (node.parent.parent.kind === 245) {
75470                 diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 113 ?
75471                     ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 :
75472                     ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1;
75473             }
75474             else {
75475                 diagnosticMessage = ts.Diagnostics.extends_clause_of_exported_interface_0_has_or_is_using_private_name_1;
75476             }
75477             return {
75478                 diagnosticMessage: diagnosticMessage,
75479                 errorNode: node,
75480                 typeName: ts.getNameOfDeclaration(node.parent.parent)
75481             };
75482         }
75483         function getImportEntityNameVisibilityError() {
75484             return {
75485                 diagnosticMessage: ts.Diagnostics.Import_declaration_0_is_using_private_name_1,
75486                 errorNode: node,
75487                 typeName: node.name
75488             };
75489         }
75490         function getTypeAliasDeclarationVisibilityError() {
75491             return {
75492                 diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1,
75493                 errorNode: node.type,
75494                 typeName: node.name
75495             };
75496         }
75497     }
75498     ts.createGetSymbolAccessibilityDiagnosticForNode = createGetSymbolAccessibilityDiagnosticForNode;
75499 })(ts || (ts = {}));
75500 var ts;
75501 (function (ts) {
75502     function getDeclarationDiagnostics(host, resolver, file) {
75503         if (file && ts.isJsonSourceFile(file)) {
75504             return [];
75505         }
75506         var compilerOptions = host.getCompilerOptions();
75507         var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : ts.filter(host.getSourceFiles(), ts.isSourceFileNotJson), [transformDeclarations], false);
75508         return result.diagnostics;
75509     }
75510     ts.getDeclarationDiagnostics = getDeclarationDiagnostics;
75511     function hasInternalAnnotation(range, currentSourceFile) {
75512         var comment = currentSourceFile.text.substring(range.pos, range.end);
75513         return ts.stringContains(comment, "@internal");
75514     }
75515     function isInternalDeclaration(node, currentSourceFile) {
75516         var parseTreeNode = ts.getParseTreeNode(node);
75517         if (parseTreeNode && parseTreeNode.kind === 156) {
75518             var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode);
75519             var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined;
75520             var text = currentSourceFile.text;
75521             var commentRanges = previousSibling
75522                 ? ts.concatenate(ts.getTrailingCommentRanges(text, ts.skipTrivia(text, previousSibling.end + 1, false, true)), ts.getLeadingCommentRanges(text, node.pos))
75523                 : ts.getTrailingCommentRanges(text, ts.skipTrivia(text, node.pos, false, true));
75524             return commentRanges && commentRanges.length && hasInternalAnnotation(ts.last(commentRanges), currentSourceFile);
75525         }
75526         var leadingCommentRanges = parseTreeNode && ts.getLeadingCommentRangesOfNode(parseTreeNode, currentSourceFile);
75527         return !!ts.forEach(leadingCommentRanges, function (range) {
75528             return hasInternalAnnotation(range, currentSourceFile);
75529         });
75530     }
75531     ts.isInternalDeclaration = isInternalDeclaration;
75532     var declarationEmitNodeBuilderFlags = 1024 |
75533         2048 |
75534         4096 |
75535         8 |
75536         524288 |
75537         4 |
75538         1;
75539     function transformDeclarations(context) {
75540         var throwDiagnostic = function () { return ts.Debug.fail("Diagnostic emitted without context"); };
75541         var getSymbolAccessibilityDiagnostic = throwDiagnostic;
75542         var needsDeclare = true;
75543         var isBundledEmit = false;
75544         var resultHasExternalModuleIndicator = false;
75545         var needsScopeFixMarker = false;
75546         var resultHasScopeMarker = false;
75547         var enclosingDeclaration;
75548         var necessaryTypeReferences;
75549         var lateMarkedStatements;
75550         var lateStatementReplacementMap;
75551         var suppressNewDiagnosticContexts;
75552         var exportedModulesFromDeclarationEmit;
75553         var host = context.getEmitHost();
75554         var symbolTracker = {
75555             trackSymbol: trackSymbol,
75556             reportInaccessibleThisError: reportInaccessibleThisError,
75557             reportInaccessibleUniqueSymbolError: reportInaccessibleUniqueSymbolError,
75558             reportCyclicStructureError: reportCyclicStructureError,
75559             reportPrivateInBaseOfClassExpression: reportPrivateInBaseOfClassExpression,
75560             reportLikelyUnsafeImportRequiredError: reportLikelyUnsafeImportRequiredError,
75561             moduleResolverHost: host,
75562             trackReferencedAmbientModule: trackReferencedAmbientModule,
75563             trackExternalModuleSymbolOfImportTypeNode: trackExternalModuleSymbolOfImportTypeNode,
75564             reportNonlocalAugmentation: reportNonlocalAugmentation
75565         };
75566         var errorNameNode;
75567         var currentSourceFile;
75568         var refs;
75569         var libs;
75570         var emittedImports;
75571         var resolver = context.getEmitResolver();
75572         var options = context.getCompilerOptions();
75573         var noResolve = options.noResolve, stripInternal = options.stripInternal;
75574         return transformRoot;
75575         function recordTypeReferenceDirectivesIfNecessary(typeReferenceDirectives) {
75576             if (!typeReferenceDirectives) {
75577                 return;
75578             }
75579             necessaryTypeReferences = necessaryTypeReferences || ts.createMap();
75580             for (var _i = 0, typeReferenceDirectives_2 = typeReferenceDirectives; _i < typeReferenceDirectives_2.length; _i++) {
75581                 var ref = typeReferenceDirectives_2[_i];
75582                 necessaryTypeReferences.set(ref, true);
75583             }
75584         }
75585         function trackReferencedAmbientModule(node, symbol) {
75586             var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863);
75587             if (ts.length(directives)) {
75588                 return recordTypeReferenceDirectivesIfNecessary(directives);
75589             }
75590             var container = ts.getSourceFileOfNode(node);
75591             refs.set("" + ts.getOriginalNodeId(container), container);
75592         }
75593         function handleSymbolAccessibilityError(symbolAccessibilityResult) {
75594             if (symbolAccessibilityResult.accessibility === 0) {
75595                 if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) {
75596                     if (!lateMarkedStatements) {
75597                         lateMarkedStatements = symbolAccessibilityResult.aliasesToMakeVisible;
75598                     }
75599                     else {
75600                         for (var _i = 0, _a = symbolAccessibilityResult.aliasesToMakeVisible; _i < _a.length; _i++) {
75601                             var ref = _a[_i];
75602                             ts.pushIfUnique(lateMarkedStatements, ref);
75603                         }
75604                     }
75605                 }
75606             }
75607             else {
75608                 var errorInfo = getSymbolAccessibilityDiagnostic(symbolAccessibilityResult);
75609                 if (errorInfo) {
75610                     if (errorInfo.typeName) {
75611                         context.addDiagnostic(ts.createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, ts.getTextOfNode(errorInfo.typeName), symbolAccessibilityResult.errorSymbolName, symbolAccessibilityResult.errorModuleName));
75612                     }
75613                     else {
75614                         context.addDiagnostic(ts.createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccessibilityResult.errorSymbolName, symbolAccessibilityResult.errorModuleName));
75615                     }
75616                 }
75617             }
75618         }
75619         function trackExternalModuleSymbolOfImportTypeNode(symbol) {
75620             if (!isBundledEmit) {
75621                 (exportedModulesFromDeclarationEmit || (exportedModulesFromDeclarationEmit = [])).push(symbol);
75622             }
75623         }
75624         function trackSymbol(symbol, enclosingDeclaration, meaning) {
75625             if (symbol.flags & 262144)
75626                 return;
75627             handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, true));
75628             recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning));
75629         }
75630         function reportPrivateInBaseOfClassExpression(propertyName) {
75631             if (errorNameNode) {
75632                 context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.Property_0_of_exported_class_expression_may_not_be_private_or_protected, propertyName));
75633             }
75634         }
75635         function reportInaccessibleUniqueSymbolError() {
75636             if (errorNameNode) {
75637                 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"));
75638             }
75639         }
75640         function reportCyclicStructureError() {
75641             if (errorNameNode) {
75642                 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)));
75643             }
75644         }
75645         function reportInaccessibleThisError() {
75646             if (errorNameNode) {
75647                 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"));
75648             }
75649         }
75650         function reportLikelyUnsafeImportRequiredError(specifier) {
75651             if (errorNameNode) {
75652                 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));
75653             }
75654         }
75655         function reportNonlocalAugmentation(containingFile, parentSymbol, symbol) {
75656             var primaryDeclaration = ts.find(parentSymbol.declarations, function (d) { return ts.getSourceFileOfNode(d) === containingFile; });
75657             var augmentingDeclarations = ts.filter(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== containingFile; });
75658             for (var _i = 0, augmentingDeclarations_1 = augmentingDeclarations; _i < augmentingDeclarations_1.length; _i++) {
75659                 var augmentations = augmentingDeclarations_1[_i];
75660                 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)));
75661             }
75662         }
75663         function transformDeclarationsForJS(sourceFile, bundled) {
75664             var oldDiag = getSymbolAccessibilityDiagnostic;
75665             getSymbolAccessibilityDiagnostic = function (s) { return ({
75666                 diagnosticMessage: s.errorModuleName
75667                     ? ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit
75668                     : ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit,
75669                 errorNode: s.errorNode || sourceFile
75670             }); };
75671             var result = resolver.getDeclarationStatementsForSourceFile(sourceFile, declarationEmitNodeBuilderFlags, symbolTracker, bundled);
75672             getSymbolAccessibilityDiagnostic = oldDiag;
75673             return result;
75674         }
75675         function transformRoot(node) {
75676             if (node.kind === 290 && node.isDeclarationFile) {
75677                 return node;
75678             }
75679             if (node.kind === 291) {
75680                 isBundledEmit = true;
75681                 refs = ts.createMap();
75682                 libs = ts.createMap();
75683                 var hasNoDefaultLib_1 = false;
75684                 var bundle = ts.createBundle(ts.map(node.sourceFiles, function (sourceFile) {
75685                     if (sourceFile.isDeclarationFile)
75686                         return undefined;
75687                     hasNoDefaultLib_1 = hasNoDefaultLib_1 || sourceFile.hasNoDefaultLib;
75688                     currentSourceFile = sourceFile;
75689                     enclosingDeclaration = sourceFile;
75690                     lateMarkedStatements = undefined;
75691                     suppressNewDiagnosticContexts = false;
75692                     lateStatementReplacementMap = ts.createMap();
75693                     getSymbolAccessibilityDiagnostic = throwDiagnostic;
75694                     needsScopeFixMarker = false;
75695                     resultHasScopeMarker = false;
75696                     collectReferences(sourceFile, refs);
75697                     collectLibs(sourceFile, libs);
75698                     if (ts.isExternalOrCommonJsModule(sourceFile) || ts.isJsonSourceFile(sourceFile)) {
75699                         resultHasExternalModuleIndicator = false;
75700                         needsDeclare = false;
75701                         var statements = ts.isSourceFileJS(sourceFile) ? ts.createNodeArray(transformDeclarationsForJS(sourceFile, true)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements);
75702                         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, []);
75703                         return newFile;
75704                     }
75705                     needsDeclare = true;
75706                     var updated = ts.isSourceFileJS(sourceFile) ? ts.createNodeArray(transformDeclarationsForJS(sourceFile)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements);
75707                     return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), true, [], [], false, []);
75708                 }), ts.mapDefined(node.prepends, function (prepend) {
75709                     if (prepend.kind === 293) {
75710                         var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal);
75711                         hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib;
75712                         collectReferences(sourceFile, refs);
75713                         recordTypeReferenceDirectivesIfNecessary(sourceFile.typeReferenceDirectives);
75714                         collectLibs(sourceFile, libs);
75715                         return sourceFile;
75716                     }
75717                     return prepend;
75718                 }));
75719                 bundle.syntheticFileReferences = [];
75720                 bundle.syntheticTypeReferences = getFileReferencesForUsedTypeReferences();
75721                 bundle.syntheticLibReferences = getLibReferences();
75722                 bundle.hasNoDefaultLib = hasNoDefaultLib_1;
75723                 var outputFilePath_1 = ts.getDirectoryPath(ts.normalizeSlashes(ts.getOutputPathsFor(node, host, true).declarationFilePath));
75724                 var referenceVisitor_1 = mapReferencesIntoArray(bundle.syntheticFileReferences, outputFilePath_1);
75725                 refs.forEach(referenceVisitor_1);
75726                 return bundle;
75727             }
75728             needsDeclare = true;
75729             needsScopeFixMarker = false;
75730             resultHasScopeMarker = false;
75731             enclosingDeclaration = node;
75732             currentSourceFile = node;
75733             getSymbolAccessibilityDiagnostic = throwDiagnostic;
75734             isBundledEmit = false;
75735             resultHasExternalModuleIndicator = false;
75736             suppressNewDiagnosticContexts = false;
75737             lateMarkedStatements = undefined;
75738             lateStatementReplacementMap = ts.createMap();
75739             necessaryTypeReferences = undefined;
75740             refs = collectReferences(currentSourceFile, ts.createMap());
75741             libs = collectLibs(currentSourceFile, ts.createMap());
75742             var references = [];
75743             var outputFilePath = ts.getDirectoryPath(ts.normalizeSlashes(ts.getOutputPathsFor(node, host, true).declarationFilePath));
75744             var referenceVisitor = mapReferencesIntoArray(references, outputFilePath);
75745             var combinedStatements;
75746             if (ts.isSourceFileJS(currentSourceFile)) {
75747                 combinedStatements = ts.createNodeArray(transformDeclarationsForJS(node));
75748                 refs.forEach(referenceVisitor);
75749                 emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax);
75750             }
75751             else {
75752                 var statements = ts.visitNodes(node.statements, visitDeclarationStatements);
75753                 combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements);
75754                 refs.forEach(referenceVisitor);
75755                 emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax);
75756                 if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) {
75757                     combinedStatements = ts.setTextRange(ts.createNodeArray(__spreadArrays(combinedStatements, [ts.createEmptyExports()])), combinedStatements);
75758                 }
75759             }
75760             var updated = ts.updateSourceFileNode(node, combinedStatements, true, references, getFileReferencesForUsedTypeReferences(), node.hasNoDefaultLib, getLibReferences());
75761             updated.exportedModulesFromDeclarationEmit = exportedModulesFromDeclarationEmit;
75762             return updated;
75763             function getLibReferences() {
75764                 return ts.map(ts.arrayFrom(libs.keys()), function (lib) { return ({ fileName: lib, pos: -1, end: -1 }); });
75765             }
75766             function getFileReferencesForUsedTypeReferences() {
75767                 return necessaryTypeReferences ? ts.mapDefined(ts.arrayFrom(necessaryTypeReferences.keys()), getFileReferenceForTypeName) : [];
75768             }
75769             function getFileReferenceForTypeName(typeName) {
75770                 if (emittedImports) {
75771                     for (var _i = 0, emittedImports_1 = emittedImports; _i < emittedImports_1.length; _i++) {
75772                         var importStatement = emittedImports_1[_i];
75773                         if (ts.isImportEqualsDeclaration(importStatement) && ts.isExternalModuleReference(importStatement.moduleReference)) {
75774                             var expr = importStatement.moduleReference.expression;
75775                             if (ts.isStringLiteralLike(expr) && expr.text === typeName) {
75776                                 return undefined;
75777                             }
75778                         }
75779                         else if (ts.isImportDeclaration(importStatement) && ts.isStringLiteral(importStatement.moduleSpecifier) && importStatement.moduleSpecifier.text === typeName) {
75780                             return undefined;
75781                         }
75782                     }
75783                 }
75784                 return { fileName: typeName, pos: -1, end: -1 };
75785             }
75786             function mapReferencesIntoArray(references, outputFilePath) {
75787                 return function (file) {
75788                     var declFileName;
75789                     if (file.isDeclarationFile) {
75790                         declFileName = file.fileName;
75791                     }
75792                     else {
75793                         if (isBundledEmit && ts.contains(node.sourceFiles, file))
75794                             return;
75795                         var paths = ts.getOutputPathsFor(file, host, true);
75796                         declFileName = paths.declarationFilePath || paths.jsFilePath || file.fileName;
75797                     }
75798                     if (declFileName) {
75799                         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);
75800                         if (!ts.pathIsRelative(specifier)) {
75801                             recordTypeReferenceDirectivesIfNecessary([specifier]);
75802                             return;
75803                         }
75804                         var fileName = ts.getRelativePathToDirectoryOrUrl(outputFilePath, declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, false);
75805                         if (ts.startsWith(fileName, "./") && ts.hasExtension(fileName)) {
75806                             fileName = fileName.substring(2);
75807                         }
75808                         if (ts.startsWith(fileName, "node_modules/") || ts.pathContainsNodeModules(fileName)) {
75809                             return;
75810                         }
75811                         references.push({ pos: -1, end: -1, fileName: fileName });
75812                     }
75813                 };
75814             }
75815         }
75816         function collectReferences(sourceFile, ret) {
75817             if (noResolve || (!ts.isUnparsedSource(sourceFile) && ts.isSourceFileJS(sourceFile)))
75818                 return ret;
75819             ts.forEach(sourceFile.referencedFiles, function (f) {
75820                 var elem = host.getSourceFileFromReference(sourceFile, f);
75821                 if (elem) {
75822                     ret.set("" + ts.getOriginalNodeId(elem), elem);
75823                 }
75824             });
75825             return ret;
75826         }
75827         function collectLibs(sourceFile, ret) {
75828             ts.forEach(sourceFile.libReferenceDirectives, function (ref) {
75829                 var lib = host.getLibFileFromReference(ref);
75830                 if (lib) {
75831                     ret.set(ts.toFileNameLowerCase(ref.fileName), true);
75832                 }
75833             });
75834             return ret;
75835         }
75836         function filterBindingPatternInitializers(name) {
75837             if (name.kind === 75) {
75838                 return name;
75839             }
75840             else {
75841                 if (name.kind === 190) {
75842                     return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement));
75843                 }
75844                 else {
75845                     return ts.updateObjectBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement));
75846                 }
75847             }
75848             function visitBindingElement(elem) {
75849                 if (elem.kind === 215) {
75850                     return elem;
75851                 }
75852                 return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
75853             }
75854         }
75855         function ensureParameter(p, modifierMask, type) {
75856             var oldDiag;
75857             if (!suppressNewDiagnosticContexts) {
75858                 oldDiag = getSymbolAccessibilityDiagnostic;
75859                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p);
75860             }
75861             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));
75862             if (!suppressNewDiagnosticContexts) {
75863                 getSymbolAccessibilityDiagnostic = oldDiag;
75864             }
75865             return newParam;
75866         }
75867         function shouldPrintWithInitializer(node) {
75868             return canHaveLiteralInitializer(node) && resolver.isLiteralConstDeclaration(ts.getParseTreeNode(node));
75869         }
75870         function ensureNoInitializer(node) {
75871             if (shouldPrintWithInitializer(node)) {
75872                 return resolver.createLiteralConstValue(ts.getParseTreeNode(node), symbolTracker);
75873             }
75874             return undefined;
75875         }
75876         function ensureType(node, type, ignorePrivate) {
75877             if (!ignorePrivate && ts.hasModifier(node, 8)) {
75878                 return;
75879             }
75880             if (shouldPrintWithInitializer(node)) {
75881                 return;
75882             }
75883             var shouldUseResolverType = node.kind === 156 &&
75884                 (resolver.isRequiredInitializedParameter(node) ||
75885                     resolver.isOptionalUninitializedParameterProperty(node));
75886             if (type && !shouldUseResolverType) {
75887                 return ts.visitNode(type, visitDeclarationSubtree);
75888             }
75889             if (!ts.getParseTreeNode(node)) {
75890                 return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(125);
75891             }
75892             if (node.kind === 164) {
75893                 return ts.createKeywordTypeNode(125);
75894             }
75895             errorNameNode = node.name;
75896             var oldDiag;
75897             if (!suppressNewDiagnosticContexts) {
75898                 oldDiag = getSymbolAccessibilityDiagnostic;
75899                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node);
75900             }
75901             if (node.kind === 242 || node.kind === 191) {
75902                 return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker));
75903             }
75904             if (node.kind === 156
75905                 || node.kind === 159
75906                 || node.kind === 158) {
75907                 if (!node.initializer)
75908                     return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType));
75909                 return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType) || resolver.createTypeOfExpression(node.initializer, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker));
75910             }
75911             return cleanup(resolver.createReturnTypeOfSignatureDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker));
75912             function cleanup(returnValue) {
75913                 errorNameNode = undefined;
75914                 if (!suppressNewDiagnosticContexts) {
75915                     getSymbolAccessibilityDiagnostic = oldDiag;
75916                 }
75917                 return returnValue || ts.createKeywordTypeNode(125);
75918             }
75919         }
75920         function isDeclarationAndNotVisible(node) {
75921             node = ts.getParseTreeNode(node);
75922             switch (node.kind) {
75923                 case 244:
75924                 case 249:
75925                 case 246:
75926                 case 245:
75927                 case 247:
75928                 case 248:
75929                     return !resolver.isDeclarationVisible(node);
75930                 case 242:
75931                     return !getBindingNameVisible(node);
75932                 case 253:
75933                 case 254:
75934                 case 260:
75935                 case 259:
75936                     return false;
75937             }
75938             return false;
75939         }
75940         function getBindingNameVisible(elem) {
75941             if (ts.isOmittedExpression(elem)) {
75942                 return false;
75943             }
75944             if (ts.isBindingPattern(elem.name)) {
75945                 return ts.some(elem.name.elements, getBindingNameVisible);
75946             }
75947             else {
75948                 return resolver.isDeclarationVisible(elem);
75949             }
75950         }
75951         function updateParamsList(node, params, modifierMask) {
75952             if (ts.hasModifier(node, 8)) {
75953                 return undefined;
75954             }
75955             var newParams = ts.map(params, function (p) { return ensureParameter(p, modifierMask); });
75956             if (!newParams) {
75957                 return undefined;
75958             }
75959             return ts.createNodeArray(newParams, params.hasTrailingComma);
75960         }
75961         function updateAccessorParamsList(input, isPrivate) {
75962             var newParams;
75963             if (!isPrivate) {
75964                 var thisParameter = ts.getThisParameter(input);
75965                 if (thisParameter) {
75966                     newParams = [ensureParameter(thisParameter)];
75967                 }
75968             }
75969             if (ts.isSetAccessorDeclaration(input)) {
75970                 var newValueParameter = void 0;
75971                 if (!isPrivate) {
75972                     var valueParameter = ts.getSetAccessorValueParameter(input);
75973                     if (valueParameter) {
75974                         var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input));
75975                         newValueParameter = ensureParameter(valueParameter, undefined, accessorType);
75976                     }
75977                 }
75978                 if (!newValueParameter) {
75979                     newValueParameter = ts.createParameter(undefined, undefined, undefined, "value");
75980                 }
75981                 newParams = ts.append(newParams, newValueParameter);
75982             }
75983             return ts.createNodeArray(newParams || ts.emptyArray);
75984         }
75985         function ensureTypeParams(node, params) {
75986             return ts.hasModifier(node, 8) ? undefined : ts.visitNodes(params, visitDeclarationSubtree);
75987         }
75988         function isEnclosingDeclaration(node) {
75989             return ts.isSourceFile(node)
75990                 || ts.isTypeAliasDeclaration(node)
75991                 || ts.isModuleDeclaration(node)
75992                 || ts.isClassDeclaration(node)
75993                 || ts.isInterfaceDeclaration(node)
75994                 || ts.isFunctionLike(node)
75995                 || ts.isIndexSignatureDeclaration(node)
75996                 || ts.isMappedTypeNode(node);
75997         }
75998         function checkEntityNameVisibility(entityName, enclosingDeclaration) {
75999             var visibilityResult = resolver.isEntityNameVisible(entityName, enclosingDeclaration);
76000             handleSymbolAccessibilityError(visibilityResult);
76001             recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName));
76002         }
76003         function preserveJsDoc(updated, original) {
76004             if (ts.hasJSDocNodes(updated) && ts.hasJSDocNodes(original)) {
76005                 updated.jsDoc = original.jsDoc;
76006             }
76007             return ts.setCommentRange(updated, ts.getCommentRange(original));
76008         }
76009         function rewriteModuleSpecifier(parent, input) {
76010             if (!input)
76011                 return undefined;
76012             resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 249 && parent.kind !== 188);
76013             if (ts.isStringLiteralLike(input)) {
76014                 if (isBundledEmit) {
76015                     var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent);
76016                     if (newName) {
76017                         return ts.createLiteral(newName);
76018                     }
76019                 }
76020                 else {
76021                     var symbol = resolver.getSymbolOfExternalModuleSpecifier(input);
76022                     if (symbol) {
76023                         (exportedModulesFromDeclarationEmit || (exportedModulesFromDeclarationEmit = [])).push(symbol);
76024                     }
76025                 }
76026             }
76027             return input;
76028         }
76029         function transformImportEqualsDeclaration(decl) {
76030             if (!resolver.isDeclarationVisible(decl))
76031                 return;
76032             if (decl.moduleReference.kind === 265) {
76033                 var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl);
76034                 return ts.updateImportEqualsDeclaration(decl, undefined, decl.modifiers, decl.name, ts.updateExternalModuleReference(decl.moduleReference, rewriteModuleSpecifier(decl, specifier)));
76035             }
76036             else {
76037                 var oldDiag = getSymbolAccessibilityDiagnostic;
76038                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(decl);
76039                 checkEntityNameVisibility(decl.moduleReference, enclosingDeclaration);
76040                 getSymbolAccessibilityDiagnostic = oldDiag;
76041                 return decl;
76042             }
76043         }
76044         function transformImportDeclaration(decl) {
76045             if (!decl.importClause) {
76046                 return ts.updateImportDeclaration(decl, undefined, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier));
76047             }
76048             var visibleDefaultBinding = decl.importClause && decl.importClause.name && resolver.isDeclarationVisible(decl.importClause) ? decl.importClause.name : undefined;
76049             if (!decl.importClause.namedBindings) {
76050                 return visibleDefaultBinding && ts.updateImportDeclaration(decl, undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, undefined, decl.importClause.isTypeOnly), rewriteModuleSpecifier(decl, decl.moduleSpecifier));
76051             }
76052             if (decl.importClause.namedBindings.kind === 256) {
76053                 var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : undefined;
76054                 return visibleDefaultBinding || namedBindings ? ts.updateImportDeclaration(decl, undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, namedBindings, decl.importClause.isTypeOnly), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined;
76055             }
76056             var bindingList = ts.mapDefined(decl.importClause.namedBindings.elements, function (b) { return resolver.isDeclarationVisible(b) ? b : undefined; });
76057             if ((bindingList && bindingList.length) || visibleDefaultBinding) {
76058                 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));
76059             }
76060             if (resolver.isImportRequiredByAugmentation(decl)) {
76061                 return ts.updateImportDeclaration(decl, undefined, decl.modifiers, undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier));
76062             }
76063         }
76064         function transformAndReplaceLatePaintedStatements(statements) {
76065             while (ts.length(lateMarkedStatements)) {
76066                 var i = lateMarkedStatements.shift();
76067                 if (!ts.isLateVisibilityPaintedStatement(i)) {
76068                     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));
76069                 }
76070                 var priorNeedsDeclare = needsDeclare;
76071                 needsDeclare = i.parent && ts.isSourceFile(i.parent) && !(ts.isExternalModule(i.parent) && isBundledEmit);
76072                 var result = transformTopLevelDeclaration(i);
76073                 needsDeclare = priorNeedsDeclare;
76074                 lateStatementReplacementMap.set("" + ts.getOriginalNodeId(i), result);
76075             }
76076             return ts.visitNodes(statements, visitLateVisibilityMarkedStatements);
76077             function visitLateVisibilityMarkedStatements(statement) {
76078                 if (ts.isLateVisibilityPaintedStatement(statement)) {
76079                     var key = "" + ts.getOriginalNodeId(statement);
76080                     if (lateStatementReplacementMap.has(key)) {
76081                         var result = lateStatementReplacementMap.get(key);
76082                         lateStatementReplacementMap.delete(key);
76083                         if (result) {
76084                             if (ts.isArray(result) ? ts.some(result, ts.needsScopeMarker) : ts.needsScopeMarker(result)) {
76085                                 needsScopeFixMarker = true;
76086                             }
76087                             if (ts.isSourceFile(statement.parent) && (ts.isArray(result) ? ts.some(result, ts.isExternalModuleIndicator) : ts.isExternalModuleIndicator(result))) {
76088                                 resultHasExternalModuleIndicator = true;
76089                             }
76090                         }
76091                         return result;
76092                     }
76093                 }
76094                 return statement;
76095             }
76096         }
76097         function visitDeclarationSubtree(input) {
76098             if (shouldStripInternal(input))
76099                 return;
76100             if (ts.isDeclaration(input)) {
76101                 if (isDeclarationAndNotVisible(input))
76102                     return;
76103                 if (ts.hasDynamicName(input) && !resolver.isLateBound(ts.getParseTreeNode(input))) {
76104                     return;
76105                 }
76106             }
76107             if (ts.isFunctionLike(input) && resolver.isImplementationOfOverload(input))
76108                 return;
76109             if (ts.isSemicolonClassElement(input))
76110                 return;
76111             var previousEnclosingDeclaration;
76112             if (isEnclosingDeclaration(input)) {
76113                 previousEnclosingDeclaration = enclosingDeclaration;
76114                 enclosingDeclaration = input;
76115             }
76116             var oldDiag = getSymbolAccessibilityDiagnostic;
76117             var canProduceDiagnostic = ts.canProduceDiagnostics(input);
76118             var oldWithinObjectLiteralType = suppressNewDiagnosticContexts;
76119             var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 173 || input.kind === 186) && input.parent.kind !== 247);
76120             if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) {
76121                 if (ts.hasModifier(input, 8)) {
76122                     if (input.symbol && input.symbol.declarations && input.symbol.declarations[0] !== input)
76123                         return;
76124                     return cleanup(ts.createProperty(undefined, ensureModifiers(input), input.name, undefined, undefined, undefined));
76125                 }
76126             }
76127             if (canProduceDiagnostic && !suppressNewDiagnosticContexts) {
76128                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(input);
76129             }
76130             if (ts.isTypeQueryNode(input)) {
76131                 checkEntityNameVisibility(input.exprName, enclosingDeclaration);
76132             }
76133             if (shouldEnterSuppressNewDiagnosticsContextContext) {
76134                 suppressNewDiagnosticContexts = true;
76135             }
76136             if (isProcessedComponent(input)) {
76137                 switch (input.kind) {
76138                     case 216: {
76139                         if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) {
76140                             checkEntityNameVisibility(input.expression, enclosingDeclaration);
76141                         }
76142                         var node = ts.visitEachChild(input, visitDeclarationSubtree, context);
76143                         return cleanup(ts.updateExpressionWithTypeArguments(node, ts.parenthesizeTypeParameters(node.typeArguments), node.expression));
76144                     }
76145                     case 169: {
76146                         checkEntityNameVisibility(input.typeName, enclosingDeclaration);
76147                         var node = ts.visitEachChild(input, visitDeclarationSubtree, context);
76148                         return cleanup(ts.updateTypeReferenceNode(node, node.typeName, ts.parenthesizeTypeParameters(node.typeArguments)));
76149                     }
76150                     case 166:
76151                         return cleanup(ts.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)));
76152                     case 162: {
76153                         var ctor = ts.createSignatureDeclaration(162, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters, 0), undefined);
76154                         ctor.modifiers = ts.createNodeArray(ensureModifiers(input));
76155                         return cleanup(ctor);
76156                     }
76157                     case 161: {
76158                         if (ts.isPrivateIdentifier(input.name)) {
76159                             return cleanup(undefined);
76160                         }
76161                         var sig = ts.createSignatureDeclaration(160, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type));
76162                         sig.name = input.name;
76163                         sig.modifiers = ts.createNodeArray(ensureModifiers(input));
76164                         sig.questionToken = input.questionToken;
76165                         return cleanup(sig);
76166                     }
76167                     case 163: {
76168                         if (ts.isPrivateIdentifier(input.name)) {
76169                             return cleanup(undefined);
76170                         }
76171                         var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input));
76172                         return cleanup(ts.updateGetAccessor(input, undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasModifier(input, 8)), ensureType(input, accessorType), undefined));
76173                     }
76174                     case 164: {
76175                         if (ts.isPrivateIdentifier(input.name)) {
76176                             return cleanup(undefined);
76177                         }
76178                         return cleanup(ts.updateSetAccessor(input, undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasModifier(input, 8)), undefined));
76179                     }
76180                     case 159:
76181                         if (ts.isPrivateIdentifier(input.name)) {
76182                             return cleanup(undefined);
76183                         }
76184                         return cleanup(ts.updateProperty(input, undefined, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type), ensureNoInitializer(input)));
76185                     case 158:
76186                         if (ts.isPrivateIdentifier(input.name)) {
76187                             return cleanup(undefined);
76188                         }
76189                         return cleanup(ts.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type), ensureNoInitializer(input)));
76190                     case 160: {
76191                         if (ts.isPrivateIdentifier(input.name)) {
76192                             return cleanup(undefined);
76193                         }
76194                         return cleanup(ts.updateMethodSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), input.name, input.questionToken));
76195                     }
76196                     case 165: {
76197                         return cleanup(ts.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)));
76198                     }
76199                     case 167: {
76200                         return cleanup(ts.updateIndexSignature(input, undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(125)));
76201                     }
76202                     case 242: {
76203                         if (ts.isBindingPattern(input.name)) {
76204                             return recreateBindingPattern(input.name);
76205                         }
76206                         shouldEnterSuppressNewDiagnosticsContextContext = true;
76207                         suppressNewDiagnosticContexts = true;
76208                         return cleanup(ts.updateTypeScriptVariableDeclaration(input, input.name, undefined, ensureType(input, input.type), ensureNoInitializer(input)));
76209                     }
76210                     case 155: {
76211                         if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) {
76212                             return cleanup(ts.updateTypeParameterDeclaration(input, input.name, undefined, undefined));
76213                         }
76214                         return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context));
76215                     }
76216                     case 180: {
76217                         var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree);
76218                         var extendsType = ts.visitNode(input.extendsType, visitDeclarationSubtree);
76219                         var oldEnclosingDecl = enclosingDeclaration;
76220                         enclosingDeclaration = input.trueType;
76221                         var trueType = ts.visitNode(input.trueType, visitDeclarationSubtree);
76222                         enclosingDeclaration = oldEnclosingDecl;
76223                         var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree);
76224                         return cleanup(ts.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType));
76225                     }
76226                     case 170: {
76227                         return cleanup(ts.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree)));
76228                     }
76229                     case 171: {
76230                         return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree)));
76231                     }
76232                     case 188: {
76233                         if (!ts.isLiteralImportTypeNode(input))
76234                             return cleanup(input);
76235                         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));
76236                     }
76237                     default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: " + ts.SyntaxKind[input.kind]);
76238                 }
76239             }
76240             return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context));
76241             function cleanup(returnValue) {
76242                 if (returnValue && canProduceDiagnostic && ts.hasDynamicName(input)) {
76243                     checkName(input);
76244                 }
76245                 if (isEnclosingDeclaration(input)) {
76246                     enclosingDeclaration = previousEnclosingDeclaration;
76247                 }
76248                 if (canProduceDiagnostic && !suppressNewDiagnosticContexts) {
76249                     getSymbolAccessibilityDiagnostic = oldDiag;
76250                 }
76251                 if (shouldEnterSuppressNewDiagnosticsContextContext) {
76252                     suppressNewDiagnosticContexts = oldWithinObjectLiteralType;
76253                 }
76254                 if (returnValue === input) {
76255                     return returnValue;
76256                 }
76257                 return returnValue && ts.setOriginalNode(preserveJsDoc(returnValue, input), input);
76258             }
76259         }
76260         function isPrivateMethodTypeParameter(node) {
76261             return node.parent.kind === 161 && ts.hasModifier(node.parent, 8);
76262         }
76263         function visitDeclarationStatements(input) {
76264             if (!isPreservedDeclarationStatement(input)) {
76265                 return;
76266             }
76267             if (shouldStripInternal(input))
76268                 return;
76269             switch (input.kind) {
76270                 case 260: {
76271                     if (ts.isSourceFile(input.parent)) {
76272                         resultHasExternalModuleIndicator = true;
76273                     }
76274                     resultHasScopeMarker = true;
76275                     return ts.updateExportDeclaration(input, undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier), input.isTypeOnly);
76276                 }
76277                 case 259: {
76278                     if (ts.isSourceFile(input.parent)) {
76279                         resultHasExternalModuleIndicator = true;
76280                     }
76281                     resultHasScopeMarker = true;
76282                     if (input.expression.kind === 75) {
76283                         return input;
76284                     }
76285                     else {
76286                         var newId = ts.createOptimisticUniqueName("_default");
76287                         getSymbolAccessibilityDiagnostic = function () { return ({
76288                             diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0,
76289                             errorNode: input
76290                         }); };
76291                         var varDecl = ts.createVariableDeclaration(newId, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), undefined);
76292                         var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(130)] : [], ts.createVariableDeclarationList([varDecl], 2));
76293                         return [statement, ts.updateExportAssignment(input, input.decorators, input.modifiers, newId)];
76294                     }
76295                 }
76296             }
76297             var result = transformTopLevelDeclaration(input);
76298             lateStatementReplacementMap.set("" + ts.getOriginalNodeId(input), result);
76299             return input;
76300         }
76301         function stripExportModifiers(statement) {
76302             if (ts.isImportEqualsDeclaration(statement) || ts.hasModifier(statement, 512)) {
76303                 return statement;
76304             }
76305             var clone = ts.getMutableClone(statement);
76306             var modifiers = ts.createModifiersFromModifierFlags(ts.getModifierFlags(statement) & (3071 ^ 1));
76307             clone.modifiers = modifiers.length ? ts.createNodeArray(modifiers) : undefined;
76308             return clone;
76309         }
76310         function transformTopLevelDeclaration(input) {
76311             if (shouldStripInternal(input))
76312                 return;
76313             switch (input.kind) {
76314                 case 253: {
76315                     return transformImportEqualsDeclaration(input);
76316                 }
76317                 case 254: {
76318                     return transformImportDeclaration(input);
76319                 }
76320             }
76321             if (ts.isDeclaration(input) && isDeclarationAndNotVisible(input))
76322                 return;
76323             if (ts.isFunctionLike(input) && resolver.isImplementationOfOverload(input))
76324                 return;
76325             var previousEnclosingDeclaration;
76326             if (isEnclosingDeclaration(input)) {
76327                 previousEnclosingDeclaration = enclosingDeclaration;
76328                 enclosingDeclaration = input;
76329             }
76330             var canProdiceDiagnostic = ts.canProduceDiagnostics(input);
76331             var oldDiag = getSymbolAccessibilityDiagnostic;
76332             if (canProdiceDiagnostic) {
76333                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(input);
76334             }
76335             var previousNeedsDeclare = needsDeclare;
76336             switch (input.kind) {
76337                 case 247:
76338                     return cleanup(ts.updateTypeAliasDeclaration(input, undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode)));
76339                 case 246: {
76340                     return cleanup(ts.updateInterfaceDeclaration(input, undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree)));
76341                 }
76342                 case 244: {
76343                     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));
76344                     if (clean && resolver.isExpandoFunctionDeclaration(input)) {
76345                         var props = resolver.getPropertiesOfContainerFunction(input);
76346                         var fakespace_1 = ts.createModuleDeclaration(undefined, undefined, clean.name || ts.createIdentifier("_default"), ts.createModuleBlock([]), 16);
76347                         fakespace_1.flags ^= 8;
76348                         fakespace_1.parent = enclosingDeclaration;
76349                         fakespace_1.locals = ts.createSymbolTable(props);
76350                         fakespace_1.symbol = props[0].parent;
76351                         var declarations = ts.mapDefined(props, function (p) {
76352                             if (!ts.isPropertyAccessExpression(p.valueDeclaration)) {
76353                                 return undefined;
76354                             }
76355                             getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p.valueDeclaration);
76356                             var type = resolver.createTypeOfDeclaration(p.valueDeclaration, fakespace_1, declarationEmitNodeBuilderFlags, symbolTracker);
76357                             getSymbolAccessibilityDiagnostic = oldDiag;
76358                             var varDecl = ts.createVariableDeclaration(ts.unescapeLeadingUnderscores(p.escapedName), type, undefined);
76359                             return ts.createVariableStatement(undefined, ts.createVariableDeclarationList([varDecl]));
76360                         });
76361                         var namespaceDecl = ts.createModuleDeclaration(undefined, ensureModifiers(input), input.name, ts.createModuleBlock(declarations), 16);
76362                         if (!ts.hasModifier(clean, 512)) {
76363                             return [clean, namespaceDecl];
76364                         }
76365                         var modifiers = ts.createModifiersFromModifierFlags((ts.getModifierFlags(clean) & ~513) | 2);
76366                         var cleanDeclaration = ts.updateFunctionDeclaration(clean, undefined, modifiers, undefined, clean.name, clean.typeParameters, clean.parameters, clean.type, undefined);
76367                         var namespaceDeclaration = ts.updateModuleDeclaration(namespaceDecl, undefined, modifiers, namespaceDecl.name, namespaceDecl.body);
76368                         var exportDefaultDeclaration = ts.createExportAssignment(undefined, undefined, false, namespaceDecl.name);
76369                         if (ts.isSourceFile(input.parent)) {
76370                             resultHasExternalModuleIndicator = true;
76371                         }
76372                         resultHasScopeMarker = true;
76373                         return [cleanDeclaration, namespaceDeclaration, exportDefaultDeclaration];
76374                     }
76375                     else {
76376                         return clean;
76377                     }
76378                 }
76379                 case 249: {
76380                     needsDeclare = false;
76381                     var inner = input.body;
76382                     if (inner && inner.kind === 250) {
76383                         var oldNeedsScopeFix = needsScopeFixMarker;
76384                         var oldHasScopeFix = resultHasScopeMarker;
76385                         resultHasScopeMarker = false;
76386                         needsScopeFixMarker = false;
76387                         var statements = ts.visitNodes(inner.statements, visitDeclarationStatements);
76388                         var lateStatements = transformAndReplaceLatePaintedStatements(statements);
76389                         if (input.flags & 8388608) {
76390                             needsScopeFixMarker = false;
76391                         }
76392                         if (!ts.isGlobalScopeAugmentation(input) && !hasScopeMarker(lateStatements) && !resultHasScopeMarker) {
76393                             if (needsScopeFixMarker) {
76394                                 lateStatements = ts.createNodeArray(__spreadArrays(lateStatements, [ts.createEmptyExports()]));
76395                             }
76396                             else {
76397                                 lateStatements = ts.visitNodes(lateStatements, stripExportModifiers);
76398                             }
76399                         }
76400                         var body = ts.updateModuleBlock(inner, lateStatements);
76401                         needsDeclare = previousNeedsDeclare;
76402                         needsScopeFixMarker = oldNeedsScopeFix;
76403                         resultHasScopeMarker = oldHasScopeFix;
76404                         var mods = ensureModifiers(input);
76405                         return cleanup(ts.updateModuleDeclaration(input, undefined, mods, ts.isExternalModuleAugmentation(input) ? rewriteModuleSpecifier(input, input.name) : input.name, body));
76406                     }
76407                     else {
76408                         needsDeclare = previousNeedsDeclare;
76409                         var mods = ensureModifiers(input);
76410                         needsDeclare = false;
76411                         ts.visitNode(inner, visitDeclarationStatements);
76412                         var id = "" + ts.getOriginalNodeId(inner);
76413                         var body = lateStatementReplacementMap.get(id);
76414                         lateStatementReplacementMap.delete(id);
76415                         return cleanup(ts.updateModuleDeclaration(input, undefined, mods, input.name, body));
76416                     }
76417                 }
76418                 case 245: {
76419                     var modifiers = ts.createNodeArray(ensureModifiers(input));
76420                     var typeParameters = ensureTypeParams(input, input.typeParameters);
76421                     var ctor = ts.getFirstConstructorWithBody(input);
76422                     var parameterProperties = void 0;
76423                     if (ctor) {
76424                         var oldDiag_1 = getSymbolAccessibilityDiagnostic;
76425                         parameterProperties = ts.compact(ts.flatMap(ctor.parameters, function (param) {
76426                             if (!ts.hasModifier(param, 92) || shouldStripInternal(param))
76427                                 return;
76428                             getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param);
76429                             if (param.name.kind === 75) {
76430                                 return preserveJsDoc(ts.createProperty(undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param);
76431                             }
76432                             else {
76433                                 return walkBindingPattern(param.name);
76434                             }
76435                             function walkBindingPattern(pattern) {
76436                                 var elems;
76437                                 for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
76438                                     var elem = _a[_i];
76439                                     if (ts.isOmittedExpression(elem))
76440                                         continue;
76441                                     if (ts.isBindingPattern(elem.name)) {
76442                                         elems = ts.concatenate(elems, walkBindingPattern(elem.name));
76443                                     }
76444                                     elems = elems || [];
76445                                     elems.push(ts.createProperty(undefined, ensureModifiers(param), elem.name, undefined, ensureType(elem, undefined), undefined));
76446                                 }
76447                                 return elems;
76448                             }
76449                         }));
76450                         getSymbolAccessibilityDiagnostic = oldDiag_1;
76451                     }
76452                     var hasPrivateIdentifier = ts.some(input.members, function (member) { return !!member.name && ts.isPrivateIdentifier(member.name); });
76453                     var privateIdentifier = hasPrivateIdentifier ? [
76454                         ts.createProperty(undefined, undefined, ts.createPrivateIdentifier("#private"), undefined, undefined, undefined)
76455                     ] : undefined;
76456                     var memberNodes = ts.concatenate(ts.concatenate(privateIdentifier, parameterProperties), ts.visitNodes(input.members, visitDeclarationSubtree));
76457                     var members = ts.createNodeArray(memberNodes);
76458                     var extendsClause_1 = ts.getEffectiveBaseTypeNode(input);
76459                     if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 100) {
76460                         var oldId = input.name ? ts.unescapeLeadingUnderscores(input.name.escapedText) : "default";
76461                         var newId_1 = ts.createOptimisticUniqueName(oldId + "_base");
76462                         getSymbolAccessibilityDiagnostic = function () { return ({
76463                             diagnosticMessage: ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1,
76464                             errorNode: extendsClause_1,
76465                             typeName: input.name
76466                         }); };
76467                         var varDecl = ts.createVariableDeclaration(newId_1, resolver.createTypeOfExpression(extendsClause_1.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), undefined);
76468                         var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(130)] : [], ts.createVariableDeclarationList([varDecl], 2));
76469                         var heritageClauses = ts.createNodeArray(ts.map(input.heritageClauses, function (clause) {
76470                             if (clause.token === 90) {
76471                                 var oldDiag_2 = getSymbolAccessibilityDiagnostic;
76472                                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(clause.types[0]);
76473                                 var newClause = ts.updateHeritageClause(clause, ts.map(clause.types, function (t) { return ts.updateExpressionWithTypeArguments(t, ts.visitNodes(t.typeArguments, visitDeclarationSubtree), newId_1); }));
76474                                 getSymbolAccessibilityDiagnostic = oldDiag_2;
76475                                 return newClause;
76476                             }
76477                             return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 100; })), visitDeclarationSubtree));
76478                         }));
76479                         return [statement, cleanup(ts.updateClassDeclaration(input, undefined, modifiers, input.name, typeParameters, heritageClauses, members))];
76480                     }
76481                     else {
76482                         var heritageClauses = transformHeritageClauses(input.heritageClauses);
76483                         return cleanup(ts.updateClassDeclaration(input, undefined, modifiers, input.name, typeParameters, heritageClauses, members));
76484                     }
76485                 }
76486                 case 225: {
76487                     return cleanup(transformVariableStatement(input));
76488                 }
76489                 case 248: {
76490                     return cleanup(ts.updateEnumDeclaration(input, undefined, ts.createNodeArray(ensureModifiers(input)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) {
76491                         if (shouldStripInternal(m))
76492                             return;
76493                         var constValue = resolver.getConstantValue(m);
76494                         return preserveJsDoc(ts.updateEnumMember(m, m.name, constValue !== undefined ? ts.createLiteral(constValue) : undefined), m);
76495                     }))));
76496                 }
76497             }
76498             return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: " + ts.SyntaxKind[input.kind]);
76499             function cleanup(node) {
76500                 if (isEnclosingDeclaration(input)) {
76501                     enclosingDeclaration = previousEnclosingDeclaration;
76502                 }
76503                 if (canProdiceDiagnostic) {
76504                     getSymbolAccessibilityDiagnostic = oldDiag;
76505                 }
76506                 if (input.kind === 249) {
76507                     needsDeclare = previousNeedsDeclare;
76508                 }
76509                 if (node === input) {
76510                     return node;
76511                 }
76512                 return node && ts.setOriginalNode(preserveJsDoc(node, input), input);
76513             }
76514         }
76515         function transformVariableStatement(input) {
76516             if (!ts.forEach(input.declarationList.declarations, getBindingNameVisible))
76517                 return;
76518             var nodes = ts.visitNodes(input.declarationList.declarations, visitDeclarationSubtree);
76519             if (!ts.length(nodes))
76520                 return;
76521             return ts.updateVariableStatement(input, ts.createNodeArray(ensureModifiers(input)), ts.updateVariableDeclarationList(input.declarationList, nodes));
76522         }
76523         function recreateBindingPattern(d) {
76524             return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); }));
76525         }
76526         function recreateBindingElement(e) {
76527             if (e.kind === 215) {
76528                 return;
76529             }
76530             if (e.name) {
76531                 if (!getBindingNameVisible(e))
76532                     return;
76533                 if (ts.isBindingPattern(e.name)) {
76534                     return recreateBindingPattern(e.name);
76535                 }
76536                 else {
76537                     return ts.createVariableDeclaration(e.name, ensureType(e, undefined), undefined);
76538                 }
76539             }
76540         }
76541         function checkName(node) {
76542             var oldDiag;
76543             if (!suppressNewDiagnosticContexts) {
76544                 oldDiag = getSymbolAccessibilityDiagnostic;
76545                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNodeName(node);
76546             }
76547             errorNameNode = node.name;
76548             ts.Debug.assert(resolver.isLateBound(ts.getParseTreeNode(node)));
76549             var decl = node;
76550             var entityName = decl.name.expression;
76551             checkEntityNameVisibility(entityName, enclosingDeclaration);
76552             if (!suppressNewDiagnosticContexts) {
76553                 getSymbolAccessibilityDiagnostic = oldDiag;
76554             }
76555             errorNameNode = undefined;
76556         }
76557         function shouldStripInternal(node) {
76558             return !!stripInternal && !!node && isInternalDeclaration(node, currentSourceFile);
76559         }
76560         function isScopeMarker(node) {
76561             return ts.isExportAssignment(node) || ts.isExportDeclaration(node);
76562         }
76563         function hasScopeMarker(statements) {
76564             return ts.some(statements, isScopeMarker);
76565         }
76566         function ensureModifiers(node) {
76567             var currentFlags = ts.getModifierFlags(node);
76568             var newFlags = ensureModifierFlags(node);
76569             if (currentFlags === newFlags) {
76570                 return node.modifiers;
76571             }
76572             return ts.createModifiersFromModifierFlags(newFlags);
76573         }
76574         function ensureModifierFlags(node) {
76575             var mask = 3071 ^ (4 | 256);
76576             var additions = (needsDeclare && !isAlwaysType(node)) ? 2 : 0;
76577             var parentIsFile = node.parent.kind === 290;
76578             if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) {
76579                 mask ^= 2;
76580                 additions = 0;
76581             }
76582             return maskModifierFlags(node, mask, additions);
76583         }
76584         function getTypeAnnotationFromAllAccessorDeclarations(node, accessors) {
76585             var accessorType = getTypeAnnotationFromAccessor(node);
76586             if (!accessorType && node !== accessors.firstAccessor) {
76587                 accessorType = getTypeAnnotationFromAccessor(accessors.firstAccessor);
76588                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.firstAccessor);
76589             }
76590             if (!accessorType && accessors.secondAccessor && node !== accessors.secondAccessor) {
76591                 accessorType = getTypeAnnotationFromAccessor(accessors.secondAccessor);
76592                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.secondAccessor);
76593             }
76594             return accessorType;
76595         }
76596         function transformHeritageClauses(nodes) {
76597             return ts.createNodeArray(ts.filter(ts.map(nodes, function (clause) { return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) {
76598                 return ts.isEntityNameExpression(t.expression) || (clause.token === 90 && t.expression.kind === 100);
76599             })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; }));
76600         }
76601     }
76602     ts.transformDeclarations = transformDeclarations;
76603     function isAlwaysType(node) {
76604         if (node.kind === 246) {
76605             return true;
76606         }
76607         return false;
76608     }
76609     function maskModifiers(node, modifierMask, modifierAdditions) {
76610         return ts.createModifiersFromModifierFlags(maskModifierFlags(node, modifierMask, modifierAdditions));
76611     }
76612     function maskModifierFlags(node, modifierMask, modifierAdditions) {
76613         if (modifierMask === void 0) { modifierMask = 3071 ^ 4; }
76614         if (modifierAdditions === void 0) { modifierAdditions = 0; }
76615         var flags = (ts.getModifierFlags(node) & modifierMask) | modifierAdditions;
76616         if (flags & 512 && !(flags & 1)) {
76617             flags ^= 1;
76618         }
76619         if (flags & 512 && flags & 2) {
76620             flags ^= 2;
76621         }
76622         return flags;
76623     }
76624     function getTypeAnnotationFromAccessor(accessor) {
76625         if (accessor) {
76626             return accessor.kind === 163
76627                 ? accessor.type
76628                 : accessor.parameters.length > 0
76629                     ? accessor.parameters[0].type
76630                     : undefined;
76631         }
76632     }
76633     function canHaveLiteralInitializer(node) {
76634         switch (node.kind) {
76635             case 159:
76636             case 158:
76637                 return !ts.hasModifier(node, 8);
76638             case 156:
76639             case 242:
76640                 return true;
76641         }
76642         return false;
76643     }
76644     function isPreservedDeclarationStatement(node) {
76645         switch (node.kind) {
76646             case 244:
76647             case 249:
76648             case 253:
76649             case 246:
76650             case 245:
76651             case 247:
76652             case 248:
76653             case 225:
76654             case 254:
76655             case 260:
76656             case 259:
76657                 return true;
76658         }
76659         return false;
76660     }
76661     function isProcessedComponent(node) {
76662         switch (node.kind) {
76663             case 166:
76664             case 162:
76665             case 161:
76666             case 163:
76667             case 164:
76668             case 159:
76669             case 158:
76670             case 160:
76671             case 165:
76672             case 167:
76673             case 242:
76674             case 155:
76675             case 216:
76676             case 169:
76677             case 180:
76678             case 170:
76679             case 171:
76680             case 188:
76681                 return true;
76682         }
76683         return false;
76684     }
76685 })(ts || (ts = {}));
76686 var ts;
76687 (function (ts) {
76688     function getModuleTransformer(moduleKind) {
76689         switch (moduleKind) {
76690             case ts.ModuleKind.ESNext:
76691             case ts.ModuleKind.ES2020:
76692             case ts.ModuleKind.ES2015:
76693                 return ts.transformECMAScriptModule;
76694             case ts.ModuleKind.System:
76695                 return ts.transformSystemModule;
76696             default:
76697                 return ts.transformModule;
76698         }
76699     }
76700     ts.noTransformers = { scriptTransformers: ts.emptyArray, declarationTransformers: ts.emptyArray };
76701     function getTransformers(compilerOptions, customTransformers, emitOnlyDtsFiles) {
76702         return {
76703             scriptTransformers: getScriptTransformers(compilerOptions, customTransformers, emitOnlyDtsFiles),
76704             declarationTransformers: getDeclarationTransformers(customTransformers),
76705         };
76706     }
76707     ts.getTransformers = getTransformers;
76708     function getScriptTransformers(compilerOptions, customTransformers, emitOnlyDtsFiles) {
76709         if (emitOnlyDtsFiles)
76710             return ts.emptyArray;
76711         var jsx = compilerOptions.jsx;
76712         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
76713         var moduleKind = ts.getEmitModuleKind(compilerOptions);
76714         var transformers = [];
76715         ts.addRange(transformers, customTransformers && ts.map(customTransformers.before, wrapScriptTransformerFactory));
76716         transformers.push(ts.transformTypeScript);
76717         transformers.push(ts.transformClassFields);
76718         if (jsx === 2) {
76719             transformers.push(ts.transformJsx);
76720         }
76721         if (languageVersion < 99) {
76722             transformers.push(ts.transformESNext);
76723         }
76724         if (languageVersion < 7) {
76725             transformers.push(ts.transformES2020);
76726         }
76727         if (languageVersion < 6) {
76728             transformers.push(ts.transformES2019);
76729         }
76730         if (languageVersion < 5) {
76731             transformers.push(ts.transformES2018);
76732         }
76733         if (languageVersion < 4) {
76734             transformers.push(ts.transformES2017);
76735         }
76736         if (languageVersion < 3) {
76737             transformers.push(ts.transformES2016);
76738         }
76739         if (languageVersion < 2) {
76740             transformers.push(ts.transformES2015);
76741             transformers.push(ts.transformGenerators);
76742         }
76743         transformers.push(getModuleTransformer(moduleKind));
76744         if (languageVersion < 1) {
76745             transformers.push(ts.transformES5);
76746         }
76747         ts.addRange(transformers, customTransformers && ts.map(customTransformers.after, wrapScriptTransformerFactory));
76748         return transformers;
76749     }
76750     function getDeclarationTransformers(customTransformers) {
76751         var transformers = [];
76752         transformers.push(ts.transformDeclarations);
76753         ts.addRange(transformers, customTransformers && ts.map(customTransformers.afterDeclarations, wrapDeclarationTransformerFactory));
76754         return transformers;
76755     }
76756     function wrapCustomTransformer(transformer) {
76757         return function (node) { return ts.isBundle(node) ? transformer.transformBundle(node) : transformer.transformSourceFile(node); };
76758     }
76759     function wrapCustomTransformerFactory(transformer, handleDefault) {
76760         return function (context) {
76761             var customTransformer = transformer(context);
76762             return typeof customTransformer === "function"
76763                 ? handleDefault(customTransformer)
76764                 : wrapCustomTransformer(customTransformer);
76765         };
76766     }
76767     function wrapScriptTransformerFactory(transformer) {
76768         return wrapCustomTransformerFactory(transformer, ts.chainBundle);
76769     }
76770     function wrapDeclarationTransformerFactory(transformer) {
76771         return wrapCustomTransformerFactory(transformer, ts.identity);
76772     }
76773     function noEmitSubstitution(_hint, node) {
76774         return node;
76775     }
76776     ts.noEmitSubstitution = noEmitSubstitution;
76777     function noEmitNotification(hint, node, callback) {
76778         callback(hint, node);
76779     }
76780     ts.noEmitNotification = noEmitNotification;
76781     function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) {
76782         var enabledSyntaxKindFeatures = new Array(331);
76783         var lexicalEnvironmentVariableDeclarations;
76784         var lexicalEnvironmentFunctionDeclarations;
76785         var lexicalEnvironmentStatements;
76786         var lexicalEnvironmentFlags = 0;
76787         var lexicalEnvironmentVariableDeclarationsStack = [];
76788         var lexicalEnvironmentFunctionDeclarationsStack = [];
76789         var lexicalEnvironmentStatementsStack = [];
76790         var lexicalEnvironmentFlagsStack = [];
76791         var lexicalEnvironmentStackOffset = 0;
76792         var lexicalEnvironmentSuspended = false;
76793         var emitHelpers;
76794         var onSubstituteNode = noEmitSubstitution;
76795         var onEmitNode = noEmitNotification;
76796         var state = 0;
76797         var diagnostics = [];
76798         var context = {
76799             getCompilerOptions: function () { return options; },
76800             getEmitResolver: function () { return resolver; },
76801             getEmitHost: function () { return host; },
76802             startLexicalEnvironment: startLexicalEnvironment,
76803             suspendLexicalEnvironment: suspendLexicalEnvironment,
76804             resumeLexicalEnvironment: resumeLexicalEnvironment,
76805             endLexicalEnvironment: endLexicalEnvironment,
76806             setLexicalEnvironmentFlags: setLexicalEnvironmentFlags,
76807             getLexicalEnvironmentFlags: getLexicalEnvironmentFlags,
76808             hoistVariableDeclaration: hoistVariableDeclaration,
76809             hoistFunctionDeclaration: hoistFunctionDeclaration,
76810             addInitializationStatement: addInitializationStatement,
76811             requestEmitHelper: requestEmitHelper,
76812             readEmitHelpers: readEmitHelpers,
76813             enableSubstitution: enableSubstitution,
76814             enableEmitNotification: enableEmitNotification,
76815             isSubstitutionEnabled: isSubstitutionEnabled,
76816             isEmitNotificationEnabled: isEmitNotificationEnabled,
76817             get onSubstituteNode() { return onSubstituteNode; },
76818             set onSubstituteNode(value) {
76819                 ts.Debug.assert(state < 1, "Cannot modify transformation hooks after initialization has completed.");
76820                 ts.Debug.assert(value !== undefined, "Value must not be 'undefined'");
76821                 onSubstituteNode = value;
76822             },
76823             get onEmitNode() { return onEmitNode; },
76824             set onEmitNode(value) {
76825                 ts.Debug.assert(state < 1, "Cannot modify transformation hooks after initialization has completed.");
76826                 ts.Debug.assert(value !== undefined, "Value must not be 'undefined'");
76827                 onEmitNode = value;
76828             },
76829             addDiagnostic: function (diag) {
76830                 diagnostics.push(diag);
76831             }
76832         };
76833         for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) {
76834             var node = nodes_4[_i];
76835             ts.disposeEmitNodes(ts.getSourceFileOfNode(ts.getParseTreeNode(node)));
76836         }
76837         ts.performance.mark("beforeTransform");
76838         var transformersWithContext = transformers.map(function (t) { return t(context); });
76839         var transformation = function (node) {
76840             for (var _i = 0, transformersWithContext_1 = transformersWithContext; _i < transformersWithContext_1.length; _i++) {
76841                 var transform = transformersWithContext_1[_i];
76842                 node = transform(node);
76843             }
76844             return node;
76845         };
76846         state = 1;
76847         var transformed = ts.map(nodes, allowDtsFiles ? transformation : transformRoot);
76848         state = 2;
76849         ts.performance.mark("afterTransform");
76850         ts.performance.measure("transformTime", "beforeTransform", "afterTransform");
76851         return {
76852             transformed: transformed,
76853             substituteNode: substituteNode,
76854             emitNodeWithNotification: emitNodeWithNotification,
76855             isEmitNotificationEnabled: isEmitNotificationEnabled,
76856             dispose: dispose,
76857             diagnostics: diagnostics
76858         };
76859         function transformRoot(node) {
76860             return node && (!ts.isSourceFile(node) || !node.isDeclarationFile) ? transformation(node) : node;
76861         }
76862         function enableSubstitution(kind) {
76863             ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed.");
76864             enabledSyntaxKindFeatures[kind] |= 1;
76865         }
76866         function isSubstitutionEnabled(node) {
76867             return (enabledSyntaxKindFeatures[node.kind] & 1) !== 0
76868                 && (ts.getEmitFlags(node) & 4) === 0;
76869         }
76870         function substituteNode(hint, node) {
76871             ts.Debug.assert(state < 3, "Cannot substitute a node after the result is disposed.");
76872             return node && isSubstitutionEnabled(node) && onSubstituteNode(hint, node) || node;
76873         }
76874         function enableEmitNotification(kind) {
76875             ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed.");
76876             enabledSyntaxKindFeatures[kind] |= 2;
76877         }
76878         function isEmitNotificationEnabled(node) {
76879             return (enabledSyntaxKindFeatures[node.kind] & 2) !== 0
76880                 || (ts.getEmitFlags(node) & 2) !== 0;
76881         }
76882         function emitNodeWithNotification(hint, node, emitCallback) {
76883             ts.Debug.assert(state < 3, "Cannot invoke TransformationResult callbacks after the result is disposed.");
76884             if (node) {
76885                 if (isEmitNotificationEnabled(node)) {
76886                     onEmitNode(hint, node, emitCallback);
76887                 }
76888                 else {
76889                     emitCallback(hint, node);
76890                 }
76891             }
76892         }
76893         function hoistVariableDeclaration(name) {
76894             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
76895             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
76896             var decl = ts.setEmitFlags(ts.createVariableDeclaration(name), 64);
76897             if (!lexicalEnvironmentVariableDeclarations) {
76898                 lexicalEnvironmentVariableDeclarations = [decl];
76899             }
76900             else {
76901                 lexicalEnvironmentVariableDeclarations.push(decl);
76902             }
76903             if (lexicalEnvironmentFlags & 1) {
76904                 lexicalEnvironmentFlags |= 2;
76905             }
76906         }
76907         function hoistFunctionDeclaration(func) {
76908             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
76909             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
76910             ts.setEmitFlags(func, 1048576);
76911             if (!lexicalEnvironmentFunctionDeclarations) {
76912                 lexicalEnvironmentFunctionDeclarations = [func];
76913             }
76914             else {
76915                 lexicalEnvironmentFunctionDeclarations.push(func);
76916             }
76917         }
76918         function addInitializationStatement(node) {
76919             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
76920             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
76921             ts.setEmitFlags(node, 1048576);
76922             if (!lexicalEnvironmentStatements) {
76923                 lexicalEnvironmentStatements = [node];
76924             }
76925             else {
76926                 lexicalEnvironmentStatements.push(node);
76927             }
76928         }
76929         function startLexicalEnvironment() {
76930             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
76931             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
76932             ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended.");
76933             lexicalEnvironmentVariableDeclarationsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentVariableDeclarations;
76934             lexicalEnvironmentFunctionDeclarationsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentFunctionDeclarations;
76935             lexicalEnvironmentStatementsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentStatements;
76936             lexicalEnvironmentFlagsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentFlags;
76937             lexicalEnvironmentStackOffset++;
76938             lexicalEnvironmentVariableDeclarations = undefined;
76939             lexicalEnvironmentFunctionDeclarations = undefined;
76940             lexicalEnvironmentStatements = undefined;
76941             lexicalEnvironmentFlags = 0;
76942         }
76943         function suspendLexicalEnvironment() {
76944             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
76945             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
76946             ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is already suspended.");
76947             lexicalEnvironmentSuspended = true;
76948         }
76949         function resumeLexicalEnvironment() {
76950             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
76951             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
76952             ts.Debug.assert(lexicalEnvironmentSuspended, "Lexical environment is not suspended.");
76953             lexicalEnvironmentSuspended = false;
76954         }
76955         function endLexicalEnvironment() {
76956             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
76957             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
76958             ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended.");
76959             var statements;
76960             if (lexicalEnvironmentVariableDeclarations ||
76961                 lexicalEnvironmentFunctionDeclarations ||
76962                 lexicalEnvironmentStatements) {
76963                 if (lexicalEnvironmentFunctionDeclarations) {
76964                     statements = __spreadArrays(lexicalEnvironmentFunctionDeclarations);
76965                 }
76966                 if (lexicalEnvironmentVariableDeclarations) {
76967                     var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList(lexicalEnvironmentVariableDeclarations));
76968                     ts.setEmitFlags(statement, 1048576);
76969                     if (!statements) {
76970                         statements = [statement];
76971                     }
76972                     else {
76973                         statements.push(statement);
76974                     }
76975                 }
76976                 if (lexicalEnvironmentStatements) {
76977                     if (!statements) {
76978                         statements = __spreadArrays(lexicalEnvironmentStatements);
76979                     }
76980                     else {
76981                         statements = __spreadArrays(statements, lexicalEnvironmentStatements);
76982                     }
76983                 }
76984             }
76985             lexicalEnvironmentStackOffset--;
76986             lexicalEnvironmentVariableDeclarations = lexicalEnvironmentVariableDeclarationsStack[lexicalEnvironmentStackOffset];
76987             lexicalEnvironmentFunctionDeclarations = lexicalEnvironmentFunctionDeclarationsStack[lexicalEnvironmentStackOffset];
76988             lexicalEnvironmentStatements = lexicalEnvironmentStatementsStack[lexicalEnvironmentStackOffset];
76989             lexicalEnvironmentFlags = lexicalEnvironmentFlagsStack[lexicalEnvironmentStackOffset];
76990             if (lexicalEnvironmentStackOffset === 0) {
76991                 lexicalEnvironmentVariableDeclarationsStack = [];
76992                 lexicalEnvironmentFunctionDeclarationsStack = [];
76993                 lexicalEnvironmentStatementsStack = [];
76994                 lexicalEnvironmentFlagsStack = [];
76995             }
76996             return statements;
76997         }
76998         function setLexicalEnvironmentFlags(flags, value) {
76999             lexicalEnvironmentFlags = value ?
77000                 lexicalEnvironmentFlags | flags :
77001                 lexicalEnvironmentFlags & ~flags;
77002         }
77003         function getLexicalEnvironmentFlags() {
77004             return lexicalEnvironmentFlags;
77005         }
77006         function requestEmitHelper(helper) {
77007             ts.Debug.assert(state > 0, "Cannot modify the transformation context during initialization.");
77008             ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed.");
77009             ts.Debug.assert(!helper.scoped, "Cannot request a scoped emit helper.");
77010             if (helper.dependencies) {
77011                 for (var _i = 0, _a = helper.dependencies; _i < _a.length; _i++) {
77012                     var h = _a[_i];
77013                     requestEmitHelper(h);
77014                 }
77015             }
77016             emitHelpers = ts.append(emitHelpers, helper);
77017         }
77018         function readEmitHelpers() {
77019             ts.Debug.assert(state > 0, "Cannot modify the transformation context during initialization.");
77020             ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed.");
77021             var helpers = emitHelpers;
77022             emitHelpers = undefined;
77023             return helpers;
77024         }
77025         function dispose() {
77026             if (state < 3) {
77027                 for (var _i = 0, nodes_5 = nodes; _i < nodes_5.length; _i++) {
77028                     var node = nodes_5[_i];
77029                     ts.disposeEmitNodes(ts.getSourceFileOfNode(ts.getParseTreeNode(node)));
77030                 }
77031                 lexicalEnvironmentVariableDeclarations = undefined;
77032                 lexicalEnvironmentVariableDeclarationsStack = undefined;
77033                 lexicalEnvironmentFunctionDeclarations = undefined;
77034                 lexicalEnvironmentFunctionDeclarationsStack = undefined;
77035                 onSubstituteNode = undefined;
77036                 onEmitNode = undefined;
77037                 emitHelpers = undefined;
77038                 state = 3;
77039             }
77040         }
77041     }
77042     ts.transformNodes = transformNodes;
77043 })(ts || (ts = {}));
77044 var ts;
77045 (function (ts) {
77046     var brackets = createBracketsMap();
77047     var syntheticParent = { pos: -1, end: -1 };
77048     function isBuildInfoFile(file) {
77049         return ts.fileExtensionIs(file, ".tsbuildinfo");
77050     }
77051     ts.isBuildInfoFile = isBuildInfoFile;
77052     function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, forceDtsEmit, onlyBuildInfo, includeBuildInfo) {
77053         if (forceDtsEmit === void 0) { forceDtsEmit = false; }
77054         var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile, forceDtsEmit);
77055         var options = host.getCompilerOptions();
77056         if (options.outFile || options.out) {
77057             var prepends = host.getPrependNodes();
77058             if (sourceFiles.length || prepends.length) {
77059                 var bundle = ts.createBundle(sourceFiles, prepends);
77060                 var result = action(getOutputPathsFor(bundle, host, forceDtsEmit), bundle);
77061                 if (result) {
77062                     return result;
77063                 }
77064             }
77065         }
77066         else {
77067             if (!onlyBuildInfo) {
77068                 for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) {
77069                     var sourceFile = sourceFiles_1[_a];
77070                     var result = action(getOutputPathsFor(sourceFile, host, forceDtsEmit), sourceFile);
77071                     if (result) {
77072                         return result;
77073                     }
77074                 }
77075             }
77076             if (includeBuildInfo) {
77077                 var buildInfoPath = getTsBuildInfoEmitOutputFilePath(host.getCompilerOptions());
77078                 if (buildInfoPath)
77079                     return action({ buildInfoPath: buildInfoPath }, undefined);
77080             }
77081         }
77082     }
77083     ts.forEachEmittedFile = forEachEmittedFile;
77084     function getTsBuildInfoEmitOutputFilePath(options) {
77085         var configFile = options.configFilePath;
77086         if (!ts.isIncrementalCompilation(options))
77087             return undefined;
77088         if (options.tsBuildInfoFile)
77089             return options.tsBuildInfoFile;
77090         var outPath = options.outFile || options.out;
77091         var buildInfoExtensionLess;
77092         if (outPath) {
77093             buildInfoExtensionLess = ts.removeFileExtension(outPath);
77094         }
77095         else {
77096             if (!configFile)
77097                 return undefined;
77098             var configFileExtensionLess = ts.removeFileExtension(configFile);
77099             buildInfoExtensionLess = options.outDir ?
77100                 options.rootDir ?
77101                     ts.resolvePath(options.outDir, ts.getRelativePathFromDirectory(options.rootDir, configFileExtensionLess, true)) :
77102                     ts.combinePaths(options.outDir, ts.getBaseFileName(configFileExtensionLess)) :
77103                 configFileExtensionLess;
77104         }
77105         return buildInfoExtensionLess + ".tsbuildinfo";
77106     }
77107     ts.getTsBuildInfoEmitOutputFilePath = getTsBuildInfoEmitOutputFilePath;
77108     function getOutputPathsForBundle(options, forceDtsPaths) {
77109         var outPath = options.outFile || options.out;
77110         var jsFilePath = options.emitDeclarationOnly ? undefined : outPath;
77111         var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options);
77112         var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" : undefined;
77113         var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined;
77114         var buildInfoPath = getTsBuildInfoEmitOutputFilePath(options);
77115         return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: buildInfoPath };
77116     }
77117     ts.getOutputPathsForBundle = getOutputPathsForBundle;
77118     function getOutputPathsFor(sourceFile, host, forceDtsPaths) {
77119         var options = host.getCompilerOptions();
77120         if (sourceFile.kind === 291) {
77121             return getOutputPathsForBundle(options, forceDtsPaths);
77122         }
77123         else {
77124             var ownOutputFilePath = ts.getOwnEmitOutputFilePath(sourceFile.fileName, host, getOutputExtension(sourceFile, options));
77125             var isJsonFile = ts.isJsonSourceFile(sourceFile);
77126             var isJsonEmittedToSameLocation = isJsonFile &&
77127                 ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0;
77128             var jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath;
77129             var sourceMapFilePath = !jsFilePath || ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options);
77130             var declarationFilePath = (forceDtsPaths || (ts.getEmitDeclarations(options) && !isJsonFile)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined;
77131             var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined;
77132             return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: undefined };
77133         }
77134     }
77135     ts.getOutputPathsFor = getOutputPathsFor;
77136     function getSourceMapFilePath(jsFilePath, options) {
77137         return (options.sourceMap && !options.inlineSourceMap) ? jsFilePath + ".map" : undefined;
77138     }
77139     function getOutputExtension(sourceFile, options) {
77140         if (ts.isJsonSourceFile(sourceFile)) {
77141             return ".json";
77142         }
77143         if (options.jsx === 1) {
77144             if (ts.isSourceFileJS(sourceFile)) {
77145                 if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) {
77146                     return ".jsx";
77147                 }
77148             }
77149             else if (sourceFile.languageVariant === 1) {
77150                 return ".jsx";
77151             }
77152         }
77153         return ".js";
77154     }
77155     ts.getOutputExtension = getOutputExtension;
77156     function rootDirOfOptions(configFile) {
77157         return configFile.options.rootDir || ts.getDirectoryPath(ts.Debug.checkDefined(configFile.options.configFilePath));
77158     }
77159     function getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, outputDir) {
77160         return outputDir ?
77161             ts.resolvePath(outputDir, ts.getRelativePathFromDirectory(rootDirOfOptions(configFile), inputFileName, ignoreCase)) :
77162             inputFileName;
77163     }
77164     function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase) {
77165         ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts") && !ts.fileExtensionIs(inputFileName, ".json"));
77166         return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir), ".d.ts");
77167     }
77168     ts.getOutputDeclarationFileName = getOutputDeclarationFileName;
77169     function getOutputJSFileName(inputFileName, configFile, ignoreCase) {
77170         if (configFile.options.emitDeclarationOnly)
77171             return undefined;
77172         var isJsonFile = ts.fileExtensionIs(inputFileName, ".json");
77173         var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir), isJsonFile ?
77174             ".json" :
77175             ts.fileExtensionIs(inputFileName, ".tsx") && configFile.options.jsx === 1 ?
77176                 ".jsx" :
77177                 ".js");
77178         return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 ?
77179             outputFileName :
77180             undefined;
77181     }
77182     function createAddOutput() {
77183         var outputs;
77184         return { addOutput: addOutput, getOutputs: getOutputs };
77185         function addOutput(path) {
77186             if (path) {
77187                 (outputs || (outputs = [])).push(path);
77188             }
77189         }
77190         function getOutputs() {
77191             return outputs || ts.emptyArray;
77192         }
77193     }
77194     function getSingleOutputFileNames(configFile, addOutput) {
77195         var _a = getOutputPathsForBundle(configFile.options, false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath;
77196         addOutput(jsFilePath);
77197         addOutput(sourceMapFilePath);
77198         addOutput(declarationFilePath);
77199         addOutput(declarationMapPath);
77200         addOutput(buildInfoPath);
77201     }
77202     function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput) {
77203         if (ts.fileExtensionIs(inputFileName, ".d.ts"))
77204             return;
77205         var js = getOutputJSFileName(inputFileName, configFile, ignoreCase);
77206         addOutput(js);
77207         if (ts.fileExtensionIs(inputFileName, ".json"))
77208             return;
77209         if (js && configFile.options.sourceMap) {
77210             addOutput(js + ".map");
77211         }
77212         if (ts.getEmitDeclarations(configFile.options)) {
77213             var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase);
77214             addOutput(dts);
77215             if (configFile.options.declarationMap) {
77216                 addOutput(dts + ".map");
77217             }
77218         }
77219     }
77220     function getAllProjectOutputs(configFile, ignoreCase) {
77221         var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs;
77222         if (configFile.options.outFile || configFile.options.out) {
77223             getSingleOutputFileNames(configFile, addOutput);
77224         }
77225         else {
77226             for (var _b = 0, _c = configFile.fileNames; _b < _c.length; _b++) {
77227                 var inputFileName = _c[_b];
77228                 getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput);
77229             }
77230             addOutput(getTsBuildInfoEmitOutputFilePath(configFile.options));
77231         }
77232         return getOutputs();
77233     }
77234     ts.getAllProjectOutputs = getAllProjectOutputs;
77235     function getOutputFileNames(commandLine, inputFileName, ignoreCase) {
77236         inputFileName = ts.normalizePath(inputFileName);
77237         ts.Debug.assert(ts.contains(commandLine.fileNames, inputFileName), "Expected fileName to be present in command line");
77238         var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs;
77239         if (commandLine.options.outFile || commandLine.options.out) {
77240             getSingleOutputFileNames(commandLine, addOutput);
77241         }
77242         else {
77243             getOwnOutputFileNames(commandLine, inputFileName, ignoreCase, addOutput);
77244         }
77245         return getOutputs();
77246     }
77247     ts.getOutputFileNames = getOutputFileNames;
77248     function getFirstProjectOutput(configFile, ignoreCase) {
77249         if (configFile.options.outFile || configFile.options.out) {
77250             var jsFilePath = getOutputPathsForBundle(configFile.options, false).jsFilePath;
77251             return ts.Debug.checkDefined(jsFilePath, "project " + configFile.options.configFilePath + " expected to have at least one output");
77252         }
77253         for (var _a = 0, _b = configFile.fileNames; _a < _b.length; _a++) {
77254             var inputFileName = _b[_a];
77255             if (ts.fileExtensionIs(inputFileName, ".d.ts"))
77256                 continue;
77257             var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase);
77258             if (jsFilePath)
77259                 return jsFilePath;
77260             if (ts.fileExtensionIs(inputFileName, ".json"))
77261                 continue;
77262             if (ts.getEmitDeclarations(configFile.options)) {
77263                 return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase);
77264             }
77265         }
77266         var buildInfoPath = getTsBuildInfoEmitOutputFilePath(configFile.options);
77267         if (buildInfoPath)
77268             return buildInfoPath;
77269         return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output");
77270     }
77271     ts.getFirstProjectOutput = getFirstProjectOutput;
77272     function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo, forceDtsEmit) {
77273         var scriptTransformers = _a.scriptTransformers, declarationTransformers = _a.declarationTransformers;
77274         var compilerOptions = host.getCompilerOptions();
77275         var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined;
77276         var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined;
77277         var emitterDiagnostics = ts.createDiagnosticCollection();
77278         var newLine = ts.getNewLineCharacter(compilerOptions, function () { return host.getNewLine(); });
77279         var writer = ts.createTextWriter(newLine);
77280         var _b = ts.performance.createTimer("printTime", "beforePrint", "afterPrint"), enter = _b.enter, exit = _b.exit;
77281         var bundleBuildInfo;
77282         var emitSkipped = false;
77283         var exportedModulesFromDeclarationEmit;
77284         enter();
77285         forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile, forceDtsEmit), forceDtsEmit, onlyBuildInfo, !targetSourceFile);
77286         exit();
77287         return {
77288             emitSkipped: emitSkipped,
77289             diagnostics: emitterDiagnostics.getDiagnostics(),
77290             emittedFiles: emittedFilesList,
77291             sourceMaps: sourceMapDataList,
77292             exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit
77293         };
77294         function emitSourceFileOrBundle(_a, sourceFileOrBundle) {
77295             var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath;
77296             var buildInfoDirectory;
77297             if (buildInfoPath && sourceFileOrBundle && ts.isBundle(sourceFileOrBundle)) {
77298                 buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
77299                 bundleBuildInfo = {
77300                     commonSourceDirectory: relativeToBuildInfo(host.getCommonSourceDirectory()),
77301                     sourceFiles: sourceFileOrBundle.sourceFiles.map(function (file) { return relativeToBuildInfo(ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory())); })
77302                 };
77303             }
77304             emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo);
77305             emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo);
77306             emitBuildInfo(bundleBuildInfo, buildInfoPath);
77307             if (!emitSkipped && emittedFilesList) {
77308                 if (!emitOnlyDtsFiles) {
77309                     if (jsFilePath) {
77310                         emittedFilesList.push(jsFilePath);
77311                     }
77312                     if (sourceMapFilePath) {
77313                         emittedFilesList.push(sourceMapFilePath);
77314                     }
77315                     if (buildInfoPath) {
77316                         emittedFilesList.push(buildInfoPath);
77317                     }
77318                 }
77319                 if (declarationFilePath) {
77320                     emittedFilesList.push(declarationFilePath);
77321                 }
77322                 if (declarationMapPath) {
77323                     emittedFilesList.push(declarationMapPath);
77324                 }
77325             }
77326             function relativeToBuildInfo(path) {
77327                 return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(buildInfoDirectory, path, host.getCanonicalFileName));
77328             }
77329         }
77330         function emitBuildInfo(bundle, buildInfoPath) {
77331             if (!buildInfoPath || targetSourceFile || emitSkipped)
77332                 return;
77333             var program = host.getProgramBuildInfo();
77334             if (host.isEmitBlocked(buildInfoPath) || compilerOptions.noEmit) {
77335                 emitSkipped = true;
77336                 return;
77337             }
77338             var version = ts.version;
77339             ts.writeFile(host, emitterDiagnostics, buildInfoPath, getBuildInfoText({ bundle: bundle, program: program, version: version }), false);
77340         }
77341         function emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo) {
77342             if (!sourceFileOrBundle || emitOnlyDtsFiles || !jsFilePath) {
77343                 return;
77344             }
77345             if ((jsFilePath && host.isEmitBlocked(jsFilePath)) || compilerOptions.noEmit) {
77346                 emitSkipped = true;
77347                 return;
77348             }
77349             var transform = ts.transformNodes(resolver, host, compilerOptions, [sourceFileOrBundle], scriptTransformers, false);
77350             var printerOptions = {
77351                 removeComments: compilerOptions.removeComments,
77352                 newLine: compilerOptions.newLine,
77353                 noEmitHelpers: compilerOptions.noEmitHelpers,
77354                 module: compilerOptions.module,
77355                 target: compilerOptions.target,
77356                 sourceMap: compilerOptions.sourceMap,
77357                 inlineSourceMap: compilerOptions.inlineSourceMap,
77358                 inlineSources: compilerOptions.inlineSources,
77359                 extendedDiagnostics: compilerOptions.extendedDiagnostics,
77360                 writeBundleFileInfo: !!bundleBuildInfo,
77361                 relativeToBuildInfo: relativeToBuildInfo
77362             };
77363             var printer = createPrinter(printerOptions, {
77364                 hasGlobalName: resolver.hasGlobalName,
77365                 onEmitNode: transform.emitNodeWithNotification,
77366                 isEmitNotificationEnabled: transform.isEmitNotificationEnabled,
77367                 substituteNode: transform.substituteNode,
77368             });
77369             ts.Debug.assert(transform.transformed.length === 1, "Should only see one output from the transform");
77370             printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], printer, compilerOptions);
77371             transform.dispose();
77372             if (bundleBuildInfo)
77373                 bundleBuildInfo.js = printer.bundleFileInfo;
77374         }
77375         function emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo) {
77376             if (!sourceFileOrBundle)
77377                 return;
77378             if (!declarationFilePath) {
77379                 if (emitOnlyDtsFiles || compilerOptions.emitDeclarationOnly)
77380                     emitSkipped = true;
77381                 return;
77382             }
77383             var sourceFiles = ts.isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles;
77384             var filesForEmit = forceDtsEmit ? sourceFiles : ts.filter(sourceFiles, ts.isSourceFileNotJson);
77385             var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(filesForEmit, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : filesForEmit;
77386             if (emitOnlyDtsFiles && !ts.getEmitDeclarations(compilerOptions)) {
77387                 filesForEmit.forEach(collectLinkedAliases);
77388             }
77389             var declarationTransform = ts.transformNodes(resolver, host, compilerOptions, inputListOrBundle, declarationTransformers, false);
77390             if (ts.length(declarationTransform.diagnostics)) {
77391                 for (var _a = 0, _b = declarationTransform.diagnostics; _a < _b.length; _a++) {
77392                     var diagnostic = _b[_a];
77393                     emitterDiagnostics.add(diagnostic);
77394                 }
77395             }
77396             var printerOptions = {
77397                 removeComments: compilerOptions.removeComments,
77398                 newLine: compilerOptions.newLine,
77399                 noEmitHelpers: true,
77400                 module: compilerOptions.module,
77401                 target: compilerOptions.target,
77402                 sourceMap: compilerOptions.sourceMap,
77403                 inlineSourceMap: compilerOptions.inlineSourceMap,
77404                 extendedDiagnostics: compilerOptions.extendedDiagnostics,
77405                 onlyPrintJsDocStyle: true,
77406                 writeBundleFileInfo: !!bundleBuildInfo,
77407                 recordInternalSection: !!bundleBuildInfo,
77408                 relativeToBuildInfo: relativeToBuildInfo
77409             };
77410             var declarationPrinter = createPrinter(printerOptions, {
77411                 hasGlobalName: resolver.hasGlobalName,
77412                 onEmitNode: declarationTransform.emitNodeWithNotification,
77413                 isEmitNotificationEnabled: declarationTransform.isEmitNotificationEnabled,
77414                 substituteNode: declarationTransform.substituteNode,
77415             });
77416             var declBlocked = (!!declarationTransform.diagnostics && !!declarationTransform.diagnostics.length) || !!host.isEmitBlocked(declarationFilePath) || !!compilerOptions.noEmit;
77417             emitSkipped = emitSkipped || declBlocked;
77418             if (!declBlocked || forceDtsEmit) {
77419                 ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform");
77420                 printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, {
77421                     sourceMap: compilerOptions.declarationMap,
77422                     sourceRoot: compilerOptions.sourceRoot,
77423                     mapRoot: compilerOptions.mapRoot,
77424                     extendedDiagnostics: compilerOptions.extendedDiagnostics,
77425                 });
77426                 if (forceDtsEmit && declarationTransform.transformed[0].kind === 290) {
77427                     var sourceFile = declarationTransform.transformed[0];
77428                     exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit;
77429                 }
77430             }
77431             declarationTransform.dispose();
77432             if (bundleBuildInfo)
77433                 bundleBuildInfo.dts = declarationPrinter.bundleFileInfo;
77434         }
77435         function collectLinkedAliases(node) {
77436             if (ts.isExportAssignment(node)) {
77437                 if (node.expression.kind === 75) {
77438                     resolver.collectLinkedAliases(node.expression, true);
77439                 }
77440                 return;
77441             }
77442             else if (ts.isExportSpecifier(node)) {
77443                 resolver.collectLinkedAliases(node.propertyName || node.name, true);
77444                 return;
77445             }
77446             ts.forEachChild(node, collectLinkedAliases);
77447         }
77448         function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) {
77449             var bundle = sourceFileOrBundle.kind === 291 ? sourceFileOrBundle : undefined;
77450             var sourceFile = sourceFileOrBundle.kind === 290 ? sourceFileOrBundle : undefined;
77451             var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile];
77452             var sourceMapGenerator;
77453             if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) {
77454                 sourceMapGenerator = ts.createSourceMapGenerator(host, ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)), getSourceRoot(mapOptions), getSourceMapDirectory(mapOptions, jsFilePath, sourceFile), mapOptions);
77455             }
77456             if (bundle) {
77457                 printer.writeBundle(bundle, writer, sourceMapGenerator);
77458             }
77459             else {
77460                 printer.writeFile(sourceFile, writer, sourceMapGenerator);
77461             }
77462             if (sourceMapGenerator) {
77463                 if (sourceMapDataList) {
77464                     sourceMapDataList.push({
77465                         inputSourceFileNames: sourceMapGenerator.getSources(),
77466                         sourceMap: sourceMapGenerator.toJSON()
77467                     });
77468                 }
77469                 var sourceMappingURL = getSourceMappingURL(mapOptions, sourceMapGenerator, jsFilePath, sourceMapFilePath, sourceFile);
77470                 if (sourceMappingURL) {
77471                     if (!writer.isAtStartOfLine())
77472                         writer.rawWrite(newLine);
77473                     writer.writeComment("//# " + "sourceMappingURL" + "=" + sourceMappingURL);
77474                 }
77475                 if (sourceMapFilePath) {
77476                     var sourceMap = sourceMapGenerator.toString();
77477                     ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, false, sourceFiles);
77478                 }
77479             }
77480             else {
77481                 writer.writeLine();
77482             }
77483             ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles);
77484             writer.clear();
77485         }
77486         function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) {
77487             return (mapOptions.sourceMap || mapOptions.inlineSourceMap)
77488                 && (sourceFileOrBundle.kind !== 290 || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json"));
77489         }
77490         function getSourceRoot(mapOptions) {
77491             var sourceRoot = ts.normalizeSlashes(mapOptions.sourceRoot || "");
77492             return sourceRoot ? ts.ensureTrailingDirectorySeparator(sourceRoot) : sourceRoot;
77493         }
77494         function getSourceMapDirectory(mapOptions, filePath, sourceFile) {
77495             if (mapOptions.sourceRoot)
77496                 return host.getCommonSourceDirectory();
77497             if (mapOptions.mapRoot) {
77498                 var sourceMapDir = ts.normalizeSlashes(mapOptions.mapRoot);
77499                 if (sourceFile) {
77500                     sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFile.fileName, host, sourceMapDir));
77501                 }
77502                 if (ts.getRootLength(sourceMapDir) === 0) {
77503                     sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir);
77504                 }
77505                 return sourceMapDir;
77506             }
77507             return ts.getDirectoryPath(ts.normalizePath(filePath));
77508         }
77509         function getSourceMappingURL(mapOptions, sourceMapGenerator, filePath, sourceMapFilePath, sourceFile) {
77510             if (mapOptions.inlineSourceMap) {
77511                 var sourceMapText = sourceMapGenerator.toString();
77512                 var base64SourceMapText = ts.base64encode(ts.sys, sourceMapText);
77513                 return "data:application/json;base64," + base64SourceMapText;
77514             }
77515             var sourceMapFile = ts.getBaseFileName(ts.normalizeSlashes(ts.Debug.checkDefined(sourceMapFilePath)));
77516             if (mapOptions.mapRoot) {
77517                 var sourceMapDir = ts.normalizeSlashes(mapOptions.mapRoot);
77518                 if (sourceFile) {
77519                     sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFile.fileName, host, sourceMapDir));
77520                 }
77521                 if (ts.getRootLength(sourceMapDir) === 0) {
77522                     sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir);
77523                     return ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(filePath)), ts.combinePaths(sourceMapDir, sourceMapFile), host.getCurrentDirectory(), host.getCanonicalFileName, true);
77524                 }
77525                 else {
77526                     return ts.combinePaths(sourceMapDir, sourceMapFile);
77527                 }
77528             }
77529             return sourceMapFile;
77530         }
77531     }
77532     ts.emitFiles = emitFiles;
77533     function getBuildInfoText(buildInfo) {
77534         return JSON.stringify(buildInfo, undefined, 2);
77535     }
77536     ts.getBuildInfoText = getBuildInfoText;
77537     function getBuildInfo(buildInfoText) {
77538         return JSON.parse(buildInfoText);
77539     }
77540     ts.getBuildInfo = getBuildInfo;
77541     ts.notImplementedResolver = {
77542         hasGlobalName: ts.notImplemented,
77543         getReferencedExportContainer: ts.notImplemented,
77544         getReferencedImportDeclaration: ts.notImplemented,
77545         getReferencedDeclarationWithCollidingName: ts.notImplemented,
77546         isDeclarationWithCollidingName: ts.notImplemented,
77547         isValueAliasDeclaration: ts.notImplemented,
77548         isReferencedAliasDeclaration: ts.notImplemented,
77549         isTopLevelValueImportEqualsWithEntityName: ts.notImplemented,
77550         getNodeCheckFlags: ts.notImplemented,
77551         isDeclarationVisible: ts.notImplemented,
77552         isLateBound: function (_node) { return false; },
77553         collectLinkedAliases: ts.notImplemented,
77554         isImplementationOfOverload: ts.notImplemented,
77555         isRequiredInitializedParameter: ts.notImplemented,
77556         isOptionalUninitializedParameterProperty: ts.notImplemented,
77557         isExpandoFunctionDeclaration: ts.notImplemented,
77558         getPropertiesOfContainerFunction: ts.notImplemented,
77559         createTypeOfDeclaration: ts.notImplemented,
77560         createReturnTypeOfSignatureDeclaration: ts.notImplemented,
77561         createTypeOfExpression: ts.notImplemented,
77562         createLiteralConstValue: ts.notImplemented,
77563         isSymbolAccessible: ts.notImplemented,
77564         isEntityNameVisible: ts.notImplemented,
77565         getConstantValue: ts.notImplemented,
77566         getReferencedValueDeclaration: ts.notImplemented,
77567         getTypeReferenceSerializationKind: ts.notImplemented,
77568         isOptionalParameter: ts.notImplemented,
77569         moduleExportsSomeValue: ts.notImplemented,
77570         isArgumentsLocalBinding: ts.notImplemented,
77571         getExternalModuleFileFromDeclaration: ts.notImplemented,
77572         getTypeReferenceDirectivesForEntityName: ts.notImplemented,
77573         getTypeReferenceDirectivesForSymbol: ts.notImplemented,
77574         isLiteralConstDeclaration: ts.notImplemented,
77575         getJsxFactoryEntity: ts.notImplemented,
77576         getAllAccessorDeclarations: ts.notImplemented,
77577         getSymbolOfExternalModuleSpecifier: ts.notImplemented,
77578         isBindingCapturedByNode: ts.notImplemented,
77579         getDeclarationStatementsForSourceFile: ts.notImplemented,
77580         isImportRequiredByAugmentation: ts.notImplemented,
77581     };
77582     function createSourceFilesFromBundleBuildInfo(bundle, buildInfoDirectory, host) {
77583         var sourceFiles = bundle.sourceFiles.map(function (fileName) {
77584             var sourceFile = ts.createNode(290, 0, 0);
77585             sourceFile.fileName = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), ts.getNormalizedAbsolutePath(fileName, buildInfoDirectory), !host.useCaseSensitiveFileNames());
77586             sourceFile.text = "";
77587             sourceFile.statements = ts.createNodeArray();
77588             return sourceFile;
77589         });
77590         var jsBundle = ts.Debug.checkDefined(bundle.js);
77591         ts.forEach(jsBundle.sources && jsBundle.sources.prologues, function (prologueInfo) {
77592             var sourceFile = sourceFiles[prologueInfo.file];
77593             sourceFile.text = prologueInfo.text;
77594             sourceFile.end = prologueInfo.text.length;
77595             sourceFile.statements = ts.createNodeArray(prologueInfo.directives.map(function (directive) {
77596                 var statement = ts.createNode(226, directive.pos, directive.end);
77597                 statement.expression = ts.createNode(10, directive.expression.pos, directive.expression.end);
77598                 statement.expression.text = directive.expression.text;
77599                 return statement;
77600             }));
77601         });
77602         return sourceFiles;
77603     }
77604     function emitUsingBuildInfo(config, host, getCommandLine, customTransformers) {
77605         var _a = getOutputPathsForBundle(config.options, false), buildInfoPath = _a.buildInfoPath, jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath;
77606         var buildInfoText = host.readFile(ts.Debug.checkDefined(buildInfoPath));
77607         if (!buildInfoText)
77608             return buildInfoPath;
77609         var jsFileText = host.readFile(ts.Debug.checkDefined(jsFilePath));
77610         if (!jsFileText)
77611             return jsFilePath;
77612         var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath);
77613         if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap)
77614             return sourceMapFilePath || "inline sourcemap decoding";
77615         var declarationText = declarationFilePath && host.readFile(declarationFilePath);
77616         if (declarationFilePath && !declarationText)
77617             return declarationFilePath;
77618         var declarationMapText = declarationMapPath && host.readFile(declarationMapPath);
77619         if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap)
77620             return declarationMapPath || "inline sourcemap decoding";
77621         var buildInfo = getBuildInfo(buildInfoText);
77622         if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationText && !buildInfo.bundle.dts))
77623             return buildInfoPath;
77624         var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
77625         var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo, true);
77626         var outputFiles = [];
77627         var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); });
77628         var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle, buildInfoDirectory, host);
77629         var emitHost = {
77630             getPrependNodes: ts.memoize(function () { return __spreadArrays(prependNodes, [ownPrependInput]); }),
77631             getCanonicalFileName: host.getCanonicalFileName,
77632             getCommonSourceDirectory: function () { return ts.getNormalizedAbsolutePath(buildInfo.bundle.commonSourceDirectory, buildInfoDirectory); },
77633             getCompilerOptions: function () { return config.options; },
77634             getCurrentDirectory: function () { return host.getCurrentDirectory(); },
77635             getNewLine: function () { return host.getNewLine(); },
77636             getSourceFile: ts.returnUndefined,
77637             getSourceFileByPath: ts.returnUndefined,
77638             getSourceFiles: function () { return sourceFilesForJsEmit; },
77639             getLibFileFromReference: ts.notImplemented,
77640             isSourceFileFromExternalLibrary: ts.returnFalse,
77641             getResolvedProjectReferenceToRedirect: ts.returnUndefined,
77642             getProjectReferenceRedirect: ts.returnUndefined,
77643             isSourceOfProjectReferenceRedirect: ts.returnFalse,
77644             writeFile: function (name, text, writeByteOrderMark) {
77645                 switch (name) {
77646                     case jsFilePath:
77647                         if (jsFileText === text)
77648                             return;
77649                         break;
77650                     case sourceMapFilePath:
77651                         if (sourceMapText === text)
77652                             return;
77653                         break;
77654                     case buildInfoPath:
77655                         var newBuildInfo = getBuildInfo(text);
77656                         newBuildInfo.program = buildInfo.program;
77657                         var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles;
77658                         newBuildInfo.bundle.js.sources = js.sources;
77659                         if (dts) {
77660                             newBuildInfo.bundle.dts.sources = dts.sources;
77661                         }
77662                         newBuildInfo.bundle.sourceFiles = sourceFiles;
77663                         outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark });
77664                         return;
77665                     case declarationFilePath:
77666                         if (declarationText === text)
77667                             return;
77668                         break;
77669                     case declarationMapPath:
77670                         if (declarationMapText === text)
77671                             return;
77672                         break;
77673                     default:
77674                         ts.Debug.fail("Unexpected path: " + name);
77675                 }
77676                 outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark });
77677             },
77678             isEmitBlocked: ts.returnFalse,
77679             readFile: function (f) { return host.readFile(f); },
77680             fileExists: function (f) { return host.fileExists(f); },
77681             useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
77682             getProgramBuildInfo: ts.returnUndefined,
77683             getSourceFileFromReference: ts.returnUndefined,
77684             redirectTargetsMap: ts.createMultiMap()
77685         };
77686         emitFiles(ts.notImplementedResolver, emitHost, undefined, ts.getTransformers(config.options, customTransformers));
77687         return outputFiles;
77688     }
77689     ts.emitUsingBuildInfo = emitUsingBuildInfo;
77690     function createPrinter(printerOptions, handlers) {
77691         if (printerOptions === void 0) { printerOptions = {}; }
77692         if (handlers === void 0) { handlers = {}; }
77693         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;
77694         var extendedDiagnostics = !!printerOptions.extendedDiagnostics;
77695         var newLine = ts.getNewLineCharacter(printerOptions);
77696         var moduleKind = ts.getEmitModuleKind(printerOptions);
77697         var bundledHelpers = ts.createMap();
77698         var currentSourceFile;
77699         var nodeIdToGeneratedName;
77700         var autoGeneratedIdToGeneratedName;
77701         var generatedNames;
77702         var tempFlagsStack;
77703         var tempFlags;
77704         var reservedNamesStack;
77705         var reservedNames;
77706         var preserveSourceNewlines = printerOptions.preserveSourceNewlines;
77707         var writer;
77708         var ownWriter;
77709         var write = writeBase;
77710         var isOwnFileEmit;
77711         var bundleFileInfo = printerOptions.writeBundleFileInfo ? { sections: [] } : undefined;
77712         var relativeToBuildInfo = bundleFileInfo ? ts.Debug.checkDefined(printerOptions.relativeToBuildInfo) : undefined;
77713         var recordInternalSection = printerOptions.recordInternalSection;
77714         var sourceFileTextPos = 0;
77715         var sourceFileTextKind = "text";
77716         var sourceMapsDisabled = true;
77717         var sourceMapGenerator;
77718         var sourceMapSource;
77719         var sourceMapSourceIndex = -1;
77720         var containerPos = -1;
77721         var containerEnd = -1;
77722         var declarationListContainerEnd = -1;
77723         var currentLineMap;
77724         var detachedCommentsInfo;
77725         var hasWrittenComment = false;
77726         var commentsDisabled = !!printerOptions.removeComments;
77727         var lastNode;
77728         var lastSubstitution;
77729         var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit;
77730         reset();
77731         return {
77732             printNode: printNode,
77733             printList: printList,
77734             printFile: printFile,
77735             printBundle: printBundle,
77736             writeNode: writeNode,
77737             writeList: writeList,
77738             writeFile: writeFile,
77739             writeBundle: writeBundle,
77740             bundleFileInfo: bundleFileInfo
77741         };
77742         function printNode(hint, node, sourceFile) {
77743             switch (hint) {
77744                 case 0:
77745                     ts.Debug.assert(ts.isSourceFile(node), "Expected a SourceFile node.");
77746                     break;
77747                 case 2:
77748                     ts.Debug.assert(ts.isIdentifier(node), "Expected an Identifier node.");
77749                     break;
77750                 case 1:
77751                     ts.Debug.assert(ts.isExpression(node), "Expected an Expression node.");
77752                     break;
77753             }
77754             switch (node.kind) {
77755                 case 290: return printFile(node);
77756                 case 291: return printBundle(node);
77757                 case 292: return printUnparsedSource(node);
77758             }
77759             writeNode(hint, node, sourceFile, beginPrint());
77760             return endPrint();
77761         }
77762         function printList(format, nodes, sourceFile) {
77763             writeList(format, nodes, sourceFile, beginPrint());
77764             return endPrint();
77765         }
77766         function printBundle(bundle) {
77767             writeBundle(bundle, beginPrint(), undefined);
77768             return endPrint();
77769         }
77770         function printFile(sourceFile) {
77771             writeFile(sourceFile, beginPrint(), undefined);
77772             return endPrint();
77773         }
77774         function printUnparsedSource(unparsed) {
77775             writeUnparsedSource(unparsed, beginPrint());
77776             return endPrint();
77777         }
77778         function writeNode(hint, node, sourceFile, output) {
77779             var previousWriter = writer;
77780             setWriter(output, undefined);
77781             print(hint, node, sourceFile);
77782             reset();
77783             writer = previousWriter;
77784         }
77785         function writeList(format, nodes, sourceFile, output) {
77786             var previousWriter = writer;
77787             setWriter(output, undefined);
77788             if (sourceFile) {
77789                 setSourceFile(sourceFile);
77790             }
77791             emitList(syntheticParent, nodes, format);
77792             reset();
77793             writer = previousWriter;
77794         }
77795         function getTextPosWithWriteLine() {
77796             return writer.getTextPosWithWriteLine ? writer.getTextPosWithWriteLine() : writer.getTextPos();
77797         }
77798         function updateOrPushBundleFileTextLike(pos, end, kind) {
77799             var last = ts.lastOrUndefined(bundleFileInfo.sections);
77800             if (last && last.kind === kind) {
77801                 last.end = end;
77802             }
77803             else {
77804                 bundleFileInfo.sections.push({ pos: pos, end: end, kind: kind });
77805             }
77806         }
77807         function recordBundleFileInternalSectionStart(node) {
77808             if (recordInternalSection &&
77809                 bundleFileInfo &&
77810                 currentSourceFile &&
77811                 (ts.isDeclaration(node) || ts.isVariableStatement(node)) &&
77812                 ts.isInternalDeclaration(node, currentSourceFile) &&
77813                 sourceFileTextKind !== "internal") {
77814                 var prevSourceFileTextKind = sourceFileTextKind;
77815                 recordBundleFileTextLikeSection(writer.getTextPos());
77816                 sourceFileTextPos = getTextPosWithWriteLine();
77817                 sourceFileTextKind = "internal";
77818                 return prevSourceFileTextKind;
77819             }
77820             return undefined;
77821         }
77822         function recordBundleFileInternalSectionEnd(prevSourceFileTextKind) {
77823             if (prevSourceFileTextKind) {
77824                 recordBundleFileTextLikeSection(writer.getTextPos());
77825                 sourceFileTextPos = getTextPosWithWriteLine();
77826                 sourceFileTextKind = prevSourceFileTextKind;
77827             }
77828         }
77829         function recordBundleFileTextLikeSection(end) {
77830             if (sourceFileTextPos < end) {
77831                 updateOrPushBundleFileTextLike(sourceFileTextPos, end, sourceFileTextKind);
77832                 return true;
77833             }
77834             return false;
77835         }
77836         function writeBundle(bundle, output, sourceMapGenerator) {
77837             var _a;
77838             isOwnFileEmit = false;
77839             var previousWriter = writer;
77840             setWriter(output, sourceMapGenerator);
77841             emitShebangIfNeeded(bundle);
77842             emitPrologueDirectivesIfNeeded(bundle);
77843             emitHelpers(bundle);
77844             emitSyntheticTripleSlashReferencesIfNeeded(bundle);
77845             for (var _b = 0, _c = bundle.prepends; _b < _c.length; _b++) {
77846                 var prepend = _c[_b];
77847                 writeLine();
77848                 var pos = writer.getTextPos();
77849                 var savedSections = bundleFileInfo && bundleFileInfo.sections;
77850                 if (savedSections)
77851                     bundleFileInfo.sections = [];
77852                 print(4, prepend, undefined);
77853                 if (bundleFileInfo) {
77854                     var newSections = bundleFileInfo.sections;
77855                     bundleFileInfo.sections = savedSections;
77856                     if (prepend.oldFileOfCurrentEmit)
77857                         (_a = bundleFileInfo.sections).push.apply(_a, newSections);
77858                     else {
77859                         newSections.forEach(function (section) { return ts.Debug.assert(ts.isBundleFileTextLike(section)); });
77860                         bundleFileInfo.sections.push({
77861                             pos: pos,
77862                             end: writer.getTextPos(),
77863                             kind: "prepend",
77864                             data: relativeToBuildInfo(prepend.fileName),
77865                             texts: newSections
77866                         });
77867                     }
77868                 }
77869             }
77870             sourceFileTextPos = getTextPosWithWriteLine();
77871             for (var _d = 0, _e = bundle.sourceFiles; _d < _e.length; _d++) {
77872                 var sourceFile = _e[_d];
77873                 print(0, sourceFile, sourceFile);
77874             }
77875             if (bundleFileInfo && bundle.sourceFiles.length) {
77876                 var end = writer.getTextPos();
77877                 if (recordBundleFileTextLikeSection(end)) {
77878                     var prologues = getPrologueDirectivesFromBundledSourceFiles(bundle);
77879                     if (prologues) {
77880                         if (!bundleFileInfo.sources)
77881                             bundleFileInfo.sources = {};
77882                         bundleFileInfo.sources.prologues = prologues;
77883                     }
77884                     var helpers = getHelpersFromBundledSourceFiles(bundle);
77885                     if (helpers) {
77886                         if (!bundleFileInfo.sources)
77887                             bundleFileInfo.sources = {};
77888                         bundleFileInfo.sources.helpers = helpers;
77889                     }
77890                 }
77891             }
77892             reset();
77893             writer = previousWriter;
77894         }
77895         function writeUnparsedSource(unparsed, output) {
77896             var previousWriter = writer;
77897             setWriter(output, undefined);
77898             print(4, unparsed, undefined);
77899             reset();
77900             writer = previousWriter;
77901         }
77902         function writeFile(sourceFile, output, sourceMapGenerator) {
77903             isOwnFileEmit = true;
77904             var previousWriter = writer;
77905             setWriter(output, sourceMapGenerator);
77906             emitShebangIfNeeded(sourceFile);
77907             emitPrologueDirectivesIfNeeded(sourceFile);
77908             print(0, sourceFile, sourceFile);
77909             reset();
77910             writer = previousWriter;
77911         }
77912         function beginPrint() {
77913             return ownWriter || (ownWriter = ts.createTextWriter(newLine));
77914         }
77915         function endPrint() {
77916             var text = ownWriter.getText();
77917             ownWriter.clear();
77918             return text;
77919         }
77920         function print(hint, node, sourceFile) {
77921             if (sourceFile) {
77922                 setSourceFile(sourceFile);
77923             }
77924             pipelineEmit(hint, node);
77925         }
77926         function setSourceFile(sourceFile) {
77927             currentSourceFile = sourceFile;
77928             currentLineMap = undefined;
77929             detachedCommentsInfo = undefined;
77930             if (sourceFile) {
77931                 setSourceMapSource(sourceFile);
77932             }
77933         }
77934         function setWriter(_writer, _sourceMapGenerator) {
77935             if (_writer && printerOptions.omitTrailingSemicolon) {
77936                 _writer = ts.getTrailingSemicolonDeferringWriter(_writer);
77937             }
77938             writer = _writer;
77939             sourceMapGenerator = _sourceMapGenerator;
77940             sourceMapsDisabled = !writer || !sourceMapGenerator;
77941         }
77942         function reset() {
77943             nodeIdToGeneratedName = [];
77944             autoGeneratedIdToGeneratedName = [];
77945             generatedNames = ts.createMap();
77946             tempFlagsStack = [];
77947             tempFlags = 0;
77948             reservedNamesStack = [];
77949             currentSourceFile = undefined;
77950             currentLineMap = undefined;
77951             detachedCommentsInfo = undefined;
77952             lastNode = undefined;
77953             lastSubstitution = undefined;
77954             setWriter(undefined, undefined);
77955         }
77956         function getCurrentLineMap() {
77957             return currentLineMap || (currentLineMap = ts.getLineStarts(currentSourceFile));
77958         }
77959         function emit(node) {
77960             if (node === undefined)
77961                 return;
77962             var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node);
77963             var substitute = pipelineEmit(4, node);
77964             recordBundleFileInternalSectionEnd(prevSourceFileTextKind);
77965             return substitute;
77966         }
77967         function emitIdentifierName(node) {
77968             if (node === undefined)
77969                 return;
77970             return pipelineEmit(2, node);
77971         }
77972         function emitExpression(node) {
77973             if (node === undefined)
77974                 return;
77975             return pipelineEmit(1, node);
77976         }
77977         function emitJsxAttributeValue(node) {
77978             return pipelineEmit(ts.isStringLiteral(node) ? 6 : 4, node);
77979         }
77980         function pipelineEmit(emitHint, node) {
77981             var savedLastNode = lastNode;
77982             var savedLastSubstitution = lastSubstitution;
77983             var savedPreserveSourceNewlines = preserveSourceNewlines;
77984             lastNode = node;
77985             lastSubstitution = undefined;
77986             if (preserveSourceNewlines && !!(ts.getEmitFlags(node) & 134217728)) {
77987                 preserveSourceNewlines = false;
77988             }
77989             var pipelinePhase = getPipelinePhase(0, emitHint, node);
77990             pipelinePhase(emitHint, node);
77991             ts.Debug.assert(lastNode === node);
77992             var substitute = lastSubstitution;
77993             lastNode = savedLastNode;
77994             lastSubstitution = savedLastSubstitution;
77995             preserveSourceNewlines = savedPreserveSourceNewlines;
77996             return substitute || node;
77997         }
77998         function getPipelinePhase(phase, emitHint, node) {
77999             switch (phase) {
78000                 case 0:
78001                     if (onEmitNode !== ts.noEmitNotification && (!isEmitNotificationEnabled || isEmitNotificationEnabled(node))) {
78002                         return pipelineEmitWithNotification;
78003                     }
78004                 case 1:
78005                     if (substituteNode !== ts.noEmitSubstitution && (lastSubstitution = substituteNode(emitHint, node)) !== node) {
78006                         return pipelineEmitWithSubstitution;
78007                     }
78008                 case 2:
78009                     if (!commentsDisabled && node.kind !== 290) {
78010                         return pipelineEmitWithComments;
78011                     }
78012                 case 3:
78013                     if (!sourceMapsDisabled && node.kind !== 290 && !ts.isInJsonFile(node)) {
78014                         return pipelineEmitWithSourceMap;
78015                     }
78016                 case 4:
78017                     return pipelineEmitWithHint;
78018                 default:
78019                     return ts.Debug.assertNever(phase);
78020             }
78021         }
78022         function getNextPipelinePhase(currentPhase, emitHint, node) {
78023             return getPipelinePhase(currentPhase + 1, emitHint, node);
78024         }
78025         function pipelineEmitWithNotification(hint, node) {
78026             ts.Debug.assert(lastNode === node);
78027             var pipelinePhase = getNextPipelinePhase(0, hint, node);
78028             onEmitNode(hint, node, pipelinePhase);
78029             ts.Debug.assert(lastNode === node);
78030         }
78031         function pipelineEmitWithHint(hint, node) {
78032             ts.Debug.assert(lastNode === node || lastSubstitution === node);
78033             if (hint === 0)
78034                 return emitSourceFile(ts.cast(node, ts.isSourceFile));
78035             if (hint === 2)
78036                 return emitIdentifier(ts.cast(node, ts.isIdentifier));
78037             if (hint === 6)
78038                 return emitLiteral(ts.cast(node, ts.isStringLiteral), true);
78039             if (hint === 3)
78040                 return emitMappedTypeParameter(ts.cast(node, ts.isTypeParameterDeclaration));
78041             if (hint === 5) {
78042                 ts.Debug.assertNode(node, ts.isEmptyStatement);
78043                 return emitEmptyStatement(true);
78044             }
78045             if (hint === 4) {
78046                 if (ts.isKeyword(node.kind))
78047                     return writeTokenNode(node, writeKeyword);
78048                 switch (node.kind) {
78049                     case 15:
78050                     case 16:
78051                     case 17:
78052                         return emitLiteral(node, false);
78053                     case 292:
78054                     case 286:
78055                         return emitUnparsedSourceOrPrepend(node);
78056                     case 285:
78057                         return writeUnparsedNode(node);
78058                     case 287:
78059                     case 288:
78060                         return emitUnparsedTextLike(node);
78061                     case 289:
78062                         return emitUnparsedSyntheticReference(node);
78063                     case 75:
78064                         return emitIdentifier(node);
78065                     case 76:
78066                         return emitPrivateIdentifier(node);
78067                     case 153:
78068                         return emitQualifiedName(node);
78069                     case 154:
78070                         return emitComputedPropertyName(node);
78071                     case 155:
78072                         return emitTypeParameter(node);
78073                     case 156:
78074                         return emitParameter(node);
78075                     case 157:
78076                         return emitDecorator(node);
78077                     case 158:
78078                         return emitPropertySignature(node);
78079                     case 159:
78080                         return emitPropertyDeclaration(node);
78081                     case 160:
78082                         return emitMethodSignature(node);
78083                     case 161:
78084                         return emitMethodDeclaration(node);
78085                     case 162:
78086                         return emitConstructor(node);
78087                     case 163:
78088                     case 164:
78089                         return emitAccessorDeclaration(node);
78090                     case 165:
78091                         return emitCallSignature(node);
78092                     case 166:
78093                         return emitConstructSignature(node);
78094                     case 167:
78095                         return emitIndexSignature(node);
78096                     case 168:
78097                         return emitTypePredicate(node);
78098                     case 169:
78099                         return emitTypeReference(node);
78100                     case 170:
78101                         return emitFunctionType(node);
78102                     case 300:
78103                         return emitJSDocFunctionType(node);
78104                     case 171:
78105                         return emitConstructorType(node);
78106                     case 172:
78107                         return emitTypeQuery(node);
78108                     case 173:
78109                         return emitTypeLiteral(node);
78110                     case 174:
78111                         return emitArrayType(node);
78112                     case 175:
78113                         return emitTupleType(node);
78114                     case 176:
78115                         return emitOptionalType(node);
78116                     case 178:
78117                         return emitUnionType(node);
78118                     case 179:
78119                         return emitIntersectionType(node);
78120                     case 180:
78121                         return emitConditionalType(node);
78122                     case 181:
78123                         return emitInferType(node);
78124                     case 182:
78125                         return emitParenthesizedType(node);
78126                     case 216:
78127                         return emitExpressionWithTypeArguments(node);
78128                     case 183:
78129                         return emitThisType();
78130                     case 184:
78131                         return emitTypeOperator(node);
78132                     case 185:
78133                         return emitIndexedAccessType(node);
78134                     case 186:
78135                         return emitMappedType(node);
78136                     case 187:
78137                         return emitLiteralType(node);
78138                     case 188:
78139                         return emitImportTypeNode(node);
78140                     case 295:
78141                         writePunctuation("*");
78142                         return;
78143                     case 296:
78144                         writePunctuation("?");
78145                         return;
78146                     case 297:
78147                         return emitJSDocNullableType(node);
78148                     case 298:
78149                         return emitJSDocNonNullableType(node);
78150                     case 299:
78151                         return emitJSDocOptionalType(node);
78152                     case 177:
78153                     case 301:
78154                         return emitRestOrJSDocVariadicType(node);
78155                     case 189:
78156                         return emitObjectBindingPattern(node);
78157                     case 190:
78158                         return emitArrayBindingPattern(node);
78159                     case 191:
78160                         return emitBindingElement(node);
78161                     case 221:
78162                         return emitTemplateSpan(node);
78163                     case 222:
78164                         return emitSemicolonClassElement();
78165                     case 223:
78166                         return emitBlock(node);
78167                     case 225:
78168                         return emitVariableStatement(node);
78169                     case 224:
78170                         return emitEmptyStatement(false);
78171                     case 226:
78172                         return emitExpressionStatement(node);
78173                     case 227:
78174                         return emitIfStatement(node);
78175                     case 228:
78176                         return emitDoStatement(node);
78177                     case 229:
78178                         return emitWhileStatement(node);
78179                     case 230:
78180                         return emitForStatement(node);
78181                     case 231:
78182                         return emitForInStatement(node);
78183                     case 232:
78184                         return emitForOfStatement(node);
78185                     case 233:
78186                         return emitContinueStatement(node);
78187                     case 234:
78188                         return emitBreakStatement(node);
78189                     case 235:
78190                         return emitReturnStatement(node);
78191                     case 236:
78192                         return emitWithStatement(node);
78193                     case 237:
78194                         return emitSwitchStatement(node);
78195                     case 238:
78196                         return emitLabeledStatement(node);
78197                     case 239:
78198                         return emitThrowStatement(node);
78199                     case 240:
78200                         return emitTryStatement(node);
78201                     case 241:
78202                         return emitDebuggerStatement(node);
78203                     case 242:
78204                         return emitVariableDeclaration(node);
78205                     case 243:
78206                         return emitVariableDeclarationList(node);
78207                     case 244:
78208                         return emitFunctionDeclaration(node);
78209                     case 245:
78210                         return emitClassDeclaration(node);
78211                     case 246:
78212                         return emitInterfaceDeclaration(node);
78213                     case 247:
78214                         return emitTypeAliasDeclaration(node);
78215                     case 248:
78216                         return emitEnumDeclaration(node);
78217                     case 249:
78218                         return emitModuleDeclaration(node);
78219                     case 250:
78220                         return emitModuleBlock(node);
78221                     case 251:
78222                         return emitCaseBlock(node);
78223                     case 252:
78224                         return emitNamespaceExportDeclaration(node);
78225                     case 253:
78226                         return emitImportEqualsDeclaration(node);
78227                     case 254:
78228                         return emitImportDeclaration(node);
78229                     case 255:
78230                         return emitImportClause(node);
78231                     case 256:
78232                         return emitNamespaceImport(node);
78233                     case 262:
78234                         return emitNamespaceExport(node);
78235                     case 257:
78236                         return emitNamedImports(node);
78237                     case 258:
78238                         return emitImportSpecifier(node);
78239                     case 259:
78240                         return emitExportAssignment(node);
78241                     case 260:
78242                         return emitExportDeclaration(node);
78243                     case 261:
78244                         return emitNamedExports(node);
78245                     case 263:
78246                         return emitExportSpecifier(node);
78247                     case 264:
78248                         return;
78249                     case 265:
78250                         return emitExternalModuleReference(node);
78251                     case 11:
78252                         return emitJsxText(node);
78253                     case 268:
78254                     case 271:
78255                         return emitJsxOpeningElementOrFragment(node);
78256                     case 269:
78257                     case 272:
78258                         return emitJsxClosingElementOrFragment(node);
78259                     case 273:
78260                         return emitJsxAttribute(node);
78261                     case 274:
78262                         return emitJsxAttributes(node);
78263                     case 275:
78264                         return emitJsxSpreadAttribute(node);
78265                     case 276:
78266                         return emitJsxExpression(node);
78267                     case 277:
78268                         return emitCaseClause(node);
78269                     case 278:
78270                         return emitDefaultClause(node);
78271                     case 279:
78272                         return emitHeritageClause(node);
78273                     case 280:
78274                         return emitCatchClause(node);
78275                     case 281:
78276                         return emitPropertyAssignment(node);
78277                     case 282:
78278                         return emitShorthandPropertyAssignment(node);
78279                     case 283:
78280                         return emitSpreadAssignment(node);
78281                     case 284:
78282                         return emitEnumMember(node);
78283                     case 317:
78284                     case 323:
78285                         return emitJSDocPropertyLikeTag(node);
78286                     case 318:
78287                     case 320:
78288                     case 319:
78289                     case 316:
78290                         return emitJSDocSimpleTypedTag(node);
78291                     case 308:
78292                     case 307:
78293                         return emitJSDocHeritageTag(node);
78294                     case 321:
78295                         return emitJSDocTemplateTag(node);
78296                     case 322:
78297                         return emitJSDocTypedefTag(node);
78298                     case 315:
78299                         return emitJSDocCallbackTag(node);
78300                     case 305:
78301                         return emitJSDocSignature(node);
78302                     case 304:
78303                         return emitJSDocTypeLiteral(node);
78304                     case 310:
78305                     case 306:
78306                         return emitJSDocSimpleTag(node);
78307                     case 303:
78308                         return emitJSDoc(node);
78309                 }
78310                 if (ts.isExpression(node)) {
78311                     hint = 1;
78312                     if (substituteNode !== ts.noEmitSubstitution) {
78313                         lastSubstitution = node = substituteNode(hint, node);
78314                     }
78315                 }
78316                 else if (ts.isToken(node)) {
78317                     return writeTokenNode(node, writePunctuation);
78318                 }
78319             }
78320             if (hint === 1) {
78321                 switch (node.kind) {
78322                     case 8:
78323                     case 9:
78324                         return emitNumericOrBigIntLiteral(node);
78325                     case 10:
78326                     case 13:
78327                     case 14:
78328                         return emitLiteral(node, false);
78329                     case 75:
78330                         return emitIdentifier(node);
78331                     case 91:
78332                     case 100:
78333                     case 102:
78334                     case 106:
78335                     case 104:
78336                     case 96:
78337                         writeTokenNode(node, writeKeyword);
78338                         return;
78339                     case 192:
78340                         return emitArrayLiteralExpression(node);
78341                     case 193:
78342                         return emitObjectLiteralExpression(node);
78343                     case 194:
78344                         return emitPropertyAccessExpression(node);
78345                     case 195:
78346                         return emitElementAccessExpression(node);
78347                     case 196:
78348                         return emitCallExpression(node);
78349                     case 197:
78350                         return emitNewExpression(node);
78351                     case 198:
78352                         return emitTaggedTemplateExpression(node);
78353                     case 199:
78354                         return emitTypeAssertionExpression(node);
78355                     case 200:
78356                         return emitParenthesizedExpression(node);
78357                     case 201:
78358                         return emitFunctionExpression(node);
78359                     case 202:
78360                         return emitArrowFunction(node);
78361                     case 203:
78362                         return emitDeleteExpression(node);
78363                     case 204:
78364                         return emitTypeOfExpression(node);
78365                     case 205:
78366                         return emitVoidExpression(node);
78367                     case 206:
78368                         return emitAwaitExpression(node);
78369                     case 207:
78370                         return emitPrefixUnaryExpression(node);
78371                     case 208:
78372                         return emitPostfixUnaryExpression(node);
78373                     case 209:
78374                         return emitBinaryExpression(node);
78375                     case 210:
78376                         return emitConditionalExpression(node);
78377                     case 211:
78378                         return emitTemplateExpression(node);
78379                     case 212:
78380                         return emitYieldExpression(node);
78381                     case 213:
78382                         return emitSpreadExpression(node);
78383                     case 214:
78384                         return emitClassExpression(node);
78385                     case 215:
78386                         return;
78387                     case 217:
78388                         return emitAsExpression(node);
78389                     case 218:
78390                         return emitNonNullExpression(node);
78391                     case 219:
78392                         return emitMetaProperty(node);
78393                     case 266:
78394                         return emitJsxElement(node);
78395                     case 267:
78396                         return emitJsxSelfClosingElement(node);
78397                     case 270:
78398                         return emitJsxFragment(node);
78399                     case 326:
78400                         return emitPartiallyEmittedExpression(node);
78401                     case 327:
78402                         return emitCommaList(node);
78403                 }
78404             }
78405         }
78406         function emitMappedTypeParameter(node) {
78407             emit(node.name);
78408             writeSpace();
78409             writeKeyword("in");
78410             writeSpace();
78411             emit(node.constraint);
78412         }
78413         function pipelineEmitWithSubstitution(hint, node) {
78414             ts.Debug.assert(lastNode === node || lastSubstitution === node);
78415             var pipelinePhase = getNextPipelinePhase(1, hint, node);
78416             pipelinePhase(hint, lastSubstitution);
78417             ts.Debug.assert(lastNode === node || lastSubstitution === node);
78418         }
78419         function getHelpersFromBundledSourceFiles(bundle) {
78420             var result;
78421             if (moduleKind === ts.ModuleKind.None || printerOptions.noEmitHelpers) {
78422                 return undefined;
78423             }
78424             var bundledHelpers = ts.createMap();
78425             for (var _a = 0, _b = bundle.sourceFiles; _a < _b.length; _a++) {
78426                 var sourceFile = _b[_a];
78427                 var shouldSkip = ts.getExternalHelpersModuleName(sourceFile) !== undefined;
78428                 var helpers = getSortedEmitHelpers(sourceFile);
78429                 if (!helpers)
78430                     continue;
78431                 for (var _c = 0, helpers_4 = helpers; _c < helpers_4.length; _c++) {
78432                     var helper = helpers_4[_c];
78433                     if (!helper.scoped && !shouldSkip && !bundledHelpers.get(helper.name)) {
78434                         bundledHelpers.set(helper.name, true);
78435                         (result || (result = [])).push(helper.name);
78436                     }
78437                 }
78438             }
78439             return result;
78440         }
78441         function emitHelpers(node) {
78442             var helpersEmitted = false;
78443             var bundle = node.kind === 291 ? node : undefined;
78444             if (bundle && moduleKind === ts.ModuleKind.None) {
78445                 return;
78446             }
78447             var numPrepends = bundle ? bundle.prepends.length : 0;
78448             var numNodes = bundle ? bundle.sourceFiles.length + numPrepends : 1;
78449             for (var i = 0; i < numNodes; i++) {
78450                 var currentNode = bundle ? i < numPrepends ? bundle.prepends[i] : bundle.sourceFiles[i - numPrepends] : node;
78451                 var sourceFile = ts.isSourceFile(currentNode) ? currentNode : ts.isUnparsedSource(currentNode) ? undefined : currentSourceFile;
78452                 var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.hasRecordedExternalHelpers(sourceFile));
78453                 var shouldBundle = (ts.isSourceFile(currentNode) || ts.isUnparsedSource(currentNode)) && !isOwnFileEmit;
78454                 var helpers = ts.isUnparsedSource(currentNode) ? currentNode.helpers : getSortedEmitHelpers(currentNode);
78455                 if (helpers) {
78456                     for (var _a = 0, helpers_5 = helpers; _a < helpers_5.length; _a++) {
78457                         var helper = helpers_5[_a];
78458                         if (!helper.scoped) {
78459                             if (shouldSkip)
78460                                 continue;
78461                             if (shouldBundle) {
78462                                 if (bundledHelpers.get(helper.name)) {
78463                                     continue;
78464                                 }
78465                                 bundledHelpers.set(helper.name, true);
78466                             }
78467                         }
78468                         else if (bundle) {
78469                             continue;
78470                         }
78471                         var pos = getTextPosWithWriteLine();
78472                         if (typeof helper.text === "string") {
78473                             writeLines(helper.text);
78474                         }
78475                         else {
78476                             writeLines(helper.text(makeFileLevelOptimisticUniqueName));
78477                         }
78478                         if (bundleFileInfo)
78479                             bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "emitHelpers", data: helper.name });
78480                         helpersEmitted = true;
78481                     }
78482                 }
78483             }
78484             return helpersEmitted;
78485         }
78486         function getSortedEmitHelpers(node) {
78487             var helpers = ts.getEmitHelpers(node);
78488             return helpers && ts.stableSort(helpers, ts.compareEmitHelpers);
78489         }
78490         function emitNumericOrBigIntLiteral(node) {
78491             emitLiteral(node, false);
78492         }
78493         function emitLiteral(node, jsxAttributeEscape) {
78494             var text = getLiteralTextOfNode(node, printerOptions.neverAsciiEscape, jsxAttributeEscape);
78495             if ((printerOptions.sourceMap || printerOptions.inlineSourceMap)
78496                 && (node.kind === 10 || ts.isTemplateLiteralKind(node.kind))) {
78497                 writeLiteral(text);
78498             }
78499             else {
78500                 writeStringLiteral(text);
78501             }
78502         }
78503         function emitUnparsedSourceOrPrepend(unparsed) {
78504             for (var _a = 0, _b = unparsed.texts; _a < _b.length; _a++) {
78505                 var text = _b[_a];
78506                 writeLine();
78507                 emit(text);
78508             }
78509         }
78510         function writeUnparsedNode(unparsed) {
78511             writer.rawWrite(unparsed.parent.text.substring(unparsed.pos, unparsed.end));
78512         }
78513         function emitUnparsedTextLike(unparsed) {
78514             var pos = getTextPosWithWriteLine();
78515             writeUnparsedNode(unparsed);
78516             if (bundleFileInfo) {
78517                 updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 287 ?
78518                     "text" :
78519                     "internal");
78520             }
78521         }
78522         function emitUnparsedSyntheticReference(unparsed) {
78523             var pos = getTextPosWithWriteLine();
78524             writeUnparsedNode(unparsed);
78525             if (bundleFileInfo) {
78526                 var section = ts.clone(unparsed.section);
78527                 section.pos = pos;
78528                 section.end = writer.getTextPos();
78529                 bundleFileInfo.sections.push(section);
78530             }
78531         }
78532         function emitIdentifier(node) {
78533             var writeText = node.symbol ? writeSymbol : write;
78534             writeText(getTextOfNode(node, false), node.symbol);
78535             emitList(node, node.typeArguments, 53776);
78536         }
78537         function emitPrivateIdentifier(node) {
78538             var writeText = node.symbol ? writeSymbol : write;
78539             writeText(getTextOfNode(node, false), node.symbol);
78540         }
78541         function emitQualifiedName(node) {
78542             emitEntityName(node.left);
78543             writePunctuation(".");
78544             emit(node.right);
78545         }
78546         function emitEntityName(node) {
78547             if (node.kind === 75) {
78548                 emitExpression(node);
78549             }
78550             else {
78551                 emit(node);
78552             }
78553         }
78554         function emitComputedPropertyName(node) {
78555             writePunctuation("[");
78556             emitExpression(node.expression);
78557             writePunctuation("]");
78558         }
78559         function emitTypeParameter(node) {
78560             emit(node.name);
78561             if (node.constraint) {
78562                 writeSpace();
78563                 writeKeyword("extends");
78564                 writeSpace();
78565                 emit(node.constraint);
78566             }
78567             if (node.default) {
78568                 writeSpace();
78569                 writeOperator("=");
78570                 writeSpace();
78571                 emit(node.default);
78572             }
78573         }
78574         function emitParameter(node) {
78575             emitDecorators(node, node.decorators);
78576             emitModifiers(node, node.modifiers);
78577             emit(node.dotDotDotToken);
78578             emitNodeWithWriter(node.name, writeParameter);
78579             emit(node.questionToken);
78580             if (node.parent && node.parent.kind === 300 && !node.name) {
78581                 emit(node.type);
78582             }
78583             else {
78584                 emitTypeAnnotation(node.type);
78585             }
78586             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);
78587         }
78588         function emitDecorator(decorator) {
78589             writePunctuation("@");
78590             emitExpression(decorator.expression);
78591         }
78592         function emitPropertySignature(node) {
78593             emitDecorators(node, node.decorators);
78594             emitModifiers(node, node.modifiers);
78595             emitNodeWithWriter(node.name, writeProperty);
78596             emit(node.questionToken);
78597             emitTypeAnnotation(node.type);
78598             writeTrailingSemicolon();
78599         }
78600         function emitPropertyDeclaration(node) {
78601             emitDecorators(node, node.decorators);
78602             emitModifiers(node, node.modifiers);
78603             emit(node.name);
78604             emit(node.questionToken);
78605             emit(node.exclamationToken);
78606             emitTypeAnnotation(node.type);
78607             emitInitializer(node.initializer, node.type ? node.type.end : node.questionToken ? node.questionToken.end : node.name.end, node);
78608             writeTrailingSemicolon();
78609         }
78610         function emitMethodSignature(node) {
78611             pushNameGenerationScope(node);
78612             emitDecorators(node, node.decorators);
78613             emitModifiers(node, node.modifiers);
78614             emit(node.name);
78615             emit(node.questionToken);
78616             emitTypeParameters(node, node.typeParameters);
78617             emitParameters(node, node.parameters);
78618             emitTypeAnnotation(node.type);
78619             writeTrailingSemicolon();
78620             popNameGenerationScope(node);
78621         }
78622         function emitMethodDeclaration(node) {
78623             emitDecorators(node, node.decorators);
78624             emitModifiers(node, node.modifiers);
78625             emit(node.asteriskToken);
78626             emit(node.name);
78627             emit(node.questionToken);
78628             emitSignatureAndBody(node, emitSignatureHead);
78629         }
78630         function emitConstructor(node) {
78631             emitModifiers(node, node.modifiers);
78632             writeKeyword("constructor");
78633             emitSignatureAndBody(node, emitSignatureHead);
78634         }
78635         function emitAccessorDeclaration(node) {
78636             emitDecorators(node, node.decorators);
78637             emitModifiers(node, node.modifiers);
78638             writeKeyword(node.kind === 163 ? "get" : "set");
78639             writeSpace();
78640             emit(node.name);
78641             emitSignatureAndBody(node, emitSignatureHead);
78642         }
78643         function emitCallSignature(node) {
78644             pushNameGenerationScope(node);
78645             emitDecorators(node, node.decorators);
78646             emitModifiers(node, node.modifiers);
78647             emitTypeParameters(node, node.typeParameters);
78648             emitParameters(node, node.parameters);
78649             emitTypeAnnotation(node.type);
78650             writeTrailingSemicolon();
78651             popNameGenerationScope(node);
78652         }
78653         function emitConstructSignature(node) {
78654             pushNameGenerationScope(node);
78655             emitDecorators(node, node.decorators);
78656             emitModifiers(node, node.modifiers);
78657             writeKeyword("new");
78658             writeSpace();
78659             emitTypeParameters(node, node.typeParameters);
78660             emitParameters(node, node.parameters);
78661             emitTypeAnnotation(node.type);
78662             writeTrailingSemicolon();
78663             popNameGenerationScope(node);
78664         }
78665         function emitIndexSignature(node) {
78666             emitDecorators(node, node.decorators);
78667             emitModifiers(node, node.modifiers);
78668             emitParametersForIndexSignature(node, node.parameters);
78669             emitTypeAnnotation(node.type);
78670             writeTrailingSemicolon();
78671         }
78672         function emitSemicolonClassElement() {
78673             writeTrailingSemicolon();
78674         }
78675         function emitTypePredicate(node) {
78676             if (node.assertsModifier) {
78677                 emit(node.assertsModifier);
78678                 writeSpace();
78679             }
78680             emit(node.parameterName);
78681             if (node.type) {
78682                 writeSpace();
78683                 writeKeyword("is");
78684                 writeSpace();
78685                 emit(node.type);
78686             }
78687         }
78688         function emitTypeReference(node) {
78689             emit(node.typeName);
78690             emitTypeArguments(node, node.typeArguments);
78691         }
78692         function emitFunctionType(node) {
78693             pushNameGenerationScope(node);
78694             emitTypeParameters(node, node.typeParameters);
78695             emitParametersForArrow(node, node.parameters);
78696             writeSpace();
78697             writePunctuation("=>");
78698             writeSpace();
78699             emit(node.type);
78700             popNameGenerationScope(node);
78701         }
78702         function emitJSDocFunctionType(node) {
78703             writeKeyword("function");
78704             emitParameters(node, node.parameters);
78705             writePunctuation(":");
78706             emit(node.type);
78707         }
78708         function emitJSDocNullableType(node) {
78709             writePunctuation("?");
78710             emit(node.type);
78711         }
78712         function emitJSDocNonNullableType(node) {
78713             writePunctuation("!");
78714             emit(node.type);
78715         }
78716         function emitJSDocOptionalType(node) {
78717             emit(node.type);
78718             writePunctuation("=");
78719         }
78720         function emitConstructorType(node) {
78721             pushNameGenerationScope(node);
78722             writeKeyword("new");
78723             writeSpace();
78724             emitTypeParameters(node, node.typeParameters);
78725             emitParameters(node, node.parameters);
78726             writeSpace();
78727             writePunctuation("=>");
78728             writeSpace();
78729             emit(node.type);
78730             popNameGenerationScope(node);
78731         }
78732         function emitTypeQuery(node) {
78733             writeKeyword("typeof");
78734             writeSpace();
78735             emit(node.exprName);
78736         }
78737         function emitTypeLiteral(node) {
78738             writePunctuation("{");
78739             var flags = ts.getEmitFlags(node) & 1 ? 768 : 32897;
78740             emitList(node, node.members, flags | 524288);
78741             writePunctuation("}");
78742         }
78743         function emitArrayType(node) {
78744             emit(node.elementType);
78745             writePunctuation("[");
78746             writePunctuation("]");
78747         }
78748         function emitRestOrJSDocVariadicType(node) {
78749             writePunctuation("...");
78750             emit(node.type);
78751         }
78752         function emitTupleType(node) {
78753             writePunctuation("[");
78754             emitList(node, node.elementTypes, 528);
78755             writePunctuation("]");
78756         }
78757         function emitOptionalType(node) {
78758             emit(node.type);
78759             writePunctuation("?");
78760         }
78761         function emitUnionType(node) {
78762             emitList(node, node.types, 516);
78763         }
78764         function emitIntersectionType(node) {
78765             emitList(node, node.types, 520);
78766         }
78767         function emitConditionalType(node) {
78768             emit(node.checkType);
78769             writeSpace();
78770             writeKeyword("extends");
78771             writeSpace();
78772             emit(node.extendsType);
78773             writeSpace();
78774             writePunctuation("?");
78775             writeSpace();
78776             emit(node.trueType);
78777             writeSpace();
78778             writePunctuation(":");
78779             writeSpace();
78780             emit(node.falseType);
78781         }
78782         function emitInferType(node) {
78783             writeKeyword("infer");
78784             writeSpace();
78785             emit(node.typeParameter);
78786         }
78787         function emitParenthesizedType(node) {
78788             writePunctuation("(");
78789             emit(node.type);
78790             writePunctuation(")");
78791         }
78792         function emitThisType() {
78793             writeKeyword("this");
78794         }
78795         function emitTypeOperator(node) {
78796             writeTokenText(node.operator, writeKeyword);
78797             writeSpace();
78798             emit(node.type);
78799         }
78800         function emitIndexedAccessType(node) {
78801             emit(node.objectType);
78802             writePunctuation("[");
78803             emit(node.indexType);
78804             writePunctuation("]");
78805         }
78806         function emitMappedType(node) {
78807             var emitFlags = ts.getEmitFlags(node);
78808             writePunctuation("{");
78809             if (emitFlags & 1) {
78810                 writeSpace();
78811             }
78812             else {
78813                 writeLine();
78814                 increaseIndent();
78815             }
78816             if (node.readonlyToken) {
78817                 emit(node.readonlyToken);
78818                 if (node.readonlyToken.kind !== 138) {
78819                     writeKeyword("readonly");
78820                 }
78821                 writeSpace();
78822             }
78823             writePunctuation("[");
78824             pipelineEmit(3, node.typeParameter);
78825             writePunctuation("]");
78826             if (node.questionToken) {
78827                 emit(node.questionToken);
78828                 if (node.questionToken.kind !== 57) {
78829                     writePunctuation("?");
78830                 }
78831             }
78832             writePunctuation(":");
78833             writeSpace();
78834             emit(node.type);
78835             writeTrailingSemicolon();
78836             if (emitFlags & 1) {
78837                 writeSpace();
78838             }
78839             else {
78840                 writeLine();
78841                 decreaseIndent();
78842             }
78843             writePunctuation("}");
78844         }
78845         function emitLiteralType(node) {
78846             emitExpression(node.literal);
78847         }
78848         function emitImportTypeNode(node) {
78849             if (node.isTypeOf) {
78850                 writeKeyword("typeof");
78851                 writeSpace();
78852             }
78853             writeKeyword("import");
78854             writePunctuation("(");
78855             emit(node.argument);
78856             writePunctuation(")");
78857             if (node.qualifier) {
78858                 writePunctuation(".");
78859                 emit(node.qualifier);
78860             }
78861             emitTypeArguments(node, node.typeArguments);
78862         }
78863         function emitObjectBindingPattern(node) {
78864             writePunctuation("{");
78865             emitList(node, node.elements, 525136);
78866             writePunctuation("}");
78867         }
78868         function emitArrayBindingPattern(node) {
78869             writePunctuation("[");
78870             emitList(node, node.elements, 524880);
78871             writePunctuation("]");
78872         }
78873         function emitBindingElement(node) {
78874             emit(node.dotDotDotToken);
78875             if (node.propertyName) {
78876                 emit(node.propertyName);
78877                 writePunctuation(":");
78878                 writeSpace();
78879             }
78880             emit(node.name);
78881             emitInitializer(node.initializer, node.name.end, node);
78882         }
78883         function emitArrayLiteralExpression(node) {
78884             var elements = node.elements;
78885             var preferNewLine = node.multiLine ? 65536 : 0;
78886             emitExpressionList(node, elements, 8914 | preferNewLine);
78887         }
78888         function emitObjectLiteralExpression(node) {
78889             ts.forEach(node.properties, generateMemberNames);
78890             var indentedFlag = ts.getEmitFlags(node) & 65536;
78891             if (indentedFlag) {
78892                 increaseIndent();
78893             }
78894             var preferNewLine = node.multiLine ? 65536 : 0;
78895             var allowTrailingComma = currentSourceFile.languageVersion >= 1 && !ts.isJsonSourceFile(currentSourceFile) ? 64 : 0;
78896             emitList(node, node.properties, 526226 | allowTrailingComma | preferNewLine);
78897             if (indentedFlag) {
78898                 decreaseIndent();
78899             }
78900         }
78901         function emitPropertyAccessExpression(node) {
78902             var expression = ts.cast(emitExpression(node.expression), ts.isExpression);
78903             var token = node.questionDotToken || ts.createNode(24, node.expression.end, node.name.pos);
78904             var linesBeforeDot = getLinesBetweenNodes(node, node.expression, token);
78905             var linesAfterDot = getLinesBetweenNodes(node, token, node.name);
78906             writeLinesAndIndent(linesBeforeDot, false);
78907             var shouldEmitDotDot = token.kind !== 28 &&
78908                 mayNeedDotDotForPropertyAccess(expression) &&
78909                 !writer.hasTrailingComment() &&
78910                 !writer.hasTrailingWhitespace();
78911             if (shouldEmitDotDot) {
78912                 writePunctuation(".");
78913             }
78914             if (node.questionDotToken) {
78915                 emit(token);
78916             }
78917             else {
78918                 emitTokenWithComment(token.kind, node.expression.end, writePunctuation, node);
78919             }
78920             writeLinesAndIndent(linesAfterDot, false);
78921             emit(node.name);
78922             decreaseIndentIf(linesBeforeDot, linesAfterDot);
78923         }
78924         function mayNeedDotDotForPropertyAccess(expression) {
78925             expression = ts.skipPartiallyEmittedExpressions(expression);
78926             if (ts.isNumericLiteral(expression)) {
78927                 var text = getLiteralTextOfNode(expression, true, false);
78928                 return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24));
78929             }
78930             else if (ts.isAccessExpression(expression)) {
78931                 var constantValue = ts.getConstantValue(expression);
78932                 return typeof constantValue === "number" && isFinite(constantValue)
78933                     && Math.floor(constantValue) === constantValue;
78934             }
78935         }
78936         function emitElementAccessExpression(node) {
78937             emitExpression(node.expression);
78938             emit(node.questionDotToken);
78939             emitTokenWithComment(22, node.expression.end, writePunctuation, node);
78940             emitExpression(node.argumentExpression);
78941             emitTokenWithComment(23, node.argumentExpression.end, writePunctuation, node);
78942         }
78943         function emitCallExpression(node) {
78944             emitExpression(node.expression);
78945             emit(node.questionDotToken);
78946             emitTypeArguments(node, node.typeArguments);
78947             emitExpressionList(node, node.arguments, 2576);
78948         }
78949         function emitNewExpression(node) {
78950             emitTokenWithComment(99, node.pos, writeKeyword, node);
78951             writeSpace();
78952             emitExpression(node.expression);
78953             emitTypeArguments(node, node.typeArguments);
78954             emitExpressionList(node, node.arguments, 18960);
78955         }
78956         function emitTaggedTemplateExpression(node) {
78957             emitExpression(node.tag);
78958             emitTypeArguments(node, node.typeArguments);
78959             writeSpace();
78960             emitExpression(node.template);
78961         }
78962         function emitTypeAssertionExpression(node) {
78963             writePunctuation("<");
78964             emit(node.type);
78965             writePunctuation(">");
78966             emitExpression(node.expression);
78967         }
78968         function emitParenthesizedExpression(node) {
78969             var openParenPos = emitTokenWithComment(20, node.pos, writePunctuation, node);
78970             var indented = writeLineSeparatorsAndIndentBefore(node.expression, node);
78971             emitExpression(node.expression);
78972             writeLineSeparatorsAfter(node.expression, node);
78973             decreaseIndentIf(indented);
78974             emitTokenWithComment(21, node.expression ? node.expression.end : openParenPos, writePunctuation, node);
78975         }
78976         function emitFunctionExpression(node) {
78977             generateNameIfNeeded(node.name);
78978             emitFunctionDeclarationOrExpression(node);
78979         }
78980         function emitArrowFunction(node) {
78981             emitDecorators(node, node.decorators);
78982             emitModifiers(node, node.modifiers);
78983             emitSignatureAndBody(node, emitArrowFunctionHead);
78984         }
78985         function emitArrowFunctionHead(node) {
78986             emitTypeParameters(node, node.typeParameters);
78987             emitParametersForArrow(node, node.parameters);
78988             emitTypeAnnotation(node.type);
78989             writeSpace();
78990             emit(node.equalsGreaterThanToken);
78991         }
78992         function emitDeleteExpression(node) {
78993             emitTokenWithComment(85, node.pos, writeKeyword, node);
78994             writeSpace();
78995             emitExpression(node.expression);
78996         }
78997         function emitTypeOfExpression(node) {
78998             emitTokenWithComment(108, node.pos, writeKeyword, node);
78999             writeSpace();
79000             emitExpression(node.expression);
79001         }
79002         function emitVoidExpression(node) {
79003             emitTokenWithComment(110, node.pos, writeKeyword, node);
79004             writeSpace();
79005             emitExpression(node.expression);
79006         }
79007         function emitAwaitExpression(node) {
79008             emitTokenWithComment(127, node.pos, writeKeyword, node);
79009             writeSpace();
79010             emitExpression(node.expression);
79011         }
79012         function emitPrefixUnaryExpression(node) {
79013             writeTokenText(node.operator, writeOperator);
79014             if (shouldEmitWhitespaceBeforeOperand(node)) {
79015                 writeSpace();
79016             }
79017             emitExpression(node.operand);
79018         }
79019         function shouldEmitWhitespaceBeforeOperand(node) {
79020             var operand = node.operand;
79021             return operand.kind === 207
79022                 && ((node.operator === 39 && (operand.operator === 39 || operand.operator === 45))
79023                     || (node.operator === 40 && (operand.operator === 40 || operand.operator === 46)));
79024         }
79025         function emitPostfixUnaryExpression(node) {
79026             emitExpression(node.operand);
79027             writeTokenText(node.operator, writeOperator);
79028         }
79029         function emitBinaryExpression(node) {
79030             var nodeStack = [node];
79031             var stateStack = [0];
79032             var stackIndex = 0;
79033             while (stackIndex >= 0) {
79034                 node = nodeStack[stackIndex];
79035                 switch (stateStack[stackIndex]) {
79036                     case 0: {
79037                         maybePipelineEmitExpression(node.left);
79038                         break;
79039                     }
79040                     case 1: {
79041                         var isCommaOperator = node.operatorToken.kind !== 27;
79042                         var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken);
79043                         var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right);
79044                         writeLinesAndIndent(linesBeforeOperator, isCommaOperator);
79045                         emitLeadingCommentsOfPosition(node.operatorToken.pos);
79046                         writeTokenNode(node.operatorToken, node.operatorToken.kind === 97 ? writeKeyword : writeOperator);
79047                         emitTrailingCommentsOfPosition(node.operatorToken.end, true);
79048                         writeLinesAndIndent(linesAfterOperator, true);
79049                         maybePipelineEmitExpression(node.right);
79050                         break;
79051                     }
79052                     case 2: {
79053                         var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken);
79054                         var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right);
79055                         decreaseIndentIf(linesBeforeOperator, linesAfterOperator);
79056                         stackIndex--;
79057                         break;
79058                     }
79059                     default: return ts.Debug.fail("Invalid state " + stateStack[stackIndex] + " for emitBinaryExpressionWorker");
79060                 }
79061             }
79062             function maybePipelineEmitExpression(next) {
79063                 stateStack[stackIndex]++;
79064                 var savedLastNode = lastNode;
79065                 var savedLastSubstitution = lastSubstitution;
79066                 lastNode = next;
79067                 lastSubstitution = undefined;
79068                 var pipelinePhase = getPipelinePhase(0, 1, next);
79069                 if (pipelinePhase === pipelineEmitWithHint && ts.isBinaryExpression(next)) {
79070                     stackIndex++;
79071                     stateStack[stackIndex] = 0;
79072                     nodeStack[stackIndex] = next;
79073                 }
79074                 else {
79075                     pipelinePhase(1, next);
79076                 }
79077                 ts.Debug.assert(lastNode === next);
79078                 lastNode = savedLastNode;
79079                 lastSubstitution = savedLastSubstitution;
79080             }
79081         }
79082         function emitConditionalExpression(node) {
79083             var linesBeforeQuestion = getLinesBetweenNodes(node, node.condition, node.questionToken);
79084             var linesAfterQuestion = getLinesBetweenNodes(node, node.questionToken, node.whenTrue);
79085             var linesBeforeColon = getLinesBetweenNodes(node, node.whenTrue, node.colonToken);
79086             var linesAfterColon = getLinesBetweenNodes(node, node.colonToken, node.whenFalse);
79087             emitExpression(node.condition);
79088             writeLinesAndIndent(linesBeforeQuestion, true);
79089             emit(node.questionToken);
79090             writeLinesAndIndent(linesAfterQuestion, true);
79091             emitExpression(node.whenTrue);
79092             decreaseIndentIf(linesBeforeQuestion, linesAfterQuestion);
79093             writeLinesAndIndent(linesBeforeColon, true);
79094             emit(node.colonToken);
79095             writeLinesAndIndent(linesAfterColon, true);
79096             emitExpression(node.whenFalse);
79097             decreaseIndentIf(linesBeforeColon, linesAfterColon);
79098         }
79099         function emitTemplateExpression(node) {
79100             emit(node.head);
79101             emitList(node, node.templateSpans, 262144);
79102         }
79103         function emitYieldExpression(node) {
79104             emitTokenWithComment(121, node.pos, writeKeyword, node);
79105             emit(node.asteriskToken);
79106             emitExpressionWithLeadingSpace(node.expression);
79107         }
79108         function emitSpreadExpression(node) {
79109             emitTokenWithComment(25, node.pos, writePunctuation, node);
79110             emitExpression(node.expression);
79111         }
79112         function emitClassExpression(node) {
79113             generateNameIfNeeded(node.name);
79114             emitClassDeclarationOrExpression(node);
79115         }
79116         function emitExpressionWithTypeArguments(node) {
79117             emitExpression(node.expression);
79118             emitTypeArguments(node, node.typeArguments);
79119         }
79120         function emitAsExpression(node) {
79121             emitExpression(node.expression);
79122             if (node.type) {
79123                 writeSpace();
79124                 writeKeyword("as");
79125                 writeSpace();
79126                 emit(node.type);
79127             }
79128         }
79129         function emitNonNullExpression(node) {
79130             emitExpression(node.expression);
79131             writeOperator("!");
79132         }
79133         function emitMetaProperty(node) {
79134             writeToken(node.keywordToken, node.pos, writePunctuation);
79135             writePunctuation(".");
79136             emit(node.name);
79137         }
79138         function emitTemplateSpan(node) {
79139             emitExpression(node.expression);
79140             emit(node.literal);
79141         }
79142         function emitBlock(node) {
79143             emitBlockStatements(node, !node.multiLine && isEmptyBlock(node));
79144         }
79145         function emitBlockStatements(node, forceSingleLine) {
79146             emitTokenWithComment(18, node.pos, writePunctuation, node);
79147             var format = forceSingleLine || ts.getEmitFlags(node) & 1 ? 768 : 129;
79148             emitList(node, node.statements, format);
79149             emitTokenWithComment(19, node.statements.end, writePunctuation, node, !!(format & 1));
79150         }
79151         function emitVariableStatement(node) {
79152             emitModifiers(node, node.modifiers);
79153             emit(node.declarationList);
79154             writeTrailingSemicolon();
79155         }
79156         function emitEmptyStatement(isEmbeddedStatement) {
79157             if (isEmbeddedStatement) {
79158                 writePunctuation(";");
79159             }
79160             else {
79161                 writeTrailingSemicolon();
79162             }
79163         }
79164         function emitExpressionStatement(node) {
79165             emitExpression(node.expression);
79166             if (!ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) {
79167                 writeTrailingSemicolon();
79168             }
79169         }
79170         function emitIfStatement(node) {
79171             var openParenPos = emitTokenWithComment(95, node.pos, writeKeyword, node);
79172             writeSpace();
79173             emitTokenWithComment(20, openParenPos, writePunctuation, node);
79174             emitExpression(node.expression);
79175             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
79176             emitEmbeddedStatement(node, node.thenStatement);
79177             if (node.elseStatement) {
79178                 writeLineOrSpace(node);
79179                 emitTokenWithComment(87, node.thenStatement.end, writeKeyword, node);
79180                 if (node.elseStatement.kind === 227) {
79181                     writeSpace();
79182                     emit(node.elseStatement);
79183                 }
79184                 else {
79185                     emitEmbeddedStatement(node, node.elseStatement);
79186                 }
79187             }
79188         }
79189         function emitWhileClause(node, startPos) {
79190             var openParenPos = emitTokenWithComment(111, startPos, writeKeyword, node);
79191             writeSpace();
79192             emitTokenWithComment(20, openParenPos, writePunctuation, node);
79193             emitExpression(node.expression);
79194             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
79195         }
79196         function emitDoStatement(node) {
79197             emitTokenWithComment(86, node.pos, writeKeyword, node);
79198             emitEmbeddedStatement(node, node.statement);
79199             if (ts.isBlock(node.statement)) {
79200                 writeSpace();
79201             }
79202             else {
79203                 writeLineOrSpace(node);
79204             }
79205             emitWhileClause(node, node.statement.end);
79206             writeTrailingSemicolon();
79207         }
79208         function emitWhileStatement(node) {
79209             emitWhileClause(node, node.pos);
79210             emitEmbeddedStatement(node, node.statement);
79211         }
79212         function emitForStatement(node) {
79213             var openParenPos = emitTokenWithComment(93, node.pos, writeKeyword, node);
79214             writeSpace();
79215             var pos = emitTokenWithComment(20, openParenPos, writePunctuation, node);
79216             emitForBinding(node.initializer);
79217             pos = emitTokenWithComment(26, node.initializer ? node.initializer.end : pos, writePunctuation, node);
79218             emitExpressionWithLeadingSpace(node.condition);
79219             pos = emitTokenWithComment(26, node.condition ? node.condition.end : pos, writePunctuation, node);
79220             emitExpressionWithLeadingSpace(node.incrementor);
79221             emitTokenWithComment(21, node.incrementor ? node.incrementor.end : pos, writePunctuation, node);
79222             emitEmbeddedStatement(node, node.statement);
79223         }
79224         function emitForInStatement(node) {
79225             var openParenPos = emitTokenWithComment(93, node.pos, writeKeyword, node);
79226             writeSpace();
79227             emitTokenWithComment(20, openParenPos, writePunctuation, node);
79228             emitForBinding(node.initializer);
79229             writeSpace();
79230             emitTokenWithComment(97, node.initializer.end, writeKeyword, node);
79231             writeSpace();
79232             emitExpression(node.expression);
79233             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
79234             emitEmbeddedStatement(node, node.statement);
79235         }
79236         function emitForOfStatement(node) {
79237             var openParenPos = emitTokenWithComment(93, node.pos, writeKeyword, node);
79238             writeSpace();
79239             emitWithTrailingSpace(node.awaitModifier);
79240             emitTokenWithComment(20, openParenPos, writePunctuation, node);
79241             emitForBinding(node.initializer);
79242             writeSpace();
79243             emitTokenWithComment(152, 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 emitForBinding(node) {
79250             if (node !== undefined) {
79251                 if (node.kind === 243) {
79252                     emit(node);
79253                 }
79254                 else {
79255                     emitExpression(node);
79256                 }
79257             }
79258         }
79259         function emitContinueStatement(node) {
79260             emitTokenWithComment(82, node.pos, writeKeyword, node);
79261             emitWithLeadingSpace(node.label);
79262             writeTrailingSemicolon();
79263         }
79264         function emitBreakStatement(node) {
79265             emitTokenWithComment(77, node.pos, writeKeyword, node);
79266             emitWithLeadingSpace(node.label);
79267             writeTrailingSemicolon();
79268         }
79269         function emitTokenWithComment(token, pos, writer, contextNode, indentLeading) {
79270             var node = ts.getParseTreeNode(contextNode);
79271             var isSimilarNode = node && node.kind === contextNode.kind;
79272             var startPos = pos;
79273             if (isSimilarNode && currentSourceFile) {
79274                 pos = ts.skipTrivia(currentSourceFile.text, pos);
79275             }
79276             if (emitLeadingCommentsOfPosition && isSimilarNode && contextNode.pos !== startPos) {
79277                 var needsIndent = indentLeading && currentSourceFile && !ts.positionsAreOnSameLine(startPos, pos, currentSourceFile);
79278                 if (needsIndent) {
79279                     increaseIndent();
79280                 }
79281                 emitLeadingCommentsOfPosition(startPos);
79282                 if (needsIndent) {
79283                     decreaseIndent();
79284                 }
79285             }
79286             pos = writeTokenText(token, writer, pos);
79287             if (emitTrailingCommentsOfPosition && isSimilarNode && contextNode.end !== pos) {
79288                 emitTrailingCommentsOfPosition(pos, true);
79289             }
79290             return pos;
79291         }
79292         function emitReturnStatement(node) {
79293             emitTokenWithComment(101, node.pos, writeKeyword, node);
79294             emitExpressionWithLeadingSpace(node.expression);
79295             writeTrailingSemicolon();
79296         }
79297         function emitWithStatement(node) {
79298             var openParenPos = emitTokenWithComment(112, node.pos, writeKeyword, node);
79299             writeSpace();
79300             emitTokenWithComment(20, openParenPos, writePunctuation, node);
79301             emitExpression(node.expression);
79302             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
79303             emitEmbeddedStatement(node, node.statement);
79304         }
79305         function emitSwitchStatement(node) {
79306             var openParenPos = emitTokenWithComment(103, node.pos, writeKeyword, node);
79307             writeSpace();
79308             emitTokenWithComment(20, openParenPos, writePunctuation, node);
79309             emitExpression(node.expression);
79310             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
79311             writeSpace();
79312             emit(node.caseBlock);
79313         }
79314         function emitLabeledStatement(node) {
79315             emit(node.label);
79316             emitTokenWithComment(58, node.label.end, writePunctuation, node);
79317             writeSpace();
79318             emit(node.statement);
79319         }
79320         function emitThrowStatement(node) {
79321             emitTokenWithComment(105, node.pos, writeKeyword, node);
79322             emitExpressionWithLeadingSpace(node.expression);
79323             writeTrailingSemicolon();
79324         }
79325         function emitTryStatement(node) {
79326             emitTokenWithComment(107, node.pos, writeKeyword, node);
79327             writeSpace();
79328             emit(node.tryBlock);
79329             if (node.catchClause) {
79330                 writeLineOrSpace(node);
79331                 emit(node.catchClause);
79332             }
79333             if (node.finallyBlock) {
79334                 writeLineOrSpace(node);
79335                 emitTokenWithComment(92, (node.catchClause || node.tryBlock).end, writeKeyword, node);
79336                 writeSpace();
79337                 emit(node.finallyBlock);
79338             }
79339         }
79340         function emitDebuggerStatement(node) {
79341             writeToken(83, node.pos, writeKeyword);
79342             writeTrailingSemicolon();
79343         }
79344         function emitVariableDeclaration(node) {
79345             emit(node.name);
79346             emit(node.exclamationToken);
79347             emitTypeAnnotation(node.type);
79348             emitInitializer(node.initializer, node.type ? node.type.end : node.name.end, node);
79349         }
79350         function emitVariableDeclarationList(node) {
79351             writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var");
79352             writeSpace();
79353             emitList(node, node.declarations, 528);
79354         }
79355         function emitFunctionDeclaration(node) {
79356             emitFunctionDeclarationOrExpression(node);
79357         }
79358         function emitFunctionDeclarationOrExpression(node) {
79359             emitDecorators(node, node.decorators);
79360             emitModifiers(node, node.modifiers);
79361             writeKeyword("function");
79362             emit(node.asteriskToken);
79363             writeSpace();
79364             emitIdentifierName(node.name);
79365             emitSignatureAndBody(node, emitSignatureHead);
79366         }
79367         function emitBlockCallback(_hint, body) {
79368             emitBlockFunctionBody(body);
79369         }
79370         function emitSignatureAndBody(node, emitSignatureHead) {
79371             var body = node.body;
79372             if (body) {
79373                 if (ts.isBlock(body)) {
79374                     var indentedFlag = ts.getEmitFlags(node) & 65536;
79375                     if (indentedFlag) {
79376                         increaseIndent();
79377                     }
79378                     pushNameGenerationScope(node);
79379                     ts.forEach(node.parameters, generateNames);
79380                     generateNames(node.body);
79381                     emitSignatureHead(node);
79382                     if (onEmitNode) {
79383                         onEmitNode(4, body, emitBlockCallback);
79384                     }
79385                     else {
79386                         emitBlockFunctionBody(body);
79387                     }
79388                     popNameGenerationScope(node);
79389                     if (indentedFlag) {
79390                         decreaseIndent();
79391                     }
79392                 }
79393                 else {
79394                     emitSignatureHead(node);
79395                     writeSpace();
79396                     emitExpression(body);
79397                 }
79398             }
79399             else {
79400                 emitSignatureHead(node);
79401                 writeTrailingSemicolon();
79402             }
79403         }
79404         function emitSignatureHead(node) {
79405             emitTypeParameters(node, node.typeParameters);
79406             emitParameters(node, node.parameters);
79407             emitTypeAnnotation(node.type);
79408         }
79409         function shouldEmitBlockFunctionBodyOnSingleLine(body) {
79410             if (ts.getEmitFlags(body) & 1) {
79411                 return true;
79412             }
79413             if (body.multiLine) {
79414                 return false;
79415             }
79416             if (!ts.nodeIsSynthesized(body) && !ts.rangeIsOnSingleLine(body, currentSourceFile)) {
79417                 return false;
79418             }
79419             if (getLeadingLineTerminatorCount(body, body.statements, 2)
79420                 || getClosingLineTerminatorCount(body, body.statements, 2)) {
79421                 return false;
79422             }
79423             var previousStatement;
79424             for (var _a = 0, _b = body.statements; _a < _b.length; _a++) {
79425                 var statement = _b[_a];
79426                 if (getSeparatingLineTerminatorCount(previousStatement, statement, 2) > 0) {
79427                     return false;
79428                 }
79429                 previousStatement = statement;
79430             }
79431             return true;
79432         }
79433         function emitBlockFunctionBody(body) {
79434             writeSpace();
79435             writePunctuation("{");
79436             increaseIndent();
79437             var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body)
79438                 ? emitBlockFunctionBodyOnSingleLine
79439                 : emitBlockFunctionBodyWorker;
79440             if (emitBodyWithDetachedComments) {
79441                 emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody);
79442             }
79443             else {
79444                 emitBlockFunctionBody(body);
79445             }
79446             decreaseIndent();
79447             writeToken(19, body.statements.end, writePunctuation, body);
79448         }
79449         function emitBlockFunctionBodyOnSingleLine(body) {
79450             emitBlockFunctionBodyWorker(body, true);
79451         }
79452         function emitBlockFunctionBodyWorker(body, emitBlockFunctionBodyOnSingleLine) {
79453             var statementOffset = emitPrologueDirectives(body.statements);
79454             var pos = writer.getTextPos();
79455             emitHelpers(body);
79456             if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) {
79457                 decreaseIndent();
79458                 emitList(body, body.statements, 768);
79459                 increaseIndent();
79460             }
79461             else {
79462                 emitList(body, body.statements, 1, statementOffset);
79463             }
79464         }
79465         function emitClassDeclaration(node) {
79466             emitClassDeclarationOrExpression(node);
79467         }
79468         function emitClassDeclarationOrExpression(node) {
79469             ts.forEach(node.members, generateMemberNames);
79470             emitDecorators(node, node.decorators);
79471             emitModifiers(node, node.modifiers);
79472             writeKeyword("class");
79473             if (node.name) {
79474                 writeSpace();
79475                 emitIdentifierName(node.name);
79476             }
79477             var indentedFlag = ts.getEmitFlags(node) & 65536;
79478             if (indentedFlag) {
79479                 increaseIndent();
79480             }
79481             emitTypeParameters(node, node.typeParameters);
79482             emitList(node, node.heritageClauses, 0);
79483             writeSpace();
79484             writePunctuation("{");
79485             emitList(node, node.members, 129);
79486             writePunctuation("}");
79487             if (indentedFlag) {
79488                 decreaseIndent();
79489             }
79490         }
79491         function emitInterfaceDeclaration(node) {
79492             emitDecorators(node, node.decorators);
79493             emitModifiers(node, node.modifiers);
79494             writeKeyword("interface");
79495             writeSpace();
79496             emit(node.name);
79497             emitTypeParameters(node, node.typeParameters);
79498             emitList(node, node.heritageClauses, 512);
79499             writeSpace();
79500             writePunctuation("{");
79501             emitList(node, node.members, 129);
79502             writePunctuation("}");
79503         }
79504         function emitTypeAliasDeclaration(node) {
79505             emitDecorators(node, node.decorators);
79506             emitModifiers(node, node.modifiers);
79507             writeKeyword("type");
79508             writeSpace();
79509             emit(node.name);
79510             emitTypeParameters(node, node.typeParameters);
79511             writeSpace();
79512             writePunctuation("=");
79513             writeSpace();
79514             emit(node.type);
79515             writeTrailingSemicolon();
79516         }
79517         function emitEnumDeclaration(node) {
79518             emitModifiers(node, node.modifiers);
79519             writeKeyword("enum");
79520             writeSpace();
79521             emit(node.name);
79522             writeSpace();
79523             writePunctuation("{");
79524             emitList(node, node.members, 145);
79525             writePunctuation("}");
79526         }
79527         function emitModuleDeclaration(node) {
79528             emitModifiers(node, node.modifiers);
79529             if (~node.flags & 1024) {
79530                 writeKeyword(node.flags & 16 ? "namespace" : "module");
79531                 writeSpace();
79532             }
79533             emit(node.name);
79534             var body = node.body;
79535             if (!body)
79536                 return writeTrailingSemicolon();
79537             while (body.kind === 249) {
79538                 writePunctuation(".");
79539                 emit(body.name);
79540                 body = body.body;
79541             }
79542             writeSpace();
79543             emit(body);
79544         }
79545         function emitModuleBlock(node) {
79546             pushNameGenerationScope(node);
79547             ts.forEach(node.statements, generateNames);
79548             emitBlockStatements(node, isEmptyBlock(node));
79549             popNameGenerationScope(node);
79550         }
79551         function emitCaseBlock(node) {
79552             emitTokenWithComment(18, node.pos, writePunctuation, node);
79553             emitList(node, node.clauses, 129);
79554             emitTokenWithComment(19, node.clauses.end, writePunctuation, node, true);
79555         }
79556         function emitImportEqualsDeclaration(node) {
79557             emitModifiers(node, node.modifiers);
79558             emitTokenWithComment(96, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node);
79559             writeSpace();
79560             emit(node.name);
79561             writeSpace();
79562             emitTokenWithComment(62, node.name.end, writePunctuation, node);
79563             writeSpace();
79564             emitModuleReference(node.moduleReference);
79565             writeTrailingSemicolon();
79566         }
79567         function emitModuleReference(node) {
79568             if (node.kind === 75) {
79569                 emitExpression(node);
79570             }
79571             else {
79572                 emit(node);
79573             }
79574         }
79575         function emitImportDeclaration(node) {
79576             emitModifiers(node, node.modifiers);
79577             emitTokenWithComment(96, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node);
79578             writeSpace();
79579             if (node.importClause) {
79580                 emit(node.importClause);
79581                 writeSpace();
79582                 emitTokenWithComment(149, node.importClause.end, writeKeyword, node);
79583                 writeSpace();
79584             }
79585             emitExpression(node.moduleSpecifier);
79586             writeTrailingSemicolon();
79587         }
79588         function emitImportClause(node) {
79589             if (node.isTypeOnly) {
79590                 emitTokenWithComment(145, node.pos, writeKeyword, node);
79591                 writeSpace();
79592             }
79593             emit(node.name);
79594             if (node.name && node.namedBindings) {
79595                 emitTokenWithComment(27, node.name.end, writePunctuation, node);
79596                 writeSpace();
79597             }
79598             emit(node.namedBindings);
79599         }
79600         function emitNamespaceImport(node) {
79601             var asPos = emitTokenWithComment(41, node.pos, writePunctuation, node);
79602             writeSpace();
79603             emitTokenWithComment(123, asPos, writeKeyword, node);
79604             writeSpace();
79605             emit(node.name);
79606         }
79607         function emitNamedImports(node) {
79608             emitNamedImportsOrExports(node);
79609         }
79610         function emitImportSpecifier(node) {
79611             emitImportOrExportSpecifier(node);
79612         }
79613         function emitExportAssignment(node) {
79614             var nextPos = emitTokenWithComment(89, node.pos, writeKeyword, node);
79615             writeSpace();
79616             if (node.isExportEquals) {
79617                 emitTokenWithComment(62, nextPos, writeOperator, node);
79618             }
79619             else {
79620                 emitTokenWithComment(84, nextPos, writeKeyword, node);
79621             }
79622             writeSpace();
79623             emitExpression(node.expression);
79624             writeTrailingSemicolon();
79625         }
79626         function emitExportDeclaration(node) {
79627             var nextPos = emitTokenWithComment(89, node.pos, writeKeyword, node);
79628             writeSpace();
79629             if (node.isTypeOnly) {
79630                 nextPos = emitTokenWithComment(145, nextPos, writeKeyword, node);
79631                 writeSpace();
79632             }
79633             if (node.exportClause) {
79634                 emit(node.exportClause);
79635             }
79636             else {
79637                 nextPos = emitTokenWithComment(41, nextPos, writePunctuation, node);
79638             }
79639             if (node.moduleSpecifier) {
79640                 writeSpace();
79641                 var fromPos = node.exportClause ? node.exportClause.end : nextPos;
79642                 emitTokenWithComment(149, fromPos, writeKeyword, node);
79643                 writeSpace();
79644                 emitExpression(node.moduleSpecifier);
79645             }
79646             writeTrailingSemicolon();
79647         }
79648         function emitNamespaceExportDeclaration(node) {
79649             var nextPos = emitTokenWithComment(89, node.pos, writeKeyword, node);
79650             writeSpace();
79651             nextPos = emitTokenWithComment(123, nextPos, writeKeyword, node);
79652             writeSpace();
79653             nextPos = emitTokenWithComment(136, nextPos, writeKeyword, node);
79654             writeSpace();
79655             emit(node.name);
79656             writeTrailingSemicolon();
79657         }
79658         function emitNamespaceExport(node) {
79659             var asPos = emitTokenWithComment(41, node.pos, writePunctuation, node);
79660             writeSpace();
79661             emitTokenWithComment(123, asPos, writeKeyword, node);
79662             writeSpace();
79663             emit(node.name);
79664         }
79665         function emitNamedExports(node) {
79666             emitNamedImportsOrExports(node);
79667         }
79668         function emitExportSpecifier(node) {
79669             emitImportOrExportSpecifier(node);
79670         }
79671         function emitNamedImportsOrExports(node) {
79672             writePunctuation("{");
79673             emitList(node, node.elements, 525136);
79674             writePunctuation("}");
79675         }
79676         function emitImportOrExportSpecifier(node) {
79677             if (node.propertyName) {
79678                 emit(node.propertyName);
79679                 writeSpace();
79680                 emitTokenWithComment(123, node.propertyName.end, writeKeyword, node);
79681                 writeSpace();
79682             }
79683             emit(node.name);
79684         }
79685         function emitExternalModuleReference(node) {
79686             writeKeyword("require");
79687             writePunctuation("(");
79688             emitExpression(node.expression);
79689             writePunctuation(")");
79690         }
79691         function emitJsxElement(node) {
79692             emit(node.openingElement);
79693             emitList(node, node.children, 262144);
79694             emit(node.closingElement);
79695         }
79696         function emitJsxSelfClosingElement(node) {
79697             writePunctuation("<");
79698             emitJsxTagName(node.tagName);
79699             emitTypeArguments(node, node.typeArguments);
79700             writeSpace();
79701             emit(node.attributes);
79702             writePunctuation("/>");
79703         }
79704         function emitJsxFragment(node) {
79705             emit(node.openingFragment);
79706             emitList(node, node.children, 262144);
79707             emit(node.closingFragment);
79708         }
79709         function emitJsxOpeningElementOrFragment(node) {
79710             writePunctuation("<");
79711             if (ts.isJsxOpeningElement(node)) {
79712                 var indented = writeLineSeparatorsAndIndentBefore(node.tagName, node);
79713                 emitJsxTagName(node.tagName);
79714                 emitTypeArguments(node, node.typeArguments);
79715                 if (node.attributes.properties && node.attributes.properties.length > 0) {
79716                     writeSpace();
79717                 }
79718                 emit(node.attributes);
79719                 writeLineSeparatorsAfter(node.attributes, node);
79720                 decreaseIndentIf(indented);
79721             }
79722             writePunctuation(">");
79723         }
79724         function emitJsxText(node) {
79725             writer.writeLiteral(node.text);
79726         }
79727         function emitJsxClosingElementOrFragment(node) {
79728             writePunctuation("</");
79729             if (ts.isJsxClosingElement(node)) {
79730                 emitJsxTagName(node.tagName);
79731             }
79732             writePunctuation(">");
79733         }
79734         function emitJsxAttributes(node) {
79735             emitList(node, node.properties, 262656);
79736         }
79737         function emitJsxAttribute(node) {
79738             emit(node.name);
79739             emitNodeWithPrefix("=", writePunctuation, node.initializer, emitJsxAttributeValue);
79740         }
79741         function emitJsxSpreadAttribute(node) {
79742             writePunctuation("{...");
79743             emitExpression(node.expression);
79744             writePunctuation("}");
79745         }
79746         function emitJsxExpression(node) {
79747             if (node.expression) {
79748                 writePunctuation("{");
79749                 emit(node.dotDotDotToken);
79750                 emitExpression(node.expression);
79751                 writePunctuation("}");
79752             }
79753         }
79754         function emitJsxTagName(node) {
79755             if (node.kind === 75) {
79756                 emitExpression(node);
79757             }
79758             else {
79759                 emit(node);
79760             }
79761         }
79762         function emitCaseClause(node) {
79763             emitTokenWithComment(78, node.pos, writeKeyword, node);
79764             writeSpace();
79765             emitExpression(node.expression);
79766             emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end);
79767         }
79768         function emitDefaultClause(node) {
79769             var pos = emitTokenWithComment(84, node.pos, writeKeyword, node);
79770             emitCaseOrDefaultClauseRest(node, node.statements, pos);
79771         }
79772         function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) {
79773             var emitAsSingleStatement = statements.length === 1 &&
79774                 (ts.nodeIsSynthesized(parentNode) ||
79775                     ts.nodeIsSynthesized(statements[0]) ||
79776                     ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile));
79777             var format = 163969;
79778             if (emitAsSingleStatement) {
79779                 writeToken(58, colonPos, writePunctuation, parentNode);
79780                 writeSpace();
79781                 format &= ~(1 | 128);
79782             }
79783             else {
79784                 emitTokenWithComment(58, colonPos, writePunctuation, parentNode);
79785             }
79786             emitList(parentNode, statements, format);
79787         }
79788         function emitHeritageClause(node) {
79789             writeSpace();
79790             writeTokenText(node.token, writeKeyword);
79791             writeSpace();
79792             emitList(node, node.types, 528);
79793         }
79794         function emitCatchClause(node) {
79795             var openParenPos = emitTokenWithComment(79, node.pos, writeKeyword, node);
79796             writeSpace();
79797             if (node.variableDeclaration) {
79798                 emitTokenWithComment(20, openParenPos, writePunctuation, node);
79799                 emit(node.variableDeclaration);
79800                 emitTokenWithComment(21, node.variableDeclaration.end, writePunctuation, node);
79801                 writeSpace();
79802             }
79803             emit(node.block);
79804         }
79805         function emitPropertyAssignment(node) {
79806             emit(node.name);
79807             writePunctuation(":");
79808             writeSpace();
79809             var initializer = node.initializer;
79810             if (emitTrailingCommentsOfPosition && (ts.getEmitFlags(initializer) & 512) === 0) {
79811                 var commentRange = ts.getCommentRange(initializer);
79812                 emitTrailingCommentsOfPosition(commentRange.pos);
79813             }
79814             emitExpression(initializer);
79815         }
79816         function emitShorthandPropertyAssignment(node) {
79817             emit(node.name);
79818             if (node.objectAssignmentInitializer) {
79819                 writeSpace();
79820                 writePunctuation("=");
79821                 writeSpace();
79822                 emitExpression(node.objectAssignmentInitializer);
79823             }
79824         }
79825         function emitSpreadAssignment(node) {
79826             if (node.expression) {
79827                 emitTokenWithComment(25, node.pos, writePunctuation, node);
79828                 emitExpression(node.expression);
79829             }
79830         }
79831         function emitEnumMember(node) {
79832             emit(node.name);
79833             emitInitializer(node.initializer, node.name.end, node);
79834         }
79835         function emitJSDoc(node) {
79836             write("/**");
79837             if (node.comment) {
79838                 var lines = node.comment.split(/\r\n?|\n/g);
79839                 for (var _a = 0, lines_2 = lines; _a < lines_2.length; _a++) {
79840                     var line = lines_2[_a];
79841                     writeLine();
79842                     writeSpace();
79843                     writePunctuation("*");
79844                     writeSpace();
79845                     write(line);
79846                 }
79847             }
79848             if (node.tags) {
79849                 if (node.tags.length === 1 && node.tags[0].kind === 320 && !node.comment) {
79850                     writeSpace();
79851                     emit(node.tags[0]);
79852                 }
79853                 else {
79854                     emitList(node, node.tags, 33);
79855                 }
79856             }
79857             writeSpace();
79858             write("*/");
79859         }
79860         function emitJSDocSimpleTypedTag(tag) {
79861             emitJSDocTagName(tag.tagName);
79862             emitJSDocTypeExpression(tag.typeExpression);
79863             emitJSDocComment(tag.comment);
79864         }
79865         function emitJSDocHeritageTag(tag) {
79866             emitJSDocTagName(tag.tagName);
79867             writeSpace();
79868             writePunctuation("{");
79869             emit(tag.class);
79870             writePunctuation("}");
79871             emitJSDocComment(tag.comment);
79872         }
79873         function emitJSDocTemplateTag(tag) {
79874             emitJSDocTagName(tag.tagName);
79875             emitJSDocTypeExpression(tag.constraint);
79876             writeSpace();
79877             emitList(tag, tag.typeParameters, 528);
79878             emitJSDocComment(tag.comment);
79879         }
79880         function emitJSDocTypedefTag(tag) {
79881             emitJSDocTagName(tag.tagName);
79882             if (tag.typeExpression) {
79883                 if (tag.typeExpression.kind === 294) {
79884                     emitJSDocTypeExpression(tag.typeExpression);
79885                 }
79886                 else {
79887                     writeSpace();
79888                     writePunctuation("{");
79889                     write("Object");
79890                     if (tag.typeExpression.isArrayType) {
79891                         writePunctuation("[");
79892                         writePunctuation("]");
79893                     }
79894                     writePunctuation("}");
79895                 }
79896             }
79897             if (tag.fullName) {
79898                 writeSpace();
79899                 emit(tag.fullName);
79900             }
79901             emitJSDocComment(tag.comment);
79902             if (tag.typeExpression && tag.typeExpression.kind === 304) {
79903                 emitJSDocTypeLiteral(tag.typeExpression);
79904             }
79905         }
79906         function emitJSDocCallbackTag(tag) {
79907             emitJSDocTagName(tag.tagName);
79908             if (tag.name) {
79909                 writeSpace();
79910                 emit(tag.name);
79911             }
79912             emitJSDocComment(tag.comment);
79913             emitJSDocSignature(tag.typeExpression);
79914         }
79915         function emitJSDocSimpleTag(tag) {
79916             emitJSDocTagName(tag.tagName);
79917             emitJSDocComment(tag.comment);
79918         }
79919         function emitJSDocTypeLiteral(lit) {
79920             emitList(lit, ts.createNodeArray(lit.jsDocPropertyTags), 33);
79921         }
79922         function emitJSDocSignature(sig) {
79923             if (sig.typeParameters) {
79924                 emitList(sig, ts.createNodeArray(sig.typeParameters), 33);
79925             }
79926             if (sig.parameters) {
79927                 emitList(sig, ts.createNodeArray(sig.parameters), 33);
79928             }
79929             if (sig.type) {
79930                 writeLine();
79931                 writeSpace();
79932                 writePunctuation("*");
79933                 writeSpace();
79934                 emit(sig.type);
79935             }
79936         }
79937         function emitJSDocPropertyLikeTag(param) {
79938             emitJSDocTagName(param.tagName);
79939             emitJSDocTypeExpression(param.typeExpression);
79940             writeSpace();
79941             if (param.isBracketed) {
79942                 writePunctuation("[");
79943             }
79944             emit(param.name);
79945             if (param.isBracketed) {
79946                 writePunctuation("]");
79947             }
79948             emitJSDocComment(param.comment);
79949         }
79950         function emitJSDocTagName(tagName) {
79951             writePunctuation("@");
79952             emit(tagName);
79953         }
79954         function emitJSDocComment(comment) {
79955             if (comment) {
79956                 writeSpace();
79957                 write(comment);
79958             }
79959         }
79960         function emitJSDocTypeExpression(typeExpression) {
79961             if (typeExpression) {
79962                 writeSpace();
79963                 writePunctuation("{");
79964                 emit(typeExpression.type);
79965                 writePunctuation("}");
79966             }
79967         }
79968         function emitSourceFile(node) {
79969             writeLine();
79970             var statements = node.statements;
79971             if (emitBodyWithDetachedComments) {
79972                 var shouldEmitDetachedComment = statements.length === 0 ||
79973                     !ts.isPrologueDirective(statements[0]) ||
79974                     ts.nodeIsSynthesized(statements[0]);
79975                 if (shouldEmitDetachedComment) {
79976                     emitBodyWithDetachedComments(node, statements, emitSourceFileWorker);
79977                     return;
79978                 }
79979             }
79980             emitSourceFileWorker(node);
79981         }
79982         function emitSyntheticTripleSlashReferencesIfNeeded(node) {
79983             emitTripleSlashDirectives(!!node.hasNoDefaultLib, node.syntheticFileReferences || [], node.syntheticTypeReferences || [], node.syntheticLibReferences || []);
79984             for (var _a = 0, _b = node.prepends; _a < _b.length; _a++) {
79985                 var prepend = _b[_a];
79986                 if (ts.isUnparsedSource(prepend) && prepend.syntheticReferences) {
79987                     for (var _c = 0, _d = prepend.syntheticReferences; _c < _d.length; _c++) {
79988                         var ref = _d[_c];
79989                         emit(ref);
79990                         writeLine();
79991                     }
79992                 }
79993             }
79994         }
79995         function emitTripleSlashDirectivesIfNeeded(node) {
79996             if (node.isDeclarationFile)
79997                 emitTripleSlashDirectives(node.hasNoDefaultLib, node.referencedFiles, node.typeReferenceDirectives, node.libReferenceDirectives);
79998         }
79999         function emitTripleSlashDirectives(hasNoDefaultLib, files, types, libs) {
80000             if (hasNoDefaultLib) {
80001                 var pos = writer.getTextPos();
80002                 writeComment("/// <reference no-default-lib=\"true\"/>");
80003                 if (bundleFileInfo)
80004                     bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "no-default-lib" });
80005                 writeLine();
80006             }
80007             if (currentSourceFile && currentSourceFile.moduleName) {
80008                 writeComment("/// <amd-module name=\"" + currentSourceFile.moduleName + "\" />");
80009                 writeLine();
80010             }
80011             if (currentSourceFile && currentSourceFile.amdDependencies) {
80012                 for (var _a = 0, _b = currentSourceFile.amdDependencies; _a < _b.length; _a++) {
80013                     var dep = _b[_a];
80014                     if (dep.name) {
80015                         writeComment("/// <amd-dependency name=\"" + dep.name + "\" path=\"" + dep.path + "\" />");
80016                     }
80017                     else {
80018                         writeComment("/// <amd-dependency path=\"" + dep.path + "\" />");
80019                     }
80020                     writeLine();
80021                 }
80022             }
80023             for (var _c = 0, files_1 = files; _c < files_1.length; _c++) {
80024                 var directive = files_1[_c];
80025                 var pos = writer.getTextPos();
80026                 writeComment("/// <reference path=\"" + directive.fileName + "\" />");
80027                 if (bundleFileInfo)
80028                     bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference", data: directive.fileName });
80029                 writeLine();
80030             }
80031             for (var _d = 0, types_22 = types; _d < types_22.length; _d++) {
80032                 var directive = types_22[_d];
80033                 var pos = writer.getTextPos();
80034                 writeComment("/// <reference types=\"" + directive.fileName + "\" />");
80035                 if (bundleFileInfo)
80036                     bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "type", data: directive.fileName });
80037                 writeLine();
80038             }
80039             for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) {
80040                 var directive = libs_1[_e];
80041                 var pos = writer.getTextPos();
80042                 writeComment("/// <reference lib=\"" + directive.fileName + "\" />");
80043                 if (bundleFileInfo)
80044                     bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib", data: directive.fileName });
80045                 writeLine();
80046             }
80047         }
80048         function emitSourceFileWorker(node) {
80049             var statements = node.statements;
80050             pushNameGenerationScope(node);
80051             ts.forEach(node.statements, generateNames);
80052             emitHelpers(node);
80053             var index = ts.findIndex(statements, function (statement) { return !ts.isPrologueDirective(statement); });
80054             emitTripleSlashDirectivesIfNeeded(node);
80055             emitList(node, statements, 1, index === -1 ? statements.length : index);
80056             popNameGenerationScope(node);
80057         }
80058         function emitPartiallyEmittedExpression(node) {
80059             emitExpression(node.expression);
80060         }
80061         function emitCommaList(node) {
80062             emitExpressionList(node, node.elements, 528);
80063         }
80064         function emitPrologueDirectives(statements, sourceFile, seenPrologueDirectives, recordBundleFileSection) {
80065             var needsToSetSourceFile = !!sourceFile;
80066             for (var i = 0; i < statements.length; i++) {
80067                 var statement = statements[i];
80068                 if (ts.isPrologueDirective(statement)) {
80069                     var shouldEmitPrologueDirective = seenPrologueDirectives ? !seenPrologueDirectives.has(statement.expression.text) : true;
80070                     if (shouldEmitPrologueDirective) {
80071                         if (needsToSetSourceFile) {
80072                             needsToSetSourceFile = false;
80073                             setSourceFile(sourceFile);
80074                         }
80075                         writeLine();
80076                         var pos = writer.getTextPos();
80077                         emit(statement);
80078                         if (recordBundleFileSection && bundleFileInfo)
80079                             bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue", data: statement.expression.text });
80080                         if (seenPrologueDirectives) {
80081                             seenPrologueDirectives.set(statement.expression.text, true);
80082                         }
80083                     }
80084                 }
80085                 else {
80086                     return i;
80087                 }
80088             }
80089             return statements.length;
80090         }
80091         function emitUnparsedPrologues(prologues, seenPrologueDirectives) {
80092             for (var _a = 0, prologues_1 = prologues; _a < prologues_1.length; _a++) {
80093                 var prologue = prologues_1[_a];
80094                 if (!seenPrologueDirectives.has(prologue.data)) {
80095                     writeLine();
80096                     var pos = writer.getTextPos();
80097                     emit(prologue);
80098                     if (bundleFileInfo)
80099                         bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue", data: prologue.data });
80100                     if (seenPrologueDirectives) {
80101                         seenPrologueDirectives.set(prologue.data, true);
80102                     }
80103                 }
80104             }
80105         }
80106         function emitPrologueDirectivesIfNeeded(sourceFileOrBundle) {
80107             if (ts.isSourceFile(sourceFileOrBundle)) {
80108                 emitPrologueDirectives(sourceFileOrBundle.statements, sourceFileOrBundle);
80109             }
80110             else {
80111                 var seenPrologueDirectives = ts.createMap();
80112                 for (var _a = 0, _b = sourceFileOrBundle.prepends; _a < _b.length; _a++) {
80113                     var prepend = _b[_a];
80114                     emitUnparsedPrologues(prepend.prologues, seenPrologueDirectives);
80115                 }
80116                 for (var _c = 0, _d = sourceFileOrBundle.sourceFiles; _c < _d.length; _c++) {
80117                     var sourceFile = _d[_c];
80118                     emitPrologueDirectives(sourceFile.statements, sourceFile, seenPrologueDirectives, true);
80119                 }
80120                 setSourceFile(undefined);
80121             }
80122         }
80123         function getPrologueDirectivesFromBundledSourceFiles(bundle) {
80124             var seenPrologueDirectives = ts.createMap();
80125             var prologues;
80126             for (var index = 0; index < bundle.sourceFiles.length; index++) {
80127                 var sourceFile = bundle.sourceFiles[index];
80128                 var directives = void 0;
80129                 var end = 0;
80130                 for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) {
80131                     var statement = _b[_a];
80132                     if (!ts.isPrologueDirective(statement))
80133                         break;
80134                     if (seenPrologueDirectives.has(statement.expression.text))
80135                         continue;
80136                     seenPrologueDirectives.set(statement.expression.text, true);
80137                     (directives || (directives = [])).push({
80138                         pos: statement.pos,
80139                         end: statement.end,
80140                         expression: {
80141                             pos: statement.expression.pos,
80142                             end: statement.expression.end,
80143                             text: statement.expression.text
80144                         }
80145                     });
80146                     end = end < statement.end ? statement.end : end;
80147                 }
80148                 if (directives)
80149                     (prologues || (prologues = [])).push({ file: index, text: sourceFile.text.substring(0, end), directives: directives });
80150             }
80151             return prologues;
80152         }
80153         function emitShebangIfNeeded(sourceFileOrBundle) {
80154             if (ts.isSourceFile(sourceFileOrBundle) || ts.isUnparsedSource(sourceFileOrBundle)) {
80155                 var shebang = ts.getShebang(sourceFileOrBundle.text);
80156                 if (shebang) {
80157                     writeComment(shebang);
80158                     writeLine();
80159                     return true;
80160                 }
80161             }
80162             else {
80163                 for (var _a = 0, _b = sourceFileOrBundle.prepends; _a < _b.length; _a++) {
80164                     var prepend = _b[_a];
80165                     ts.Debug.assertNode(prepend, ts.isUnparsedSource);
80166                     if (emitShebangIfNeeded(prepend)) {
80167                         return true;
80168                     }
80169                 }
80170                 for (var _c = 0, _d = sourceFileOrBundle.sourceFiles; _c < _d.length; _c++) {
80171                     var sourceFile = _d[_c];
80172                     if (emitShebangIfNeeded(sourceFile)) {
80173                         return true;
80174                     }
80175                 }
80176             }
80177         }
80178         function emitNodeWithWriter(node, writer) {
80179             if (!node)
80180                 return;
80181             var savedWrite = write;
80182             write = writer;
80183             emit(node);
80184             write = savedWrite;
80185         }
80186         function emitModifiers(node, modifiers) {
80187             if (modifiers && modifiers.length) {
80188                 emitList(node, modifiers, 262656);
80189                 writeSpace();
80190             }
80191         }
80192         function emitTypeAnnotation(node) {
80193             if (node) {
80194                 writePunctuation(":");
80195                 writeSpace();
80196                 emit(node);
80197             }
80198         }
80199         function emitInitializer(node, equalCommentStartPos, container) {
80200             if (node) {
80201                 writeSpace();
80202                 emitTokenWithComment(62, equalCommentStartPos, writeOperator, container);
80203                 writeSpace();
80204                 emitExpression(node);
80205             }
80206         }
80207         function emitNodeWithPrefix(prefix, prefixWriter, node, emit) {
80208             if (node) {
80209                 prefixWriter(prefix);
80210                 emit(node);
80211             }
80212         }
80213         function emitWithLeadingSpace(node) {
80214             if (node) {
80215                 writeSpace();
80216                 emit(node);
80217             }
80218         }
80219         function emitExpressionWithLeadingSpace(node) {
80220             if (node) {
80221                 writeSpace();
80222                 emitExpression(node);
80223             }
80224         }
80225         function emitWithTrailingSpace(node) {
80226             if (node) {
80227                 emit(node);
80228                 writeSpace();
80229             }
80230         }
80231         function emitEmbeddedStatement(parent, node) {
80232             if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1) {
80233                 writeSpace();
80234                 emit(node);
80235             }
80236             else {
80237                 writeLine();
80238                 increaseIndent();
80239                 if (ts.isEmptyStatement(node)) {
80240                     pipelineEmit(5, node);
80241                 }
80242                 else {
80243                     emit(node);
80244                 }
80245                 decreaseIndent();
80246             }
80247         }
80248         function emitDecorators(parentNode, decorators) {
80249             emitList(parentNode, decorators, 2146305);
80250         }
80251         function emitTypeArguments(parentNode, typeArguments) {
80252             emitList(parentNode, typeArguments, 53776);
80253         }
80254         function emitTypeParameters(parentNode, typeParameters) {
80255             if (ts.isFunctionLike(parentNode) && parentNode.typeArguments) {
80256                 return emitTypeArguments(parentNode, parentNode.typeArguments);
80257             }
80258             emitList(parentNode, typeParameters, 53776);
80259         }
80260         function emitParameters(parentNode, parameters) {
80261             emitList(parentNode, parameters, 2576);
80262         }
80263         function canEmitSimpleArrowHead(parentNode, parameters) {
80264             var parameter = ts.singleOrUndefined(parameters);
80265             return parameter
80266                 && parameter.pos === parentNode.pos
80267                 && ts.isArrowFunction(parentNode)
80268                 && !parentNode.type
80269                 && !ts.some(parentNode.decorators)
80270                 && !ts.some(parentNode.modifiers)
80271                 && !ts.some(parentNode.typeParameters)
80272                 && !ts.some(parameter.decorators)
80273                 && !ts.some(parameter.modifiers)
80274                 && !parameter.dotDotDotToken
80275                 && !parameter.questionToken
80276                 && !parameter.type
80277                 && !parameter.initializer
80278                 && ts.isIdentifier(parameter.name);
80279         }
80280         function emitParametersForArrow(parentNode, parameters) {
80281             if (canEmitSimpleArrowHead(parentNode, parameters)) {
80282                 emitList(parentNode, parameters, 2576 & ~2048);
80283             }
80284             else {
80285                 emitParameters(parentNode, parameters);
80286             }
80287         }
80288         function emitParametersForIndexSignature(parentNode, parameters) {
80289             emitList(parentNode, parameters, 8848);
80290         }
80291         function emitList(parentNode, children, format, start, count) {
80292             emitNodeList(emit, parentNode, children, format, start, count);
80293         }
80294         function emitExpressionList(parentNode, children, format, start, count) {
80295             emitNodeList(emitExpression, parentNode, children, format, start, count);
80296         }
80297         function writeDelimiter(format) {
80298             switch (format & 60) {
80299                 case 0:
80300                     break;
80301                 case 16:
80302                     writePunctuation(",");
80303                     break;
80304                 case 4:
80305                     writeSpace();
80306                     writePunctuation("|");
80307                     break;
80308                 case 32:
80309                     writeSpace();
80310                     writePunctuation("*");
80311                     writeSpace();
80312                     break;
80313                 case 8:
80314                     writeSpace();
80315                     writePunctuation("&");
80316                     break;
80317             }
80318         }
80319         function emitNodeList(emit, parentNode, children, format, start, count) {
80320             if (start === void 0) { start = 0; }
80321             if (count === void 0) { count = children ? children.length - start : 0; }
80322             var isUndefined = children === undefined;
80323             if (isUndefined && format & 16384) {
80324                 return;
80325             }
80326             var isEmpty = children === undefined || start >= children.length || count === 0;
80327             if (isEmpty && format & 32768) {
80328                 if (onBeforeEmitNodeArray) {
80329                     onBeforeEmitNodeArray(children);
80330                 }
80331                 if (onAfterEmitNodeArray) {
80332                     onAfterEmitNodeArray(children);
80333                 }
80334                 return;
80335             }
80336             if (format & 15360) {
80337                 writePunctuation(getOpeningBracket(format));
80338                 if (isEmpty && !isUndefined) {
80339                     emitTrailingCommentsOfPosition(children.pos, true);
80340                 }
80341             }
80342             if (onBeforeEmitNodeArray) {
80343                 onBeforeEmitNodeArray(children);
80344             }
80345             if (isEmpty) {
80346                 if (format & 1 && !(preserveSourceNewlines && ts.rangeIsOnSingleLine(parentNode, currentSourceFile))) {
80347                     writeLine();
80348                 }
80349                 else if (format & 256 && !(format & 524288)) {
80350                     writeSpace();
80351                 }
80352             }
80353             else {
80354                 var mayEmitInterveningComments = (format & 262144) === 0;
80355                 var shouldEmitInterveningComments = mayEmitInterveningComments;
80356                 var leadingLineTerminatorCount = getLeadingLineTerminatorCount(parentNode, children, format);
80357                 if (leadingLineTerminatorCount) {
80358                     writeLine(leadingLineTerminatorCount);
80359                     shouldEmitInterveningComments = false;
80360                 }
80361                 else if (format & 256) {
80362                     writeSpace();
80363                 }
80364                 if (format & 128) {
80365                     increaseIndent();
80366                 }
80367                 var previousSibling = void 0;
80368                 var previousSourceFileTextKind = void 0;
80369                 var shouldDecreaseIndentAfterEmit = false;
80370                 for (var i = 0; i < count; i++) {
80371                     var child = children[start + i];
80372                     if (format & 32) {
80373                         writeLine();
80374                         writeDelimiter(format);
80375                     }
80376                     else if (previousSibling) {
80377                         if (format & 60 && previousSibling.end !== parentNode.end) {
80378                             emitLeadingCommentsOfPosition(previousSibling.end);
80379                         }
80380                         writeDelimiter(format);
80381                         recordBundleFileInternalSectionEnd(previousSourceFileTextKind);
80382                         var separatingLineTerminatorCount = getSeparatingLineTerminatorCount(previousSibling, child, format);
80383                         if (separatingLineTerminatorCount > 0) {
80384                             if ((format & (3 | 128)) === 0) {
80385                                 increaseIndent();
80386                                 shouldDecreaseIndentAfterEmit = true;
80387                             }
80388                             writeLine(separatingLineTerminatorCount);
80389                             shouldEmitInterveningComments = false;
80390                         }
80391                         else if (previousSibling && format & 512) {
80392                             writeSpace();
80393                         }
80394                     }
80395                     previousSourceFileTextKind = recordBundleFileInternalSectionStart(child);
80396                     if (shouldEmitInterveningComments) {
80397                         if (emitTrailingCommentsOfPosition) {
80398                             var commentRange = ts.getCommentRange(child);
80399                             emitTrailingCommentsOfPosition(commentRange.pos);
80400                         }
80401                     }
80402                     else {
80403                         shouldEmitInterveningComments = mayEmitInterveningComments;
80404                     }
80405                     emit(child);
80406                     if (shouldDecreaseIndentAfterEmit) {
80407                         decreaseIndent();
80408                         shouldDecreaseIndentAfterEmit = false;
80409                     }
80410                     previousSibling = child;
80411                 }
80412                 var hasTrailingComma = (format & 64) && children.hasTrailingComma;
80413                 if (format & 16 && hasTrailingComma) {
80414                     writePunctuation(",");
80415                 }
80416                 if (previousSibling && format & 60 && previousSibling.end !== parentNode.end && !(ts.getEmitFlags(previousSibling) & 1024)) {
80417                     emitLeadingCommentsOfPosition(previousSibling.end);
80418                 }
80419                 if (format & 128) {
80420                     decreaseIndent();
80421                 }
80422                 recordBundleFileInternalSectionEnd(previousSourceFileTextKind);
80423                 var closingLineTerminatorCount = getClosingLineTerminatorCount(parentNode, children, format);
80424                 if (closingLineTerminatorCount) {
80425                     writeLine(closingLineTerminatorCount);
80426                 }
80427                 else if (format & (2097152 | 256)) {
80428                     writeSpace();
80429                 }
80430             }
80431             if (onAfterEmitNodeArray) {
80432                 onAfterEmitNodeArray(children);
80433             }
80434             if (format & 15360) {
80435                 if (isEmpty && !isUndefined) {
80436                     emitLeadingCommentsOfPosition(children.end);
80437                 }
80438                 writePunctuation(getClosingBracket(format));
80439             }
80440         }
80441         function writeLiteral(s) {
80442             writer.writeLiteral(s);
80443         }
80444         function writeStringLiteral(s) {
80445             writer.writeStringLiteral(s);
80446         }
80447         function writeBase(s) {
80448             writer.write(s);
80449         }
80450         function writeSymbol(s, sym) {
80451             writer.writeSymbol(s, sym);
80452         }
80453         function writePunctuation(s) {
80454             writer.writePunctuation(s);
80455         }
80456         function writeTrailingSemicolon() {
80457             writer.writeTrailingSemicolon(";");
80458         }
80459         function writeKeyword(s) {
80460             writer.writeKeyword(s);
80461         }
80462         function writeOperator(s) {
80463             writer.writeOperator(s);
80464         }
80465         function writeParameter(s) {
80466             writer.writeParameter(s);
80467         }
80468         function writeComment(s) {
80469             writer.writeComment(s);
80470         }
80471         function writeSpace() {
80472             writer.writeSpace(" ");
80473         }
80474         function writeProperty(s) {
80475             writer.writeProperty(s);
80476         }
80477         function writeLine(count) {
80478             if (count === void 0) { count = 1; }
80479             for (var i = 0; i < count; i++) {
80480                 writer.writeLine(i > 0);
80481             }
80482         }
80483         function increaseIndent() {
80484             writer.increaseIndent();
80485         }
80486         function decreaseIndent() {
80487             writer.decreaseIndent();
80488         }
80489         function writeToken(token, pos, writer, contextNode) {
80490             return !sourceMapsDisabled
80491                 ? emitTokenWithSourceMap(contextNode, token, writer, pos, writeTokenText)
80492                 : writeTokenText(token, writer, pos);
80493         }
80494         function writeTokenNode(node, writer) {
80495             if (onBeforeEmitToken) {
80496                 onBeforeEmitToken(node);
80497             }
80498             writer(ts.tokenToString(node.kind));
80499             if (onAfterEmitToken) {
80500                 onAfterEmitToken(node);
80501             }
80502         }
80503         function writeTokenText(token, writer, pos) {
80504             var tokenString = ts.tokenToString(token);
80505             writer(tokenString);
80506             return pos < 0 ? pos : pos + tokenString.length;
80507         }
80508         function writeLineOrSpace(node) {
80509             if (ts.getEmitFlags(node) & 1) {
80510                 writeSpace();
80511             }
80512             else {
80513                 writeLine();
80514             }
80515         }
80516         function writeLines(text) {
80517             var lines = text.split(/\r\n?|\n/g);
80518             var indentation = ts.guessIndentation(lines);
80519             for (var _a = 0, lines_3 = lines; _a < lines_3.length; _a++) {
80520                 var lineText = lines_3[_a];
80521                 var line = indentation ? lineText.slice(indentation) : lineText;
80522                 if (line.length) {
80523                     writeLine();
80524                     write(line);
80525                 }
80526             }
80527         }
80528         function writeLinesAndIndent(lineCount, writeSpaceIfNotIndenting) {
80529             if (lineCount) {
80530                 increaseIndent();
80531                 writeLine(lineCount);
80532             }
80533             else if (writeSpaceIfNotIndenting) {
80534                 writeSpace();
80535             }
80536         }
80537         function decreaseIndentIf(value1, value2) {
80538             if (value1) {
80539                 decreaseIndent();
80540             }
80541             if (value2) {
80542                 decreaseIndent();
80543             }
80544         }
80545         function getLeadingLineTerminatorCount(parentNode, children, format) {
80546             if (format & 2 || preserveSourceNewlines) {
80547                 if (format & 65536) {
80548                     return 1;
80549                 }
80550                 var firstChild_1 = children[0];
80551                 if (firstChild_1 === undefined) {
80552                     return ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
80553                 }
80554                 if (firstChild_1.kind === 11) {
80555                     return 0;
80556                 }
80557                 if (!ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(firstChild_1) && (!firstChild_1.parent || firstChild_1.parent === parentNode)) {
80558                     if (preserveSourceNewlines) {
80559                         return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter(firstChild_1.pos, parentNode.pos, currentSourceFile, includeComments); });
80560                     }
80561                     return ts.rangeStartPositionsAreOnSameLine(parentNode, firstChild_1, currentSourceFile) ? 0 : 1;
80562                 }
80563                 if (synthesizedNodeStartsOnNewLine(firstChild_1, format)) {
80564                     return 1;
80565                 }
80566             }
80567             return format & 1 ? 1 : 0;
80568         }
80569         function getSeparatingLineTerminatorCount(previousNode, nextNode, format) {
80570             if (format & 2 || preserveSourceNewlines) {
80571                 if (previousNode === undefined || nextNode === undefined) {
80572                     return 0;
80573                 }
80574                 if (nextNode.kind === 11) {
80575                     return 0;
80576                 }
80577                 else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode) && previousNode.parent === nextNode.parent) {
80578                     if (preserveSourceNewlines) {
80579                         return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); });
80580                     }
80581                     return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1;
80582                 }
80583                 else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) {
80584                     return 1;
80585                 }
80586             }
80587             else if (ts.getStartsOnNewLine(nextNode)) {
80588                 return 1;
80589             }
80590             return format & 1 ? 1 : 0;
80591         }
80592         function getClosingLineTerminatorCount(parentNode, children, format) {
80593             if (format & 2 || preserveSourceNewlines) {
80594                 if (format & 65536) {
80595                     return 1;
80596                 }
80597                 var lastChild_1 = ts.lastOrUndefined(children);
80598                 if (lastChild_1 === undefined) {
80599                     return ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
80600                 }
80601                 if (!ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild_1) && (!lastChild_1.parent || lastChild_1.parent === parentNode)) {
80602                     if (preserveSourceNewlines) {
80603                         return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter(lastChild_1.end, parentNode.end, currentSourceFile, includeComments); });
80604                     }
80605                     return ts.rangeEndPositionsAreOnSameLine(parentNode, lastChild_1, currentSourceFile) ? 0 : 1;
80606                 }
80607                 if (synthesizedNodeStartsOnNewLine(lastChild_1, format)) {
80608                     return 1;
80609                 }
80610             }
80611             if (format & 1 && !(format & 131072)) {
80612                 return 1;
80613             }
80614             return 0;
80615         }
80616         function getEffectiveLines(getLineDifference) {
80617             ts.Debug.assert(!!preserveSourceNewlines);
80618             var lines = getLineDifference(true);
80619             if (lines === 0) {
80620                 return getLineDifference(false);
80621             }
80622             return lines;
80623         }
80624         function writeLineSeparatorsAndIndentBefore(node, parent) {
80625             var leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, [node], 0);
80626             if (leadingNewlines) {
80627                 writeLinesAndIndent(leadingNewlines, false);
80628             }
80629             return !!leadingNewlines;
80630         }
80631         function writeLineSeparatorsAfter(node, parent) {
80632             var trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, [node], 0);
80633             if (trailingNewlines) {
80634                 writeLine(trailingNewlines);
80635             }
80636         }
80637         function synthesizedNodeStartsOnNewLine(node, format) {
80638             if (ts.nodeIsSynthesized(node)) {
80639                 var startsOnNewLine = ts.getStartsOnNewLine(node);
80640                 if (startsOnNewLine === undefined) {
80641                     return (format & 65536) !== 0;
80642                 }
80643                 return startsOnNewLine;
80644             }
80645             return (format & 65536) !== 0;
80646         }
80647         function getLinesBetweenNodes(parent, node1, node2) {
80648             if (ts.getEmitFlags(parent) & 131072) {
80649                 return 0;
80650             }
80651             parent = skipSynthesizedParentheses(parent);
80652             node1 = skipSynthesizedParentheses(node1);
80653             node2 = skipSynthesizedParentheses(node2);
80654             if (ts.getStartsOnNewLine(node2)) {
80655                 return 1;
80656             }
80657             if (!ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) {
80658                 if (preserveSourceNewlines) {
80659                     return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(node1, node2, currentSourceFile, includeComments); });
80660                 }
80661                 return ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile) ? 0 : 1;
80662             }
80663             return 0;
80664         }
80665         function isEmptyBlock(block) {
80666             return block.statements.length === 0
80667                 && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile);
80668         }
80669         function skipSynthesizedParentheses(node) {
80670             while (node.kind === 200 && ts.nodeIsSynthesized(node)) {
80671                 node = node.expression;
80672             }
80673             return node;
80674         }
80675         function getTextOfNode(node, includeTrivia) {
80676             if (ts.isGeneratedIdentifier(node)) {
80677                 return generateName(node);
80678             }
80679             else if ((ts.isIdentifier(node) || ts.isPrivateIdentifier(node)) && (ts.nodeIsSynthesized(node) || !node.parent || !currentSourceFile || (node.parent && currentSourceFile && ts.getSourceFileOfNode(node) !== ts.getOriginalNode(currentSourceFile)))) {
80680                 return ts.idText(node);
80681             }
80682             else if (node.kind === 10 && node.textSourceNode) {
80683                 return getTextOfNode(node.textSourceNode, includeTrivia);
80684             }
80685             else if (ts.isLiteralExpression(node) && (ts.nodeIsSynthesized(node) || !node.parent)) {
80686                 return node.text;
80687             }
80688             return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node, includeTrivia);
80689         }
80690         function getLiteralTextOfNode(node, neverAsciiEscape, jsxAttributeEscape) {
80691             if (node.kind === 10 && node.textSourceNode) {
80692                 var textSourceNode = node.textSourceNode;
80693                 if (ts.isIdentifier(textSourceNode)) {
80694                     return jsxAttributeEscape ? "\"" + ts.escapeJsxAttributeString(getTextOfNode(textSourceNode)) + "\"" :
80695                         neverAsciiEscape || (ts.getEmitFlags(node) & 16777216) ? "\"" + ts.escapeString(getTextOfNode(textSourceNode)) + "\"" :
80696                             "\"" + ts.escapeNonAsciiString(getTextOfNode(textSourceNode)) + "\"";
80697                 }
80698                 else {
80699                     return getLiteralTextOfNode(textSourceNode, neverAsciiEscape, jsxAttributeEscape);
80700                 }
80701             }
80702             return ts.getLiteralText(node, currentSourceFile, neverAsciiEscape, jsxAttributeEscape);
80703         }
80704         function pushNameGenerationScope(node) {
80705             if (node && ts.getEmitFlags(node) & 524288) {
80706                 return;
80707             }
80708             tempFlagsStack.push(tempFlags);
80709             tempFlags = 0;
80710             reservedNamesStack.push(reservedNames);
80711         }
80712         function popNameGenerationScope(node) {
80713             if (node && ts.getEmitFlags(node) & 524288) {
80714                 return;
80715             }
80716             tempFlags = tempFlagsStack.pop();
80717             reservedNames = reservedNamesStack.pop();
80718         }
80719         function reserveNameInNestedScopes(name) {
80720             if (!reservedNames || reservedNames === ts.lastOrUndefined(reservedNamesStack)) {
80721                 reservedNames = ts.createMap();
80722             }
80723             reservedNames.set(name, true);
80724         }
80725         function generateNames(node) {
80726             if (!node)
80727                 return;
80728             switch (node.kind) {
80729                 case 223:
80730                     ts.forEach(node.statements, generateNames);
80731                     break;
80732                 case 238:
80733                 case 236:
80734                 case 228:
80735                 case 229:
80736                     generateNames(node.statement);
80737                     break;
80738                 case 227:
80739                     generateNames(node.thenStatement);
80740                     generateNames(node.elseStatement);
80741                     break;
80742                 case 230:
80743                 case 232:
80744                 case 231:
80745                     generateNames(node.initializer);
80746                     generateNames(node.statement);
80747                     break;
80748                 case 237:
80749                     generateNames(node.caseBlock);
80750                     break;
80751                 case 251:
80752                     ts.forEach(node.clauses, generateNames);
80753                     break;
80754                 case 277:
80755                 case 278:
80756                     ts.forEach(node.statements, generateNames);
80757                     break;
80758                 case 240:
80759                     generateNames(node.tryBlock);
80760                     generateNames(node.catchClause);
80761                     generateNames(node.finallyBlock);
80762                     break;
80763                 case 280:
80764                     generateNames(node.variableDeclaration);
80765                     generateNames(node.block);
80766                     break;
80767                 case 225:
80768                     generateNames(node.declarationList);
80769                     break;
80770                 case 243:
80771                     ts.forEach(node.declarations, generateNames);
80772                     break;
80773                 case 242:
80774                 case 156:
80775                 case 191:
80776                 case 245:
80777                     generateNameIfNeeded(node.name);
80778                     break;
80779                 case 244:
80780                     generateNameIfNeeded(node.name);
80781                     if (ts.getEmitFlags(node) & 524288) {
80782                         ts.forEach(node.parameters, generateNames);
80783                         generateNames(node.body);
80784                     }
80785                     break;
80786                 case 189:
80787                 case 190:
80788                     ts.forEach(node.elements, generateNames);
80789                     break;
80790                 case 254:
80791                     generateNames(node.importClause);
80792                     break;
80793                 case 255:
80794                     generateNameIfNeeded(node.name);
80795                     generateNames(node.namedBindings);
80796                     break;
80797                 case 256:
80798                     generateNameIfNeeded(node.name);
80799                     break;
80800                 case 262:
80801                     generateNameIfNeeded(node.name);
80802                     break;
80803                 case 257:
80804                     ts.forEach(node.elements, generateNames);
80805                     break;
80806                 case 258:
80807                     generateNameIfNeeded(node.propertyName || node.name);
80808                     break;
80809             }
80810         }
80811         function generateMemberNames(node) {
80812             if (!node)
80813                 return;
80814             switch (node.kind) {
80815                 case 281:
80816                 case 282:
80817                 case 159:
80818                 case 161:
80819                 case 163:
80820                 case 164:
80821                     generateNameIfNeeded(node.name);
80822                     break;
80823             }
80824         }
80825         function generateNameIfNeeded(name) {
80826             if (name) {
80827                 if (ts.isGeneratedIdentifier(name)) {
80828                     generateName(name);
80829                 }
80830                 else if (ts.isBindingPattern(name)) {
80831                     generateNames(name);
80832                 }
80833             }
80834         }
80835         function generateName(name) {
80836             if ((name.autoGenerateFlags & 7) === 4) {
80837                 return generateNameCached(getNodeForGeneratedName(name), name.autoGenerateFlags);
80838             }
80839             else {
80840                 var autoGenerateId = name.autoGenerateId;
80841                 return autoGeneratedIdToGeneratedName[autoGenerateId] || (autoGeneratedIdToGeneratedName[autoGenerateId] = makeName(name));
80842             }
80843         }
80844         function generateNameCached(node, flags) {
80845             var nodeId = ts.getNodeId(node);
80846             return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = generateNameForNode(node, flags));
80847         }
80848         function isUniqueName(name) {
80849             return isFileLevelUniqueName(name)
80850                 && !generatedNames.has(name)
80851                 && !(reservedNames && reservedNames.has(name));
80852         }
80853         function isFileLevelUniqueName(name) {
80854             return currentSourceFile ? ts.isFileLevelUniqueName(currentSourceFile, name, hasGlobalName) : true;
80855         }
80856         function isUniqueLocalName(name, container) {
80857             for (var node = container; ts.isNodeDescendantOf(node, container); node = node.nextContainer) {
80858                 if (node.locals) {
80859                     var local = node.locals.get(ts.escapeLeadingUnderscores(name));
80860                     if (local && local.flags & (111551 | 1048576 | 2097152)) {
80861                         return false;
80862                     }
80863                 }
80864             }
80865             return true;
80866         }
80867         function makeTempVariableName(flags, reservedInNestedScopes) {
80868             if (flags && !(tempFlags & flags)) {
80869                 var name = flags === 268435456 ? "_i" : "_n";
80870                 if (isUniqueName(name)) {
80871                     tempFlags |= flags;
80872                     if (reservedInNestedScopes) {
80873                         reserveNameInNestedScopes(name);
80874                     }
80875                     return name;
80876                 }
80877             }
80878             while (true) {
80879                 var count = tempFlags & 268435455;
80880                 tempFlags++;
80881                 if (count !== 8 && count !== 13) {
80882                     var name = count < 26
80883                         ? "_" + String.fromCharCode(97 + count)
80884                         : "_" + (count - 26);
80885                     if (isUniqueName(name)) {
80886                         if (reservedInNestedScopes) {
80887                             reserveNameInNestedScopes(name);
80888                         }
80889                         return name;
80890                     }
80891                 }
80892             }
80893         }
80894         function makeUniqueName(baseName, checkFn, optimistic, scoped) {
80895             if (checkFn === void 0) { checkFn = isUniqueName; }
80896             if (optimistic) {
80897                 if (checkFn(baseName)) {
80898                     if (scoped) {
80899                         reserveNameInNestedScopes(baseName);
80900                     }
80901                     else {
80902                         generatedNames.set(baseName, true);
80903                     }
80904                     return baseName;
80905                 }
80906             }
80907             if (baseName.charCodeAt(baseName.length - 1) !== 95) {
80908                 baseName += "_";
80909             }
80910             var i = 1;
80911             while (true) {
80912                 var generatedName = baseName + i;
80913                 if (checkFn(generatedName)) {
80914                     if (scoped) {
80915                         reserveNameInNestedScopes(generatedName);
80916                     }
80917                     else {
80918                         generatedNames.set(generatedName, true);
80919                     }
80920                     return generatedName;
80921                 }
80922                 i++;
80923             }
80924         }
80925         function makeFileLevelOptimisticUniqueName(name) {
80926             return makeUniqueName(name, isFileLevelUniqueName, true);
80927         }
80928         function generateNameForModuleOrEnum(node) {
80929             var name = getTextOfNode(node.name);
80930             return isUniqueLocalName(name, node) ? name : makeUniqueName(name);
80931         }
80932         function generateNameForImportOrExportDeclaration(node) {
80933             var expr = ts.getExternalModuleName(node);
80934             var baseName = ts.isStringLiteral(expr) ?
80935                 ts.makeIdentifierFromModuleName(expr.text) : "module";
80936             return makeUniqueName(baseName);
80937         }
80938         function generateNameForExportDefault() {
80939             return makeUniqueName("default");
80940         }
80941         function generateNameForClassExpression() {
80942             return makeUniqueName("class");
80943         }
80944         function generateNameForMethodOrAccessor(node) {
80945             if (ts.isIdentifier(node.name)) {
80946                 return generateNameCached(node.name);
80947             }
80948             return makeTempVariableName(0);
80949         }
80950         function generateNameForNode(node, flags) {
80951             switch (node.kind) {
80952                 case 75:
80953                     return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16), !!(flags & 8));
80954                 case 249:
80955                 case 248:
80956                     return generateNameForModuleOrEnum(node);
80957                 case 254:
80958                 case 260:
80959                     return generateNameForImportOrExportDeclaration(node);
80960                 case 244:
80961                 case 245:
80962                 case 259:
80963                     return generateNameForExportDefault();
80964                 case 214:
80965                     return generateNameForClassExpression();
80966                 case 161:
80967                 case 163:
80968                 case 164:
80969                     return generateNameForMethodOrAccessor(node);
80970                 case 154:
80971                     return makeTempVariableName(0, true);
80972                 default:
80973                     return makeTempVariableName(0);
80974             }
80975         }
80976         function makeName(name) {
80977             switch (name.autoGenerateFlags & 7) {
80978                 case 1:
80979                     return makeTempVariableName(0, !!(name.autoGenerateFlags & 8));
80980                 case 2:
80981                     return makeTempVariableName(268435456, !!(name.autoGenerateFlags & 8));
80982                 case 3:
80983                     return makeUniqueName(ts.idText(name), (name.autoGenerateFlags & 32) ? isFileLevelUniqueName : isUniqueName, !!(name.autoGenerateFlags & 16), !!(name.autoGenerateFlags & 8));
80984             }
80985             return ts.Debug.fail("Unsupported GeneratedIdentifierKind.");
80986         }
80987         function getNodeForGeneratedName(name) {
80988             var autoGenerateId = name.autoGenerateId;
80989             var node = name;
80990             var original = node.original;
80991             while (original) {
80992                 node = original;
80993                 if (ts.isIdentifier(node)
80994                     && !!(node.autoGenerateFlags & 4)
80995                     && node.autoGenerateId !== autoGenerateId) {
80996                     break;
80997                 }
80998                 original = node.original;
80999             }
81000             return node;
81001         }
81002         function pipelineEmitWithComments(hint, node) {
81003             ts.Debug.assert(lastNode === node || lastSubstitution === node);
81004             enterComment();
81005             hasWrittenComment = false;
81006             var emitFlags = ts.getEmitFlags(node);
81007             var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end;
81008             var isEmittedNode = node.kind !== 325;
81009             var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0 || node.kind === 11;
81010             var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0 || node.kind === 11;
81011             var savedContainerPos = containerPos;
81012             var savedContainerEnd = containerEnd;
81013             var savedDeclarationListContainerEnd = declarationListContainerEnd;
81014             if ((pos > 0 || end > 0) && pos !== end) {
81015                 if (!skipLeadingComments) {
81016                     emitLeadingComments(pos, isEmittedNode);
81017                 }
81018                 if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512) !== 0)) {
81019                     containerPos = pos;
81020                 }
81021                 if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024) !== 0)) {
81022                     containerEnd = end;
81023                     if (node.kind === 243) {
81024                         declarationListContainerEnd = end;
81025                     }
81026                 }
81027             }
81028             ts.forEach(ts.getSyntheticLeadingComments(node), emitLeadingSynthesizedComment);
81029             exitComment();
81030             var pipelinePhase = getNextPipelinePhase(2, hint, node);
81031             if (emitFlags & 2048) {
81032                 commentsDisabled = true;
81033                 pipelinePhase(hint, node);
81034                 commentsDisabled = false;
81035             }
81036             else {
81037                 pipelinePhase(hint, node);
81038             }
81039             enterComment();
81040             ts.forEach(ts.getSyntheticTrailingComments(node), emitTrailingSynthesizedComment);
81041             if ((pos > 0 || end > 0) && pos !== end) {
81042                 containerPos = savedContainerPos;
81043                 containerEnd = savedContainerEnd;
81044                 declarationListContainerEnd = savedDeclarationListContainerEnd;
81045                 if (!skipTrailingComments && isEmittedNode) {
81046                     emitTrailingComments(end);
81047                 }
81048             }
81049             exitComment();
81050             ts.Debug.assert(lastNode === node || lastSubstitution === node);
81051         }
81052         function emitLeadingSynthesizedComment(comment) {
81053             if (comment.kind === 2) {
81054                 writer.writeLine();
81055             }
81056             writeSynthesizedComment(comment);
81057             if (comment.hasTrailingNewLine || comment.kind === 2) {
81058                 writer.writeLine();
81059             }
81060             else {
81061                 writer.writeSpace(" ");
81062             }
81063         }
81064         function emitTrailingSynthesizedComment(comment) {
81065             if (!writer.isAtStartOfLine()) {
81066                 writer.writeSpace(" ");
81067             }
81068             writeSynthesizedComment(comment);
81069             if (comment.hasTrailingNewLine) {
81070                 writer.writeLine();
81071             }
81072         }
81073         function writeSynthesizedComment(comment) {
81074             var text = formatSynthesizedComment(comment);
81075             var lineMap = comment.kind === 3 ? ts.computeLineStarts(text) : undefined;
81076             ts.writeCommentRange(text, lineMap, writer, 0, text.length, newLine);
81077         }
81078         function formatSynthesizedComment(comment) {
81079             return comment.kind === 3
81080                 ? "/*" + comment.text + "*/"
81081                 : "//" + comment.text;
81082         }
81083         function emitBodyWithDetachedComments(node, detachedRange, emitCallback) {
81084             enterComment();
81085             var pos = detachedRange.pos, end = detachedRange.end;
81086             var emitFlags = ts.getEmitFlags(node);
81087             var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0;
81088             var skipTrailingComments = commentsDisabled || end < 0 || (emitFlags & 1024) !== 0;
81089             if (!skipLeadingComments) {
81090                 emitDetachedCommentsAndUpdateCommentsInfo(detachedRange);
81091             }
81092             exitComment();
81093             if (emitFlags & 2048 && !commentsDisabled) {
81094                 commentsDisabled = true;
81095                 emitCallback(node);
81096                 commentsDisabled = false;
81097             }
81098             else {
81099                 emitCallback(node);
81100             }
81101             enterComment();
81102             if (!skipTrailingComments) {
81103                 emitLeadingComments(detachedRange.end, true);
81104                 if (hasWrittenComment && !writer.isAtStartOfLine()) {
81105                     writer.writeLine();
81106                 }
81107             }
81108             exitComment();
81109         }
81110         function emitLeadingComments(pos, isEmittedNode) {
81111             hasWrittenComment = false;
81112             if (isEmittedNode) {
81113                 forEachLeadingCommentToEmit(pos, emitLeadingComment);
81114             }
81115             else if (pos === 0) {
81116                 forEachLeadingCommentToEmit(pos, emitTripleSlashLeadingComment);
81117             }
81118         }
81119         function emitTripleSlashLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) {
81120             if (isTripleSlashComment(commentPos, commentEnd)) {
81121                 emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos);
81122             }
81123         }
81124         function shouldWriteComment(text, pos) {
81125             if (printerOptions.onlyPrintJsDocStyle) {
81126                 return (ts.isJSDocLikeText(text, pos) || ts.isPinnedComment(text, pos));
81127             }
81128             return true;
81129         }
81130         function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) {
81131             if (!shouldWriteComment(currentSourceFile.text, commentPos))
81132                 return;
81133             if (!hasWrittenComment) {
81134                 ts.emitNewLineBeforeLeadingCommentOfPosition(getCurrentLineMap(), writer, rangePos, commentPos);
81135                 hasWrittenComment = true;
81136             }
81137             emitPos(commentPos);
81138             ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
81139             emitPos(commentEnd);
81140             if (hasTrailingNewLine) {
81141                 writer.writeLine();
81142             }
81143             else if (kind === 3) {
81144                 writer.writeSpace(" ");
81145             }
81146         }
81147         function emitLeadingCommentsOfPosition(pos) {
81148             if (commentsDisabled || pos === -1) {
81149                 return;
81150             }
81151             emitLeadingComments(pos, true);
81152         }
81153         function emitTrailingComments(pos) {
81154             forEachTrailingCommentToEmit(pos, emitTrailingComment);
81155         }
81156         function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) {
81157             if (!shouldWriteComment(currentSourceFile.text, commentPos))
81158                 return;
81159             if (!writer.isAtStartOfLine()) {
81160                 writer.writeSpace(" ");
81161             }
81162             emitPos(commentPos);
81163             ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
81164             emitPos(commentEnd);
81165             if (hasTrailingNewLine) {
81166                 writer.writeLine();
81167             }
81168         }
81169         function emitTrailingCommentsOfPosition(pos, prefixSpace) {
81170             if (commentsDisabled) {
81171                 return;
81172             }
81173             enterComment();
81174             forEachTrailingCommentToEmit(pos, prefixSpace ? emitTrailingComment : emitTrailingCommentOfPosition);
81175             exitComment();
81176         }
81177         function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) {
81178             emitPos(commentPos);
81179             ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
81180             emitPos(commentEnd);
81181             if (hasTrailingNewLine) {
81182                 writer.writeLine();
81183             }
81184             else {
81185                 writer.writeSpace(" ");
81186             }
81187         }
81188         function forEachLeadingCommentToEmit(pos, cb) {
81189             if (currentSourceFile && (containerPos === -1 || pos !== containerPos)) {
81190                 if (hasDetachedComments(pos)) {
81191                     forEachLeadingCommentWithoutDetachedComments(cb);
81192                 }
81193                 else {
81194                     ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, pos);
81195                 }
81196             }
81197         }
81198         function forEachTrailingCommentToEmit(end, cb) {
81199             if (currentSourceFile && (containerEnd === -1 || (end !== containerEnd && end !== declarationListContainerEnd))) {
81200                 ts.forEachTrailingCommentRange(currentSourceFile.text, end, cb);
81201             }
81202         }
81203         function hasDetachedComments(pos) {
81204             return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos;
81205         }
81206         function forEachLeadingCommentWithoutDetachedComments(cb) {
81207             var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos;
81208             if (detachedCommentsInfo.length - 1) {
81209                 detachedCommentsInfo.pop();
81210             }
81211             else {
81212                 detachedCommentsInfo = undefined;
81213             }
81214             ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, pos);
81215         }
81216         function emitDetachedCommentsAndUpdateCommentsInfo(range) {
81217             var currentDetachedCommentInfo = ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled);
81218             if (currentDetachedCommentInfo) {
81219                 if (detachedCommentsInfo) {
81220                     detachedCommentsInfo.push(currentDetachedCommentInfo);
81221                 }
81222                 else {
81223                     detachedCommentsInfo = [currentDetachedCommentInfo];
81224                 }
81225             }
81226         }
81227         function emitComment(text, lineMap, writer, commentPos, commentEnd, newLine) {
81228             if (!shouldWriteComment(currentSourceFile.text, commentPos))
81229                 return;
81230             emitPos(commentPos);
81231             ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine);
81232             emitPos(commentEnd);
81233         }
81234         function isTripleSlashComment(commentPos, commentEnd) {
81235             return ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd);
81236         }
81237         function getParsedSourceMap(node) {
81238             if (node.parsedSourceMap === undefined && node.sourceMapText !== undefined) {
81239                 node.parsedSourceMap = ts.tryParseRawSourceMap(node.sourceMapText) || false;
81240             }
81241             return node.parsedSourceMap || undefined;
81242         }
81243         function pipelineEmitWithSourceMap(hint, node) {
81244             ts.Debug.assert(lastNode === node || lastSubstitution === node);
81245             var pipelinePhase = getNextPipelinePhase(3, hint, node);
81246             if (ts.isUnparsedSource(node) || ts.isUnparsedPrepend(node)) {
81247                 pipelinePhase(hint, node);
81248             }
81249             else if (ts.isUnparsedNode(node)) {
81250                 var parsed = getParsedSourceMap(node.parent);
81251                 if (parsed && sourceMapGenerator) {
81252                     sourceMapGenerator.appendSourceMap(writer.getLine(), writer.getColumn(), parsed, node.parent.sourceMapPath, node.parent.getLineAndCharacterOfPosition(node.pos), node.parent.getLineAndCharacterOfPosition(node.end));
81253                 }
81254                 pipelinePhase(hint, node);
81255             }
81256             else {
81257                 var _a = ts.getSourceMapRange(node), pos = _a.pos, end = _a.end, _b = _a.source, source = _b === void 0 ? sourceMapSource : _b;
81258                 var emitFlags = ts.getEmitFlags(node);
81259                 if (node.kind !== 325
81260                     && (emitFlags & 16) === 0
81261                     && pos >= 0) {
81262                     emitSourcePos(source, skipSourceTrivia(source, pos));
81263                 }
81264                 if (emitFlags & 64) {
81265                     sourceMapsDisabled = true;
81266                     pipelinePhase(hint, node);
81267                     sourceMapsDisabled = false;
81268                 }
81269                 else {
81270                     pipelinePhase(hint, node);
81271                 }
81272                 if (node.kind !== 325
81273                     && (emitFlags & 32) === 0
81274                     && end >= 0) {
81275                     emitSourcePos(source, end);
81276                 }
81277             }
81278             ts.Debug.assert(lastNode === node || lastSubstitution === node);
81279         }
81280         function skipSourceTrivia(source, pos) {
81281             return source.skipTrivia ? source.skipTrivia(pos) : ts.skipTrivia(source.text, pos);
81282         }
81283         function emitPos(pos) {
81284             if (sourceMapsDisabled || ts.positionIsSynthesized(pos) || isJsonSourceMapSource(sourceMapSource)) {
81285                 return;
81286             }
81287             var _a = ts.getLineAndCharacterOfPosition(sourceMapSource, pos), sourceLine = _a.line, sourceCharacter = _a.character;
81288             sourceMapGenerator.addMapping(writer.getLine(), writer.getColumn(), sourceMapSourceIndex, sourceLine, sourceCharacter, undefined);
81289         }
81290         function emitSourcePos(source, pos) {
81291             if (source !== sourceMapSource) {
81292                 var savedSourceMapSource = sourceMapSource;
81293                 setSourceMapSource(source);
81294                 emitPos(pos);
81295                 setSourceMapSource(savedSourceMapSource);
81296             }
81297             else {
81298                 emitPos(pos);
81299             }
81300         }
81301         function emitTokenWithSourceMap(node, token, writer, tokenPos, emitCallback) {
81302             if (sourceMapsDisabled || node && ts.isInJsonFile(node)) {
81303                 return emitCallback(token, writer, tokenPos);
81304             }
81305             var emitNode = node && node.emitNode;
81306             var emitFlags = emitNode && emitNode.flags || 0;
81307             var range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token];
81308             var source = range && range.source || sourceMapSource;
81309             tokenPos = skipSourceTrivia(source, range ? range.pos : tokenPos);
81310             if ((emitFlags & 128) === 0 && tokenPos >= 0) {
81311                 emitSourcePos(source, tokenPos);
81312             }
81313             tokenPos = emitCallback(token, writer, tokenPos);
81314             if (range)
81315                 tokenPos = range.end;
81316             if ((emitFlags & 256) === 0 && tokenPos >= 0) {
81317                 emitSourcePos(source, tokenPos);
81318             }
81319             return tokenPos;
81320         }
81321         function setSourceMapSource(source) {
81322             if (sourceMapsDisabled) {
81323                 return;
81324             }
81325             sourceMapSource = source;
81326             if (isJsonSourceMapSource(source)) {
81327                 return;
81328             }
81329             sourceMapSourceIndex = sourceMapGenerator.addSource(source.fileName);
81330             if (printerOptions.inlineSources) {
81331                 sourceMapGenerator.setSourceContent(sourceMapSourceIndex, source.text);
81332             }
81333         }
81334         function isJsonSourceMapSource(sourceFile) {
81335             return ts.fileExtensionIs(sourceFile.fileName, ".json");
81336         }
81337     }
81338     ts.createPrinter = createPrinter;
81339     function createBracketsMap() {
81340         var brackets = [];
81341         brackets[1024] = ["{", "}"];
81342         brackets[2048] = ["(", ")"];
81343         brackets[4096] = ["<", ">"];
81344         brackets[8192] = ["[", "]"];
81345         return brackets;
81346     }
81347     function getOpeningBracket(format) {
81348         return brackets[format & 15360][0];
81349     }
81350     function getClosingBracket(format) {
81351         return brackets[format & 15360][1];
81352     }
81353 })(ts || (ts = {}));
81354 var ts;
81355 (function (ts) {
81356     function createCachedDirectoryStructureHost(host, currentDirectory, useCaseSensitiveFileNames) {
81357         if (!host.getDirectories || !host.readDirectory) {
81358             return undefined;
81359         }
81360         var cachedReadDirectoryResult = ts.createMap();
81361         var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
81362         return {
81363             useCaseSensitiveFileNames: useCaseSensitiveFileNames,
81364             fileExists: fileExists,
81365             readFile: function (path, encoding) { return host.readFile(path, encoding); },
81366             directoryExists: host.directoryExists && directoryExists,
81367             getDirectories: getDirectories,
81368             readDirectory: readDirectory,
81369             createDirectory: host.createDirectory && createDirectory,
81370             writeFile: host.writeFile && writeFile,
81371             addOrDeleteFileOrDirectory: addOrDeleteFileOrDirectory,
81372             addOrDeleteFile: addOrDeleteFile,
81373             clearCache: clearCache,
81374             realpath: host.realpath && realpath
81375         };
81376         function toPath(fileName) {
81377             return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
81378         }
81379         function getCachedFileSystemEntries(rootDirPath) {
81380             return cachedReadDirectoryResult.get(ts.ensureTrailingDirectorySeparator(rootDirPath));
81381         }
81382         function getCachedFileSystemEntriesForBaseDir(path) {
81383             return getCachedFileSystemEntries(ts.getDirectoryPath(path));
81384         }
81385         function getBaseNameOfFileName(fileName) {
81386             return ts.getBaseFileName(ts.normalizePath(fileName));
81387         }
81388         function createCachedFileSystemEntries(rootDir, rootDirPath) {
81389             var resultFromHost = {
81390                 files: ts.map(host.readDirectory(rootDir, undefined, undefined, ["*.*"]), getBaseNameOfFileName) || [],
81391                 directories: host.getDirectories(rootDir) || []
81392             };
81393             cachedReadDirectoryResult.set(ts.ensureTrailingDirectorySeparator(rootDirPath), resultFromHost);
81394             return resultFromHost;
81395         }
81396         function tryReadDirectory(rootDir, rootDirPath) {
81397             rootDirPath = ts.ensureTrailingDirectorySeparator(rootDirPath);
81398             var cachedResult = getCachedFileSystemEntries(rootDirPath);
81399             if (cachedResult) {
81400                 return cachedResult;
81401             }
81402             try {
81403                 return createCachedFileSystemEntries(rootDir, rootDirPath);
81404             }
81405             catch (_e) {
81406                 ts.Debug.assert(!cachedReadDirectoryResult.has(ts.ensureTrailingDirectorySeparator(rootDirPath)));
81407                 return undefined;
81408             }
81409         }
81410         function fileNameEqual(name1, name2) {
81411             return getCanonicalFileName(name1) === getCanonicalFileName(name2);
81412         }
81413         function hasEntry(entries, name) {
81414             return ts.some(entries, function (file) { return fileNameEqual(file, name); });
81415         }
81416         function updateFileSystemEntry(entries, baseName, isValid) {
81417             if (hasEntry(entries, baseName)) {
81418                 if (!isValid) {
81419                     return ts.filterMutate(entries, function (entry) { return !fileNameEqual(entry, baseName); });
81420                 }
81421             }
81422             else if (isValid) {
81423                 return entries.push(baseName);
81424             }
81425         }
81426         function writeFile(fileName, data, writeByteOrderMark) {
81427             var path = toPath(fileName);
81428             var result = getCachedFileSystemEntriesForBaseDir(path);
81429             if (result) {
81430                 updateFilesOfFileSystemEntry(result, getBaseNameOfFileName(fileName), true);
81431             }
81432             return host.writeFile(fileName, data, writeByteOrderMark);
81433         }
81434         function fileExists(fileName) {
81435             var path = toPath(fileName);
81436             var result = getCachedFileSystemEntriesForBaseDir(path);
81437             return result && hasEntry(result.files, getBaseNameOfFileName(fileName)) ||
81438                 host.fileExists(fileName);
81439         }
81440         function directoryExists(dirPath) {
81441             var path = toPath(dirPath);
81442             return cachedReadDirectoryResult.has(ts.ensureTrailingDirectorySeparator(path)) || host.directoryExists(dirPath);
81443         }
81444         function createDirectory(dirPath) {
81445             var path = toPath(dirPath);
81446             var result = getCachedFileSystemEntriesForBaseDir(path);
81447             var baseFileName = getBaseNameOfFileName(dirPath);
81448             if (result) {
81449                 updateFileSystemEntry(result.directories, baseFileName, true);
81450             }
81451             host.createDirectory(dirPath);
81452         }
81453         function getDirectories(rootDir) {
81454             var rootDirPath = toPath(rootDir);
81455             var result = tryReadDirectory(rootDir, rootDirPath);
81456             if (result) {
81457                 return result.directories.slice();
81458             }
81459             return host.getDirectories(rootDir);
81460         }
81461         function readDirectory(rootDir, extensions, excludes, includes, depth) {
81462             var rootDirPath = toPath(rootDir);
81463             var result = tryReadDirectory(rootDir, rootDirPath);
81464             if (result) {
81465                 return ts.matchFiles(rootDir, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath);
81466             }
81467             return host.readDirectory(rootDir, extensions, excludes, includes, depth);
81468             function getFileSystemEntries(dir) {
81469                 var path = toPath(dir);
81470                 if (path === rootDirPath) {
81471                     return result;
81472                 }
81473                 return tryReadDirectory(dir, path) || ts.emptyFileSystemEntries;
81474             }
81475         }
81476         function realpath(s) {
81477             return host.realpath ? host.realpath(s) : s;
81478         }
81479         function addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath) {
81480             var existingResult = getCachedFileSystemEntries(fileOrDirectoryPath);
81481             if (existingResult) {
81482                 clearCache();
81483                 return undefined;
81484             }
81485             var parentResult = getCachedFileSystemEntriesForBaseDir(fileOrDirectoryPath);
81486             if (!parentResult) {
81487                 return undefined;
81488             }
81489             if (!host.directoryExists) {
81490                 clearCache();
81491                 return undefined;
81492             }
81493             var baseName = getBaseNameOfFileName(fileOrDirectory);
81494             var fsQueryResult = {
81495                 fileExists: host.fileExists(fileOrDirectoryPath),
81496                 directoryExists: host.directoryExists(fileOrDirectoryPath)
81497             };
81498             if (fsQueryResult.directoryExists || hasEntry(parentResult.directories, baseName)) {
81499                 clearCache();
81500             }
81501             else {
81502                 updateFilesOfFileSystemEntry(parentResult, baseName, fsQueryResult.fileExists);
81503             }
81504             return fsQueryResult;
81505         }
81506         function addOrDeleteFile(fileName, filePath, eventKind) {
81507             if (eventKind === ts.FileWatcherEventKind.Changed) {
81508                 return;
81509             }
81510             var parentResult = getCachedFileSystemEntriesForBaseDir(filePath);
81511             if (parentResult) {
81512                 updateFilesOfFileSystemEntry(parentResult, getBaseNameOfFileName(fileName), eventKind === ts.FileWatcherEventKind.Created);
81513             }
81514         }
81515         function updateFilesOfFileSystemEntry(parentResult, baseName, fileExists) {
81516             updateFileSystemEntry(parentResult.files, baseName, fileExists);
81517         }
81518         function clearCache() {
81519             cachedReadDirectoryResult.clear();
81520         }
81521     }
81522     ts.createCachedDirectoryStructureHost = createCachedDirectoryStructureHost;
81523     var ConfigFileProgramReloadLevel;
81524     (function (ConfigFileProgramReloadLevel) {
81525         ConfigFileProgramReloadLevel[ConfigFileProgramReloadLevel["None"] = 0] = "None";
81526         ConfigFileProgramReloadLevel[ConfigFileProgramReloadLevel["Partial"] = 1] = "Partial";
81527         ConfigFileProgramReloadLevel[ConfigFileProgramReloadLevel["Full"] = 2] = "Full";
81528     })(ConfigFileProgramReloadLevel = ts.ConfigFileProgramReloadLevel || (ts.ConfigFileProgramReloadLevel = {}));
81529     function updateMissingFilePathsWatch(program, missingFileWatches, createMissingFileWatch) {
81530         var missingFilePaths = program.getMissingFilePaths();
81531         var newMissingFilePathMap = ts.arrayToSet(missingFilePaths);
81532         ts.mutateMap(missingFileWatches, newMissingFilePathMap, {
81533             createNewValue: createMissingFileWatch,
81534             onDeleteValue: ts.closeFileWatcher
81535         });
81536     }
81537     ts.updateMissingFilePathsWatch = updateMissingFilePathsWatch;
81538     function updateWatchingWildcardDirectories(existingWatchedForWildcards, wildcardDirectories, watchDirectory) {
81539         ts.mutateMap(existingWatchedForWildcards, wildcardDirectories, {
81540             createNewValue: createWildcardDirectoryWatcher,
81541             onDeleteValue: closeFileWatcherOf,
81542             onExistingValue: updateWildcardDirectoryWatcher
81543         });
81544         function createWildcardDirectoryWatcher(directory, flags) {
81545             return {
81546                 watcher: watchDirectory(directory, flags),
81547                 flags: flags
81548             };
81549         }
81550         function updateWildcardDirectoryWatcher(existingWatcher, flags, directory) {
81551             if (existingWatcher.flags === flags) {
81552                 return;
81553             }
81554             existingWatcher.watcher.close();
81555             existingWatchedForWildcards.set(directory, createWildcardDirectoryWatcher(directory, flags));
81556         }
81557     }
81558     ts.updateWatchingWildcardDirectories = updateWatchingWildcardDirectories;
81559     function isEmittedFileOfProgram(program, file) {
81560         if (!program) {
81561             return false;
81562         }
81563         return program.isEmittedFile(file);
81564     }
81565     ts.isEmittedFileOfProgram = isEmittedFileOfProgram;
81566     var WatchLogLevel;
81567     (function (WatchLogLevel) {
81568         WatchLogLevel[WatchLogLevel["None"] = 0] = "None";
81569         WatchLogLevel[WatchLogLevel["TriggerOnly"] = 1] = "TriggerOnly";
81570         WatchLogLevel[WatchLogLevel["Verbose"] = 2] = "Verbose";
81571     })(WatchLogLevel = ts.WatchLogLevel || (ts.WatchLogLevel = {}));
81572     function getWatchFactory(watchLogLevel, log, getDetailWatchInfo) {
81573         return getWatchFactoryWith(watchLogLevel, log, getDetailWatchInfo, watchFile, watchDirectory);
81574     }
81575     ts.getWatchFactory = getWatchFactory;
81576     function getWatchFactoryWith(watchLogLevel, log, getDetailWatchInfo, watchFile, watchDirectory) {
81577         var createFileWatcher = getCreateFileWatcher(watchLogLevel, watchFile);
81578         var createFilePathWatcher = watchLogLevel === WatchLogLevel.None ? watchFilePath : createFileWatcher;
81579         var createDirectoryWatcher = getCreateFileWatcher(watchLogLevel, watchDirectory);
81580         if (watchLogLevel === WatchLogLevel.Verbose && ts.sysLog === ts.noop) {
81581             ts.setSysLog(function (s) { return log(s); });
81582         }
81583         return {
81584             watchFile: function (host, file, callback, pollingInterval, options, detailInfo1, detailInfo2) {
81585                 return createFileWatcher(host, file, callback, pollingInterval, options, undefined, detailInfo1, detailInfo2, watchFile, log, "FileWatcher", getDetailWatchInfo);
81586             },
81587             watchFilePath: function (host, file, callback, pollingInterval, options, path, detailInfo1, detailInfo2) {
81588                 return createFilePathWatcher(host, file, callback, pollingInterval, options, path, detailInfo1, detailInfo2, watchFile, log, "FileWatcher", getDetailWatchInfo);
81589             },
81590             watchDirectory: function (host, directory, callback, flags, options, detailInfo1, detailInfo2) {
81591                 return createDirectoryWatcher(host, directory, callback, flags, options, undefined, detailInfo1, detailInfo2, watchDirectory, log, "DirectoryWatcher", getDetailWatchInfo);
81592             }
81593         };
81594     }
81595     function watchFile(host, file, callback, pollingInterval, options) {
81596         return host.watchFile(file, callback, pollingInterval, options);
81597     }
81598     function watchFilePath(host, file, callback, pollingInterval, options, path) {
81599         return watchFile(host, file, function (fileName, eventKind) { return callback(fileName, eventKind, path); }, pollingInterval, options);
81600     }
81601     function watchDirectory(host, directory, callback, flags, options) {
81602         return host.watchDirectory(directory, callback, (flags & 1) !== 0, options);
81603     }
81604     function getCreateFileWatcher(watchLogLevel, addWatch) {
81605         switch (watchLogLevel) {
81606             case WatchLogLevel.None:
81607                 return addWatch;
81608             case WatchLogLevel.TriggerOnly:
81609                 return createFileWatcherWithTriggerLogging;
81610             case WatchLogLevel.Verbose:
81611                 return addWatch === watchDirectory ? createDirectoryWatcherWithLogging : createFileWatcherWithLogging;
81612         }
81613     }
81614     function createFileWatcherWithLogging(host, file, cb, flags, options, passThrough, detailInfo1, detailInfo2, addWatch, log, watchCaption, getDetailWatchInfo) {
81615         log(watchCaption + ":: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo));
81616         var watcher = createFileWatcherWithTriggerLogging(host, file, cb, flags, options, passThrough, detailInfo1, detailInfo2, addWatch, log, watchCaption, getDetailWatchInfo);
81617         return {
81618             close: function () {
81619                 log(watchCaption + ":: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo));
81620                 watcher.close();
81621             }
81622         };
81623     }
81624     function createDirectoryWatcherWithLogging(host, file, cb, flags, options, passThrough, detailInfo1, detailInfo2, addWatch, log, watchCaption, getDetailWatchInfo) {
81625         var watchInfo = watchCaption + ":: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo);
81626         log(watchInfo);
81627         var start = ts.timestamp();
81628         var watcher = createFileWatcherWithTriggerLogging(host, file, cb, flags, options, passThrough, detailInfo1, detailInfo2, addWatch, log, watchCaption, getDetailWatchInfo);
81629         var elapsed = ts.timestamp() - start;
81630         log("Elapsed:: " + elapsed + "ms " + watchInfo);
81631         return {
81632             close: function () {
81633                 var watchInfo = watchCaption + ":: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo);
81634                 log(watchInfo);
81635                 var start = ts.timestamp();
81636                 watcher.close();
81637                 var elapsed = ts.timestamp() - start;
81638                 log("Elapsed:: " + elapsed + "ms " + watchInfo);
81639             }
81640         };
81641     }
81642     function createFileWatcherWithTriggerLogging(host, file, cb, flags, options, passThrough, detailInfo1, detailInfo2, addWatch, log, watchCaption, getDetailWatchInfo) {
81643         return addWatch(host, file, function (fileName, cbOptional) {
81644             var triggerredInfo = watchCaption + ":: Triggered with " + fileName + " " + (cbOptional !== undefined ? cbOptional : "") + ":: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo);
81645             log(triggerredInfo);
81646             var start = ts.timestamp();
81647             cb(fileName, cbOptional, passThrough);
81648             var elapsed = ts.timestamp() - start;
81649             log("Elapsed:: " + elapsed + "ms " + triggerredInfo);
81650         }, flags, options);
81651     }
81652     function getFallbackOptions(options) {
81653         var fallbackPolling = options === null || options === void 0 ? void 0 : options.fallbackPolling;
81654         return {
81655             watchFile: fallbackPolling !== undefined ?
81656                 fallbackPolling :
81657                 ts.WatchFileKind.PriorityPollingInterval
81658         };
81659     }
81660     ts.getFallbackOptions = getFallbackOptions;
81661     function getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo) {
81662         return "WatchInfo: " + file + " " + flags + " " + JSON.stringify(options) + " " + (getDetailWatchInfo ? getDetailWatchInfo(detailInfo1, detailInfo2) : detailInfo2 === undefined ? detailInfo1 : detailInfo1 + " " + detailInfo2);
81663     }
81664     function closeFileWatcherOf(objWithWatcher) {
81665         objWithWatcher.watcher.close();
81666     }
81667     ts.closeFileWatcherOf = closeFileWatcherOf;
81668 })(ts || (ts = {}));
81669 var ts;
81670 (function (ts) {
81671     function findConfigFile(searchPath, fileExists, configName) {
81672         if (configName === void 0) { configName = "tsconfig.json"; }
81673         return ts.forEachAncestorDirectory(searchPath, function (ancestor) {
81674             var fileName = ts.combinePaths(ancestor, configName);
81675             return fileExists(fileName) ? fileName : undefined;
81676         });
81677     }
81678     ts.findConfigFile = findConfigFile;
81679     function resolveTripleslashReference(moduleName, containingFile) {
81680         var basePath = ts.getDirectoryPath(containingFile);
81681         var referencedFileName = ts.isRootedDiskPath(moduleName) ? moduleName : ts.combinePaths(basePath, moduleName);
81682         return ts.normalizePath(referencedFileName);
81683     }
81684     ts.resolveTripleslashReference = resolveTripleslashReference;
81685     function computeCommonSourceDirectoryOfFilenames(fileNames, currentDirectory, getCanonicalFileName) {
81686         var commonPathComponents;
81687         var failed = ts.forEach(fileNames, function (sourceFile) {
81688             var sourcePathComponents = ts.getNormalizedPathComponents(sourceFile, currentDirectory);
81689             sourcePathComponents.pop();
81690             if (!commonPathComponents) {
81691                 commonPathComponents = sourcePathComponents;
81692                 return;
81693             }
81694             var n = Math.min(commonPathComponents.length, sourcePathComponents.length);
81695             for (var i = 0; i < n; i++) {
81696                 if (getCanonicalFileName(commonPathComponents[i]) !== getCanonicalFileName(sourcePathComponents[i])) {
81697                     if (i === 0) {
81698                         return true;
81699                     }
81700                     commonPathComponents.length = i;
81701                     break;
81702                 }
81703             }
81704             if (sourcePathComponents.length < commonPathComponents.length) {
81705                 commonPathComponents.length = sourcePathComponents.length;
81706             }
81707         });
81708         if (failed) {
81709             return "";
81710         }
81711         if (!commonPathComponents) {
81712             return currentDirectory;
81713         }
81714         return ts.getPathFromPathComponents(commonPathComponents);
81715     }
81716     ts.computeCommonSourceDirectoryOfFilenames = computeCommonSourceDirectoryOfFilenames;
81717     function createCompilerHost(options, setParentNodes) {
81718         return createCompilerHostWorker(options, setParentNodes);
81719     }
81720     ts.createCompilerHost = createCompilerHost;
81721     function createCompilerHostWorker(options, setParentNodes, system) {
81722         if (system === void 0) { system = ts.sys; }
81723         var existingDirectories = ts.createMap();
81724         var getCanonicalFileName = ts.createGetCanonicalFileName(system.useCaseSensitiveFileNames);
81725         function getSourceFile(fileName, languageVersion, onError) {
81726             var text;
81727             try {
81728                 ts.performance.mark("beforeIORead");
81729                 text = compilerHost.readFile(fileName);
81730                 ts.performance.mark("afterIORead");
81731                 ts.performance.measure("I/O Read", "beforeIORead", "afterIORead");
81732             }
81733             catch (e) {
81734                 if (onError) {
81735                     onError(e.message);
81736                 }
81737                 text = "";
81738             }
81739             return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined;
81740         }
81741         function directoryExists(directoryPath) {
81742             if (existingDirectories.has(directoryPath)) {
81743                 return true;
81744             }
81745             if ((compilerHost.directoryExists || system.directoryExists)(directoryPath)) {
81746                 existingDirectories.set(directoryPath, true);
81747                 return true;
81748             }
81749             return false;
81750         }
81751         function writeFile(fileName, data, writeByteOrderMark, onError) {
81752             try {
81753                 ts.performance.mark("beforeIOWrite");
81754                 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); });
81755                 ts.performance.mark("afterIOWrite");
81756                 ts.performance.measure("I/O Write", "beforeIOWrite", "afterIOWrite");
81757             }
81758             catch (e) {
81759                 if (onError) {
81760                     onError(e.message);
81761                 }
81762             }
81763         }
81764         var outputFingerprints;
81765         function writeFileWorker(fileName, data, writeByteOrderMark) {
81766             if (!ts.isWatchSet(options) || !system.createHash || !system.getModifiedTime) {
81767                 system.writeFile(fileName, data, writeByteOrderMark);
81768                 return;
81769             }
81770             if (!outputFingerprints) {
81771                 outputFingerprints = ts.createMap();
81772             }
81773             var hash = system.createHash(data);
81774             var mtimeBefore = system.getModifiedTime(fileName);
81775             if (mtimeBefore) {
81776                 var fingerprint = outputFingerprints.get(fileName);
81777                 if (fingerprint &&
81778                     fingerprint.byteOrderMark === writeByteOrderMark &&
81779                     fingerprint.hash === hash &&
81780                     fingerprint.mtime.getTime() === mtimeBefore.getTime()) {
81781                     return;
81782                 }
81783             }
81784             system.writeFile(fileName, data, writeByteOrderMark);
81785             var mtimeAfter = system.getModifiedTime(fileName) || ts.missingFileModifiedTime;
81786             outputFingerprints.set(fileName, {
81787                 hash: hash,
81788                 byteOrderMark: writeByteOrderMark,
81789                 mtime: mtimeAfter
81790             });
81791         }
81792         function getDefaultLibLocation() {
81793             return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath()));
81794         }
81795         var newLine = ts.getNewLineCharacter(options, function () { return system.newLine; });
81796         var realpath = system.realpath && (function (path) { return system.realpath(path); });
81797         var compilerHost = {
81798             getSourceFile: getSourceFile,
81799             getDefaultLibLocation: getDefaultLibLocation,
81800             getDefaultLibFileName: function (options) { return ts.combinePaths(getDefaultLibLocation(), ts.getDefaultLibFileName(options)); },
81801             writeFile: writeFile,
81802             getCurrentDirectory: ts.memoize(function () { return system.getCurrentDirectory(); }),
81803             useCaseSensitiveFileNames: function () { return system.useCaseSensitiveFileNames; },
81804             getCanonicalFileName: getCanonicalFileName,
81805             getNewLine: function () { return newLine; },
81806             fileExists: function (fileName) { return system.fileExists(fileName); },
81807             readFile: function (fileName) { return system.readFile(fileName); },
81808             trace: function (s) { return system.write(s + newLine); },
81809             directoryExists: function (directoryName) { return system.directoryExists(directoryName); },
81810             getEnvironmentVariable: function (name) { return system.getEnvironmentVariable ? system.getEnvironmentVariable(name) : ""; },
81811             getDirectories: function (path) { return system.getDirectories(path); },
81812             realpath: realpath,
81813             readDirectory: function (path, extensions, include, exclude, depth) { return system.readDirectory(path, extensions, include, exclude, depth); },
81814             createDirectory: function (d) { return system.createDirectory(d); },
81815             createHash: ts.maybeBind(system, system.createHash)
81816         };
81817         return compilerHost;
81818     }
81819     ts.createCompilerHostWorker = createCompilerHostWorker;
81820     function changeCompilerHostLikeToUseCache(host, toPath, getSourceFile) {
81821         var originalReadFile = host.readFile;
81822         var originalFileExists = host.fileExists;
81823         var originalDirectoryExists = host.directoryExists;
81824         var originalCreateDirectory = host.createDirectory;
81825         var originalWriteFile = host.writeFile;
81826         var readFileCache = ts.createMap();
81827         var fileExistsCache = ts.createMap();
81828         var directoryExistsCache = ts.createMap();
81829         var sourceFileCache = ts.createMap();
81830         var readFileWithCache = function (fileName) {
81831             var key = toPath(fileName);
81832             var value = readFileCache.get(key);
81833             if (value !== undefined)
81834                 return value !== false ? value : undefined;
81835             return setReadFileCache(key, fileName);
81836         };
81837         var setReadFileCache = function (key, fileName) {
81838             var newValue = originalReadFile.call(host, fileName);
81839             readFileCache.set(key, newValue !== undefined ? newValue : false);
81840             return newValue;
81841         };
81842         host.readFile = function (fileName) {
81843             var key = toPath(fileName);
81844             var value = readFileCache.get(key);
81845             if (value !== undefined)
81846                 return value !== false ? value : undefined;
81847             if (!ts.fileExtensionIs(fileName, ".json") && !ts.isBuildInfoFile(fileName)) {
81848                 return originalReadFile.call(host, fileName);
81849             }
81850             return setReadFileCache(key, fileName);
81851         };
81852         var getSourceFileWithCache = getSourceFile ? function (fileName, languageVersion, onError, shouldCreateNewSourceFile) {
81853             var key = toPath(fileName);
81854             var value = sourceFileCache.get(key);
81855             if (value)
81856                 return value;
81857             var sourceFile = getSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile);
81858             if (sourceFile && (ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json"))) {
81859                 sourceFileCache.set(key, sourceFile);
81860             }
81861             return sourceFile;
81862         } : undefined;
81863         host.fileExists = function (fileName) {
81864             var key = toPath(fileName);
81865             var value = fileExistsCache.get(key);
81866             if (value !== undefined)
81867                 return value;
81868             var newValue = originalFileExists.call(host, fileName);
81869             fileExistsCache.set(key, !!newValue);
81870             return newValue;
81871         };
81872         if (originalWriteFile) {
81873             host.writeFile = function (fileName, data, writeByteOrderMark, onError, sourceFiles) {
81874                 var key = toPath(fileName);
81875                 fileExistsCache.delete(key);
81876                 var value = readFileCache.get(key);
81877                 if (value !== undefined && value !== data) {
81878                     readFileCache.delete(key);
81879                     sourceFileCache.delete(key);
81880                 }
81881                 else if (getSourceFileWithCache) {
81882                     var sourceFile = sourceFileCache.get(key);
81883                     if (sourceFile && sourceFile.text !== data) {
81884                         sourceFileCache.delete(key);
81885                     }
81886                 }
81887                 originalWriteFile.call(host, fileName, data, writeByteOrderMark, onError, sourceFiles);
81888             };
81889         }
81890         if (originalDirectoryExists && originalCreateDirectory) {
81891             host.directoryExists = function (directory) {
81892                 var key = toPath(directory);
81893                 var value = directoryExistsCache.get(key);
81894                 if (value !== undefined)
81895                     return value;
81896                 var newValue = originalDirectoryExists.call(host, directory);
81897                 directoryExistsCache.set(key, !!newValue);
81898                 return newValue;
81899             };
81900             host.createDirectory = function (directory) {
81901                 var key = toPath(directory);
81902                 directoryExistsCache.delete(key);
81903                 originalCreateDirectory.call(host, directory);
81904             };
81905         }
81906         return {
81907             originalReadFile: originalReadFile,
81908             originalFileExists: originalFileExists,
81909             originalDirectoryExists: originalDirectoryExists,
81910             originalCreateDirectory: originalCreateDirectory,
81911             originalWriteFile: originalWriteFile,
81912             getSourceFileWithCache: getSourceFileWithCache,
81913             readFileWithCache: readFileWithCache
81914         };
81915     }
81916     ts.changeCompilerHostLikeToUseCache = changeCompilerHostLikeToUseCache;
81917     function getPreEmitDiagnostics(program, sourceFile, cancellationToken) {
81918         var diagnostics;
81919         diagnostics = ts.addRange(diagnostics, program.getConfigFileParsingDiagnostics());
81920         diagnostics = ts.addRange(diagnostics, program.getOptionsDiagnostics(cancellationToken));
81921         diagnostics = ts.addRange(diagnostics, program.getSyntacticDiagnostics(sourceFile, cancellationToken));
81922         diagnostics = ts.addRange(diagnostics, program.getGlobalDiagnostics(cancellationToken));
81923         diagnostics = ts.addRange(diagnostics, program.getSemanticDiagnostics(sourceFile, cancellationToken));
81924         if (ts.getEmitDeclarations(program.getCompilerOptions())) {
81925             diagnostics = ts.addRange(diagnostics, program.getDeclarationDiagnostics(sourceFile, cancellationToken));
81926         }
81927         return ts.sortAndDeduplicateDiagnostics(diagnostics || ts.emptyArray);
81928     }
81929     ts.getPreEmitDiagnostics = getPreEmitDiagnostics;
81930     function formatDiagnostics(diagnostics, host) {
81931         var output = "";
81932         for (var _i = 0, diagnostics_2 = diagnostics; _i < diagnostics_2.length; _i++) {
81933             var diagnostic = diagnostics_2[_i];
81934             output += formatDiagnostic(diagnostic, host);
81935         }
81936         return output;
81937     }
81938     ts.formatDiagnostics = formatDiagnostics;
81939     function formatDiagnostic(diagnostic, host) {
81940         var errorMessage = ts.diagnosticCategoryName(diagnostic) + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) + host.getNewLine();
81941         if (diagnostic.file) {
81942             var _a = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start), line = _a.line, character = _a.character;
81943             var fileName = diagnostic.file.fileName;
81944             var relativeFileName = ts.convertToRelativePath(fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); });
81945             return relativeFileName + "(" + (line + 1) + "," + (character + 1) + "): " + errorMessage;
81946         }
81947         return errorMessage;
81948     }
81949     ts.formatDiagnostic = formatDiagnostic;
81950     var ForegroundColorEscapeSequences;
81951     (function (ForegroundColorEscapeSequences) {
81952         ForegroundColorEscapeSequences["Grey"] = "\u001B[90m";
81953         ForegroundColorEscapeSequences["Red"] = "\u001B[91m";
81954         ForegroundColorEscapeSequences["Yellow"] = "\u001B[93m";
81955         ForegroundColorEscapeSequences["Blue"] = "\u001B[94m";
81956         ForegroundColorEscapeSequences["Cyan"] = "\u001B[96m";
81957     })(ForegroundColorEscapeSequences = ts.ForegroundColorEscapeSequences || (ts.ForegroundColorEscapeSequences = {}));
81958     var gutterStyleSequence = "\u001b[7m";
81959     var gutterSeparator = " ";
81960     var resetEscapeSequence = "\u001b[0m";
81961     var ellipsis = "...";
81962     var halfIndent = "  ";
81963     var indent = "    ";
81964     function getCategoryFormat(category) {
81965         switch (category) {
81966             case ts.DiagnosticCategory.Error: return ForegroundColorEscapeSequences.Red;
81967             case ts.DiagnosticCategory.Warning: return ForegroundColorEscapeSequences.Yellow;
81968             case ts.DiagnosticCategory.Suggestion: return ts.Debug.fail("Should never get an Info diagnostic on the command line.");
81969             case ts.DiagnosticCategory.Message: return ForegroundColorEscapeSequences.Blue;
81970         }
81971     }
81972     function formatColorAndReset(text, formatStyle) {
81973         return formatStyle + text + resetEscapeSequence;
81974     }
81975     ts.formatColorAndReset = formatColorAndReset;
81976     function formatCodeSpan(file, start, length, indent, squiggleColor, host) {
81977         var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character;
81978         var _b = ts.getLineAndCharacterOfPosition(file, start + length), lastLine = _b.line, lastLineChar = _b.character;
81979         var lastLineInFile = ts.getLineAndCharacterOfPosition(file, file.text.length).line;
81980         var hasMoreThanFiveLines = (lastLine - firstLine) >= 4;
81981         var gutterWidth = (lastLine + 1 + "").length;
81982         if (hasMoreThanFiveLines) {
81983             gutterWidth = Math.max(ellipsis.length, gutterWidth);
81984         }
81985         var context = "";
81986         for (var i = firstLine; i <= lastLine; i++) {
81987             context += host.getNewLine();
81988             if (hasMoreThanFiveLines && firstLine + 1 < i && i < lastLine - 1) {
81989                 context += indent + formatColorAndReset(ts.padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + host.getNewLine();
81990                 i = lastLine - 1;
81991             }
81992             var lineStart = ts.getPositionOfLineAndCharacter(file, i, 0);
81993             var lineEnd = i < lastLineInFile ? ts.getPositionOfLineAndCharacter(file, i + 1, 0) : file.text.length;
81994             var lineContent = file.text.slice(lineStart, lineEnd);
81995             lineContent = lineContent.replace(/\s+$/g, "");
81996             lineContent = lineContent.replace("\t", " ");
81997             context += indent + formatColorAndReset(ts.padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator;
81998             context += lineContent + host.getNewLine();
81999             context += indent + formatColorAndReset(ts.padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator;
82000             context += squiggleColor;
82001             if (i === firstLine) {
82002                 var lastCharForLine = i === lastLine ? lastLineChar : undefined;
82003                 context += lineContent.slice(0, firstLineChar).replace(/\S/g, " ");
82004                 context += lineContent.slice(firstLineChar, lastCharForLine).replace(/./g, "~");
82005             }
82006             else if (i === lastLine) {
82007                 context += lineContent.slice(0, lastLineChar).replace(/./g, "~");
82008             }
82009             else {
82010                 context += lineContent.replace(/./g, "~");
82011             }
82012             context += resetEscapeSequence;
82013         }
82014         return context;
82015     }
82016     function formatLocation(file, start, host, color) {
82017         if (color === void 0) { color = formatColorAndReset; }
82018         var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character;
82019         var relativeFileName = host ? ts.convertToRelativePath(file.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) : file.fileName;
82020         var output = "";
82021         output += color(relativeFileName, ForegroundColorEscapeSequences.Cyan);
82022         output += ":";
82023         output += color("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow);
82024         output += ":";
82025         output += color("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow);
82026         return output;
82027     }
82028     ts.formatLocation = formatLocation;
82029     function formatDiagnosticsWithColorAndContext(diagnostics, host) {
82030         var output = "";
82031         for (var _i = 0, diagnostics_3 = diagnostics; _i < diagnostics_3.length; _i++) {
82032             var diagnostic = diagnostics_3[_i];
82033             if (diagnostic.file) {
82034                 var file = diagnostic.file, start = diagnostic.start;
82035                 output += formatLocation(file, start, host);
82036                 output += " - ";
82037             }
82038             output += formatColorAndReset(ts.diagnosticCategoryName(diagnostic), getCategoryFormat(diagnostic.category));
82039             output += formatColorAndReset(" TS" + diagnostic.code + ": ", ForegroundColorEscapeSequences.Grey);
82040             output += flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine());
82041             if (diagnostic.file) {
82042                 output += host.getNewLine();
82043                 output += formatCodeSpan(diagnostic.file, diagnostic.start, diagnostic.length, "", getCategoryFormat(diagnostic.category), host);
82044                 if (diagnostic.relatedInformation) {
82045                     output += host.getNewLine();
82046                     for (var _a = 0, _b = diagnostic.relatedInformation; _a < _b.length; _a++) {
82047                         var _c = _b[_a], file = _c.file, start = _c.start, length_8 = _c.length, messageText = _c.messageText;
82048                         if (file) {
82049                             output += host.getNewLine();
82050                             output += halfIndent + formatLocation(file, start, host);
82051                             output += formatCodeSpan(file, start, length_8, indent, ForegroundColorEscapeSequences.Cyan, host);
82052                         }
82053                         output += host.getNewLine();
82054                         output += indent + flattenDiagnosticMessageText(messageText, host.getNewLine());
82055                     }
82056                 }
82057             }
82058             output += host.getNewLine();
82059         }
82060         return output;
82061     }
82062     ts.formatDiagnosticsWithColorAndContext = formatDiagnosticsWithColorAndContext;
82063     function flattenDiagnosticMessageText(diag, newLine, indent) {
82064         if (indent === void 0) { indent = 0; }
82065         if (ts.isString(diag)) {
82066             return diag;
82067         }
82068         else if (diag === undefined) {
82069             return "";
82070         }
82071         var result = "";
82072         if (indent) {
82073             result += newLine;
82074             for (var i = 0; i < indent; i++) {
82075                 result += "  ";
82076             }
82077         }
82078         result += diag.messageText;
82079         indent++;
82080         if (diag.next) {
82081             for (var _i = 0, _a = diag.next; _i < _a.length; _i++) {
82082                 var kid = _a[_i];
82083                 result += flattenDiagnosticMessageText(kid, newLine, indent);
82084             }
82085         }
82086         return result;
82087     }
82088     ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText;
82089     function loadWithLocalCache(names, containingFile, redirectedReference, loader) {
82090         if (names.length === 0) {
82091             return [];
82092         }
82093         var resolutions = [];
82094         var cache = ts.createMap();
82095         for (var _i = 0, names_2 = names; _i < names_2.length; _i++) {
82096             var name = names_2[_i];
82097             var result = void 0;
82098             if (cache.has(name)) {
82099                 result = cache.get(name);
82100             }
82101             else {
82102                 cache.set(name, result = loader(name, containingFile, redirectedReference));
82103             }
82104             resolutions.push(result);
82105         }
82106         return resolutions;
82107     }
82108     ts.loadWithLocalCache = loadWithLocalCache;
82109     ts.inferredTypesContainingFile = "__inferred type names__.ts";
82110     function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, projectReferences) {
82111         if (!program || hasChangedAutomaticTypeDirectiveNames) {
82112             return false;
82113         }
82114         if (!ts.arrayIsEqualTo(program.getRootFileNames(), rootFileNames)) {
82115             return false;
82116         }
82117         var seenResolvedRefs;
82118         if (!ts.arrayIsEqualTo(program.getProjectReferences(), projectReferences, projectReferenceUptoDate)) {
82119             return false;
82120         }
82121         if (program.getSourceFiles().some(sourceFileNotUptoDate)) {
82122             return false;
82123         }
82124         if (program.getMissingFilePaths().some(fileExists)) {
82125             return false;
82126         }
82127         var currentOptions = program.getCompilerOptions();
82128         if (!ts.compareDataObjects(currentOptions, newOptions)) {
82129             return false;
82130         }
82131         if (currentOptions.configFile && newOptions.configFile) {
82132             return currentOptions.configFile.text === newOptions.configFile.text;
82133         }
82134         return true;
82135         function sourceFileNotUptoDate(sourceFile) {
82136             return !sourceFileVersionUptoDate(sourceFile) ||
82137                 hasInvalidatedResolution(sourceFile.path);
82138         }
82139         function sourceFileVersionUptoDate(sourceFile) {
82140             return sourceFile.version === getSourceVersion(sourceFile.resolvedPath, sourceFile.fileName);
82141         }
82142         function projectReferenceUptoDate(oldRef, newRef, index) {
82143             if (!ts.projectReferenceIsEqualTo(oldRef, newRef)) {
82144                 return false;
82145             }
82146             return resolvedProjectReferenceUptoDate(program.getResolvedProjectReferences()[index], oldRef);
82147         }
82148         function resolvedProjectReferenceUptoDate(oldResolvedRef, oldRef) {
82149             if (oldResolvedRef) {
82150                 if (ts.contains(seenResolvedRefs, oldResolvedRef)) {
82151                     return true;
82152                 }
82153                 if (!sourceFileVersionUptoDate(oldResolvedRef.sourceFile)) {
82154                     return false;
82155                 }
82156                 (seenResolvedRefs || (seenResolvedRefs = [])).push(oldResolvedRef);
82157                 return !ts.forEach(oldResolvedRef.references, function (childResolvedRef, index) {
82158                     return !resolvedProjectReferenceUptoDate(childResolvedRef, oldResolvedRef.commandLine.projectReferences[index]);
82159                 });
82160             }
82161             return !fileExists(resolveProjectReferencePath(oldRef));
82162         }
82163     }
82164     ts.isProgramUptoDate = isProgramUptoDate;
82165     function getConfigFileParsingDiagnostics(configFileParseResult) {
82166         return configFileParseResult.options.configFile ? __spreadArrays(configFileParseResult.options.configFile.parseDiagnostics, configFileParseResult.errors) :
82167             configFileParseResult.errors;
82168     }
82169     ts.getConfigFileParsingDiagnostics = getConfigFileParsingDiagnostics;
82170     function shouldProgramCreateNewSourceFiles(program, newOptions) {
82171         if (!program)
82172             return false;
82173         var oldOptions = program.getCompilerOptions();
82174         return !!ts.sourceFileAffectingCompilerOptions.some(function (option) {
82175             return !ts.isJsonEqual(ts.getCompilerOptionValue(oldOptions, option), ts.getCompilerOptionValue(newOptions, option));
82176         });
82177     }
82178     function createCreateProgramOptions(rootNames, options, host, oldProgram, configFileParsingDiagnostics) {
82179         return {
82180             rootNames: rootNames,
82181             options: options,
82182             host: host,
82183             oldProgram: oldProgram,
82184             configFileParsingDiagnostics: configFileParsingDiagnostics
82185         };
82186     }
82187     function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) {
82188         var _a;
82189         var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions;
82190         var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences;
82191         var oldProgram = createProgramOptions.oldProgram;
82192         var processingDefaultLibFiles;
82193         var processingOtherFiles;
82194         var files;
82195         var symlinks;
82196         var commonSourceDirectory;
82197         var diagnosticsProducingTypeChecker;
82198         var noDiagnosticsTypeChecker;
82199         var classifiableNames;
82200         var ambientModuleNameToUnmodifiedFileName = ts.createMap();
82201         var refFileMap;
82202         var cachedBindAndCheckDiagnosticsForFile = {};
82203         var cachedDeclarationDiagnosticsForFile = {};
82204         var resolvedTypeReferenceDirectives = ts.createMap();
82205         var fileProcessingDiagnostics = ts.createDiagnosticCollection();
82206         var maxNodeModuleJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0;
82207         var currentNodeModulesDepth = 0;
82208         var modulesWithElidedImports = ts.createMap();
82209         var sourceFilesFoundSearchingNodeModules = ts.createMap();
82210         ts.performance.mark("beforeProgram");
82211         var host = createProgramOptions.host || createCompilerHost(options);
82212         var configParsingHost = parseConfigHostFromCompilerHostLike(host);
82213         var skipDefaultLib = options.noLib;
82214         var getDefaultLibraryFileName = ts.memoize(function () { return host.getDefaultLibFileName(options); });
82215         var defaultLibraryPath = host.getDefaultLibLocation ? host.getDefaultLibLocation() : ts.getDirectoryPath(getDefaultLibraryFileName());
82216         var programDiagnostics = ts.createDiagnosticCollection();
82217         var currentDirectory = host.getCurrentDirectory();
82218         var supportedExtensions = ts.getSupportedExtensions(options);
82219         var supportedExtensionsWithJsonIfResolveJsonModule = ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions);
82220         var hasEmitBlockingDiagnostics = ts.createMap();
82221         var _compilerOptionsObjectLiteralSyntax;
82222         var moduleResolutionCache;
82223         var actualResolveModuleNamesWorker;
82224         var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
82225         if (host.resolveModuleNames) {
82226             actualResolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.checkEachDefined(moduleNames), containingFile, reusedNames, redirectedReference, options).map(function (resolved) {
82227                 if (!resolved || resolved.extension !== undefined) {
82228                     return resolved;
82229                 }
82230                 var withExtension = ts.clone(resolved);
82231                 withExtension.extension = ts.extensionFromPath(resolved.resolvedFileName);
82232                 return withExtension;
82233             }); };
82234         }
82235         else {
82236             moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }, options);
82237             var loader_1 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache, redirectedReference).resolvedModule; };
82238             actualResolveModuleNamesWorker = function (moduleNames, containingFile, _reusedNames, redirectedReference) { return loadWithLocalCache(ts.Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader_1); };
82239         }
82240         var actualResolveTypeReferenceDirectiveNamesWorker;
82241         if (host.resolveTypeReferenceDirectives) {
82242             actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); };
82243         }
82244         else {
82245             var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference).resolvedTypeReferenceDirective; };
82246             actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { return loadWithLocalCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader_2); };
82247         }
82248         var packageIdToSourceFile = ts.createMap();
82249         var sourceFileToPackageName = ts.createMap();
82250         var redirectTargetsMap = ts.createMultiMap();
82251         var filesByName = ts.createMap();
82252         var missingFilePaths;
82253         var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createMap() : undefined;
82254         var resolvedProjectReferences;
82255         var projectReferenceRedirects;
82256         var mapFromFileToProjectReferenceRedirects;
82257         var mapFromToProjectReferenceRedirectSource;
82258         var useSourceOfProjectReferenceRedirect = !!((_a = host.useSourceOfProjectReferenceRedirect) === null || _a === void 0 ? void 0 : _a.call(host)) &&
82259             !options.disableSourceOfProjectReferenceRedirect;
82260         var _b = updateHostForUseSourceOfProjectReferenceRedirect({
82261             compilerHost: host,
82262             useSourceOfProjectReferenceRedirect: useSourceOfProjectReferenceRedirect,
82263             toPath: toPath,
82264             getResolvedProjectReferences: getResolvedProjectReferences,
82265             getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect,
82266             forEachResolvedProjectReference: forEachResolvedProjectReference
82267         }), onProgramCreateComplete = _b.onProgramCreateComplete, fileExists = _b.fileExists;
82268         var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
82269         var structuralIsReused;
82270         structuralIsReused = tryReuseStructureFromOldProgram();
82271         if (structuralIsReused !== 2) {
82272             processingDefaultLibFiles = [];
82273             processingOtherFiles = [];
82274             if (projectReferences) {
82275                 if (!resolvedProjectReferences) {
82276                     resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile);
82277                 }
82278                 if (rootNames.length) {
82279                     for (var _i = 0, resolvedProjectReferences_1 = resolvedProjectReferences; _i < resolvedProjectReferences_1.length; _i++) {
82280                         var parsedRef = resolvedProjectReferences_1[_i];
82281                         if (!parsedRef)
82282                             continue;
82283                         var out = parsedRef.commandLine.options.outFile || parsedRef.commandLine.options.out;
82284                         if (useSourceOfProjectReferenceRedirect) {
82285                             if (out || ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) {
82286                                 for (var _c = 0, _d = parsedRef.commandLine.fileNames; _c < _d.length; _c++) {
82287                                     var fileName = _d[_c];
82288                                     processSourceFile(fileName, false, false, undefined);
82289                                 }
82290                             }
82291                         }
82292                         else {
82293                             if (out) {
82294                                 processSourceFile(ts.changeExtension(out, ".d.ts"), false, false, undefined);
82295                             }
82296                             else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) {
82297                                 for (var _e = 0, _f = parsedRef.commandLine.fileNames; _e < _f.length; _e++) {
82298                                     var fileName = _f[_e];
82299                                     if (!ts.fileExtensionIs(fileName, ".d.ts") && !ts.fileExtensionIs(fileName, ".json")) {
82300                                         processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), false, false, undefined);
82301                                     }
82302                                 }
82303                             }
82304                         }
82305                     }
82306                 }
82307             }
82308             ts.forEach(rootNames, function (name) { return processRootFile(name, false, false); });
82309             var typeReferences = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray;
82310             if (typeReferences.length) {
82311                 var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory();
82312                 var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
82313                 var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
82314                 for (var i = 0; i < typeReferences.length; i++) {
82315                     processTypeReferenceDirective(typeReferences[i], resolutions[i]);
82316                 }
82317             }
82318             if (rootNames.length && !skipDefaultLib) {
82319                 var defaultLibraryFileName = getDefaultLibraryFileName();
82320                 if (!options.lib && defaultLibraryFileName) {
82321                     processRootFile(defaultLibraryFileName, true, false);
82322                 }
82323                 else {
82324                     ts.forEach(options.lib, function (libFileName) {
82325                         processRootFile(ts.combinePaths(defaultLibraryPath, libFileName), true, false);
82326                     });
82327                 }
82328             }
82329             missingFilePaths = ts.arrayFrom(ts.mapDefinedIterator(filesByName.entries(), function (_a) {
82330                 var path = _a[0], file = _a[1];
82331                 return file === undefined ? path : undefined;
82332             }));
82333             files = ts.stableSort(processingDefaultLibFiles, compareDefaultLibFiles).concat(processingOtherFiles);
82334             processingDefaultLibFiles = undefined;
82335             processingOtherFiles = undefined;
82336         }
82337         ts.Debug.assert(!!missingFilePaths);
82338         if (oldProgram && host.onReleaseOldSourceFile) {
82339             var oldSourceFiles = oldProgram.getSourceFiles();
82340             for (var _g = 0, oldSourceFiles_1 = oldSourceFiles; _g < oldSourceFiles_1.length; _g++) {
82341                 var oldSourceFile = oldSourceFiles_1[_g];
82342                 var newFile = getSourceFileByPath(oldSourceFile.resolvedPath);
82343                 if (shouldCreateNewSourceFile || !newFile ||
82344                     (oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) {
82345                     host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path));
82346                 }
82347             }
82348             oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference, resolvedProjectReferencePath) {
82349                 if (resolvedProjectReference && !getResolvedProjectReferenceByPath(resolvedProjectReferencePath)) {
82350                     host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions(), false);
82351                 }
82352             });
82353         }
82354         oldProgram = undefined;
82355         var program = {
82356             getRootFileNames: function () { return rootNames; },
82357             getSourceFile: getSourceFile,
82358             getSourceFileByPath: getSourceFileByPath,
82359             getSourceFiles: function () { return files; },
82360             getMissingFilePaths: function () { return missingFilePaths; },
82361             getRefFileMap: function () { return refFileMap; },
82362             getFilesByNameMap: function () { return filesByName; },
82363             getCompilerOptions: function () { return options; },
82364             getSyntacticDiagnostics: getSyntacticDiagnostics,
82365             getOptionsDiagnostics: getOptionsDiagnostics,
82366             getGlobalDiagnostics: getGlobalDiagnostics,
82367             getSemanticDiagnostics: getSemanticDiagnostics,
82368             getSuggestionDiagnostics: getSuggestionDiagnostics,
82369             getDeclarationDiagnostics: getDeclarationDiagnostics,
82370             getBindAndCheckDiagnostics: getBindAndCheckDiagnostics,
82371             getProgramDiagnostics: getProgramDiagnostics,
82372             getTypeChecker: getTypeChecker,
82373             getClassifiableNames: getClassifiableNames,
82374             getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker,
82375             getCommonSourceDirectory: getCommonSourceDirectory,
82376             emit: emit,
82377             getCurrentDirectory: function () { return currentDirectory; },
82378             getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); },
82379             getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); },
82380             getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); },
82381             getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); },
82382             getInstantiationCount: function () { return getDiagnosticsProducingTypeChecker().getInstantiationCount(); },
82383             getRelationCacheSizes: function () { return getDiagnosticsProducingTypeChecker().getRelationCacheSizes(); },
82384             getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; },
82385             getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; },
82386             isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary,
82387             isSourceFileDefaultLibrary: isSourceFileDefaultLibrary,
82388             dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker,
82389             getSourceFileFromReference: getSourceFileFromReference,
82390             getLibFileFromReference: getLibFileFromReference,
82391             sourceFileToPackageName: sourceFileToPackageName,
82392             redirectTargetsMap: redirectTargetsMap,
82393             isEmittedFile: isEmittedFile,
82394             getConfigFileParsingDiagnostics: getConfigFileParsingDiagnostics,
82395             getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
82396             getProjectReferences: getProjectReferences,
82397             getResolvedProjectReferences: getResolvedProjectReferences,
82398             getProjectReferenceRedirect: getProjectReferenceRedirect,
82399             getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect,
82400             getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath,
82401             forEachResolvedProjectReference: forEachResolvedProjectReference,
82402             isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
82403             emitBuildInfo: emitBuildInfo,
82404             fileExists: fileExists,
82405             getProbableSymlinks: getProbableSymlinks,
82406             useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
82407         };
82408         onProgramCreateComplete();
82409         verifyCompilerOptions();
82410         ts.performance.mark("afterProgram");
82411         ts.performance.measure("Program", "beforeProgram", "afterProgram");
82412         return program;
82413         function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames, redirectedReference) {
82414             ts.performance.mark("beforeResolveModule");
82415             var result = actualResolveModuleNamesWorker(moduleNames, containingFile, reusedNames, redirectedReference);
82416             ts.performance.mark("afterResolveModule");
82417             ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
82418             return result;
82419         }
82420         function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, redirectedReference) {
82421             ts.performance.mark("beforeResolveTypeReference");
82422             var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, redirectedReference);
82423             ts.performance.mark("afterResolveTypeReference");
82424             ts.performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference");
82425             return result;
82426         }
82427         function compareDefaultLibFiles(a, b) {
82428             return ts.compareValues(getDefaultLibFilePriority(a), getDefaultLibFilePriority(b));
82429         }
82430         function getDefaultLibFilePriority(a) {
82431             if (ts.containsPath(defaultLibraryPath, a.fileName, false)) {
82432                 var basename = ts.getBaseFileName(a.fileName);
82433                 if (basename === "lib.d.ts" || basename === "lib.es6.d.ts")
82434                     return 0;
82435                 var name = ts.removeSuffix(ts.removePrefix(basename, "lib."), ".d.ts");
82436                 var index = ts.libs.indexOf(name);
82437                 if (index !== -1)
82438                     return index + 1;
82439             }
82440             return ts.libs.length + 2;
82441         }
82442         function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile) {
82443             return moduleResolutionCache && ts.resolveModuleNameFromCache(moduleName, containingFile, moduleResolutionCache);
82444         }
82445         function toPath(fileName) {
82446             return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
82447         }
82448         function getCommonSourceDirectory() {
82449             if (commonSourceDirectory === undefined) {
82450                 var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, program); });
82451                 if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) {
82452                     commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory);
82453                 }
82454                 else if (options.composite && options.configFilePath) {
82455                     commonSourceDirectory = ts.getDirectoryPath(ts.normalizeSlashes(options.configFilePath));
82456                     checkSourceFilesBelongToPath(emittedFiles, commonSourceDirectory);
82457                 }
82458                 else {
82459                     commonSourceDirectory = computeCommonSourceDirectory(emittedFiles);
82460                 }
82461                 if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== ts.directorySeparator) {
82462                     commonSourceDirectory += ts.directorySeparator;
82463                 }
82464             }
82465             return commonSourceDirectory;
82466         }
82467         function getClassifiableNames() {
82468             if (!classifiableNames) {
82469                 getTypeChecker();
82470                 classifiableNames = ts.createUnderscoreEscapedMap();
82471                 for (var _i = 0, files_2 = files; _i < files_2.length; _i++) {
82472                     var sourceFile = files_2[_i];
82473                     ts.copyEntries(sourceFile.classifiableNames, classifiableNames);
82474                 }
82475             }
82476             return classifiableNames;
82477         }
82478         function resolveModuleNamesReusingOldState(moduleNames, containingFile, file) {
82479             if (structuralIsReused === 0 && !file.ambientModuleNames.length) {
82480                 return resolveModuleNamesWorker(moduleNames, containingFile, undefined, getResolvedProjectReferenceToRedirect(file.originalFileName));
82481             }
82482             var oldSourceFile = oldProgram && oldProgram.getSourceFile(containingFile);
82483             if (oldSourceFile !== file && file.resolvedModules) {
82484                 var result_11 = [];
82485                 for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) {
82486                     var moduleName = moduleNames_1[_i];
82487                     var resolvedModule = file.resolvedModules.get(moduleName);
82488                     result_11.push(resolvedModule);
82489                 }
82490                 return result_11;
82491             }
82492             var unknownModuleNames;
82493             var result;
82494             var reusedNames;
82495             var predictedToResolveToAmbientModuleMarker = {};
82496             for (var i = 0; i < moduleNames.length; i++) {
82497                 var moduleName = moduleNames[i];
82498                 if (file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) {
82499                     var oldResolvedModule = oldSourceFile && oldSourceFile.resolvedModules.get(moduleName);
82500                     if (oldResolvedModule) {
82501                         if (ts.isTraceEnabled(options, host)) {
82502                             ts.trace(host, ts.Diagnostics.Reusing_resolution_of_module_0_to_file_1_from_old_program, moduleName, containingFile);
82503                         }
82504                         (result || (result = new Array(moduleNames.length)))[i] = oldResolvedModule;
82505                         (reusedNames || (reusedNames = [])).push(moduleName);
82506                         continue;
82507                     }
82508                 }
82509                 var resolvesToAmbientModuleInNonModifiedFile = false;
82510                 if (ts.contains(file.ambientModuleNames, moduleName)) {
82511                     resolvesToAmbientModuleInNonModifiedFile = true;
82512                     if (ts.isTraceEnabled(options, host)) {
82513                         ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1, moduleName, containingFile);
82514                     }
82515                 }
82516                 else {
82517                     resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName);
82518                 }
82519                 if (resolvesToAmbientModuleInNonModifiedFile) {
82520                     (result || (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker;
82521                 }
82522                 else {
82523                     (unknownModuleNames || (unknownModuleNames = [])).push(moduleName);
82524                 }
82525             }
82526             var resolutions = unknownModuleNames && unknownModuleNames.length
82527                 ? resolveModuleNamesWorker(unknownModuleNames, containingFile, reusedNames, getResolvedProjectReferenceToRedirect(file.originalFileName))
82528                 : ts.emptyArray;
82529             if (!result) {
82530                 ts.Debug.assert(resolutions.length === moduleNames.length);
82531                 return resolutions;
82532             }
82533             var j = 0;
82534             for (var i = 0; i < result.length; i++) {
82535                 if (result[i]) {
82536                     if (result[i] === predictedToResolveToAmbientModuleMarker) {
82537                         result[i] = undefined;
82538                     }
82539                 }
82540                 else {
82541                     result[i] = resolutions[j];
82542                     j++;
82543                 }
82544             }
82545             ts.Debug.assert(j === resolutions.length);
82546             return result;
82547             function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName) {
82548                 var resolutionToFile = ts.getResolvedModule(oldSourceFile, moduleName);
82549                 var resolvedFile = resolutionToFile && oldProgram.getSourceFile(resolutionToFile.resolvedFileName);
82550                 if (resolutionToFile && resolvedFile) {
82551                     return false;
82552                 }
82553                 var unmodifiedFile = ambientModuleNameToUnmodifiedFileName.get(moduleName);
82554                 if (!unmodifiedFile) {
82555                     return false;
82556                 }
82557                 if (ts.isTraceEnabled(options, host)) {
82558                     ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName, unmodifiedFile);
82559                 }
82560                 return true;
82561             }
82562         }
82563         function canReuseProjectReferences() {
82564             return !forEachProjectReference(oldProgram.getProjectReferences(), oldProgram.getResolvedProjectReferences(), function (oldResolvedRef, index, parent) {
82565                 var newRef = (parent ? parent.commandLine.projectReferences : projectReferences)[index];
82566                 var newResolvedRef = parseProjectReferenceConfigFile(newRef);
82567                 if (oldResolvedRef) {
82568                     return !newResolvedRef || newResolvedRef.sourceFile !== oldResolvedRef.sourceFile;
82569                 }
82570                 else {
82571                     return newResolvedRef !== undefined;
82572                 }
82573             }, function (oldProjectReferences, parent) {
82574                 var newReferences = parent ? getResolvedProjectReferenceByPath(parent.sourceFile.path).commandLine.projectReferences : projectReferences;
82575                 return !ts.arrayIsEqualTo(oldProjectReferences, newReferences, ts.projectReferenceIsEqualTo);
82576             });
82577         }
82578         function tryReuseStructureFromOldProgram() {
82579             if (!oldProgram) {
82580                 return 0;
82581             }
82582             var oldOptions = oldProgram.getCompilerOptions();
82583             if (ts.changesAffectModuleResolution(oldOptions, options)) {
82584                 return oldProgram.structureIsReused = 0;
82585             }
82586             ts.Debug.assert(!(oldProgram.structureIsReused & (2 | 1)));
82587             var oldRootNames = oldProgram.getRootFileNames();
82588             if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) {
82589                 return oldProgram.structureIsReused = 0;
82590             }
82591             if (!ts.arrayIsEqualTo(options.types, oldOptions.types)) {
82592                 return oldProgram.structureIsReused = 0;
82593             }
82594             if (!canReuseProjectReferences()) {
82595                 return oldProgram.structureIsReused = 0;
82596             }
82597             if (projectReferences) {
82598                 resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile);
82599             }
82600             var newSourceFiles = [];
82601             var modifiedSourceFiles = [];
82602             oldProgram.structureIsReused = 2;
82603             if (oldProgram.getMissingFilePaths().some(function (missingFilePath) { return host.fileExists(missingFilePath); })) {
82604                 return oldProgram.structureIsReused = 0;
82605             }
82606             var oldSourceFiles = oldProgram.getSourceFiles();
82607             var seenPackageNames = ts.createMap();
82608             for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) {
82609                 var oldSourceFile = oldSourceFiles_2[_i];
82610                 var newSourceFile = host.getSourceFileByPath
82611                     ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, options.target, undefined, shouldCreateNewSourceFile)
82612                     : host.getSourceFile(oldSourceFile.fileName, options.target, undefined, shouldCreateNewSourceFile);
82613                 if (!newSourceFile) {
82614                     return oldProgram.structureIsReused = 0;
82615                 }
82616                 ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`");
82617                 var fileChanged = void 0;
82618                 if (oldSourceFile.redirectInfo) {
82619                     if (newSourceFile !== oldSourceFile.redirectInfo.unredirected) {
82620                         return oldProgram.structureIsReused = 0;
82621                     }
82622                     fileChanged = false;
82623                     newSourceFile = oldSourceFile;
82624                 }
82625                 else if (oldProgram.redirectTargetsMap.has(oldSourceFile.path)) {
82626                     if (newSourceFile !== oldSourceFile) {
82627                         return oldProgram.structureIsReused = 0;
82628                     }
82629                     fileChanged = false;
82630                 }
82631                 else {
82632                     fileChanged = newSourceFile !== oldSourceFile;
82633                 }
82634                 newSourceFile.path = oldSourceFile.path;
82635                 newSourceFile.originalFileName = oldSourceFile.originalFileName;
82636                 newSourceFile.resolvedPath = oldSourceFile.resolvedPath;
82637                 newSourceFile.fileName = oldSourceFile.fileName;
82638                 var packageName = oldProgram.sourceFileToPackageName.get(oldSourceFile.path);
82639                 if (packageName !== undefined) {
82640                     var prevKind = seenPackageNames.get(packageName);
82641                     var newKind = fileChanged ? 1 : 0;
82642                     if ((prevKind !== undefined && newKind === 1) || prevKind === 1) {
82643                         return oldProgram.structureIsReused = 0;
82644                     }
82645                     seenPackageNames.set(packageName, newKind);
82646                 }
82647                 if (fileChanged) {
82648                     if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) {
82649                         return oldProgram.structureIsReused = 0;
82650                     }
82651                     if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) {
82652                         oldProgram.structureIsReused = 1;
82653                     }
82654                     if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) {
82655                         oldProgram.structureIsReused = 1;
82656                     }
82657                     collectExternalModuleReferences(newSourceFile);
82658                     if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) {
82659                         oldProgram.structureIsReused = 1;
82660                     }
82661                     if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) {
82662                         oldProgram.structureIsReused = 1;
82663                     }
82664                     if ((oldSourceFile.flags & 3145728) !== (newSourceFile.flags & 3145728)) {
82665                         oldProgram.structureIsReused = 1;
82666                     }
82667                     if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) {
82668                         oldProgram.structureIsReused = 1;
82669                     }
82670                     modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
82671                 }
82672                 else if (hasInvalidatedResolution(oldSourceFile.path)) {
82673                     oldProgram.structureIsReused = 1;
82674                     modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
82675                 }
82676                 newSourceFiles.push(newSourceFile);
82677             }
82678             if (oldProgram.structureIsReused !== 2) {
82679                 return oldProgram.structureIsReused;
82680             }
82681             var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; });
82682             for (var _a = 0, oldSourceFiles_3 = oldSourceFiles; _a < oldSourceFiles_3.length; _a++) {
82683                 var oldFile = oldSourceFiles_3[_a];
82684                 if (!ts.contains(modifiedFiles, oldFile)) {
82685                     for (var _b = 0, _c = oldFile.ambientModuleNames; _b < _c.length; _b++) {
82686                         var moduleName = _c[_b];
82687                         ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName);
82688                     }
82689                 }
82690             }
82691             for (var _d = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _d < modifiedSourceFiles_1.length; _d++) {
82692                 var _e = modifiedSourceFiles_1[_d], oldSourceFile = _e.oldFile, newSourceFile = _e.newFile;
82693                 var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.originalFileName, currentDirectory);
82694                 var moduleNames = getModuleNames(newSourceFile);
82695                 var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile);
82696                 var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo);
82697                 if (resolutionsChanged) {
82698                     oldProgram.structureIsReused = 1;
82699                     newSourceFile.resolvedModules = ts.zipToMap(moduleNames, resolutions);
82700                 }
82701                 else {
82702                     newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
82703                 }
82704                 if (resolveTypeReferenceDirectiveNamesWorker) {
82705                     var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
82706                     var resolutions_1 = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath, getResolvedProjectReferenceToRedirect(newSourceFile.originalFileName));
82707                     var resolutionsChanged_1 = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions_1, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo);
82708                     if (resolutionsChanged_1) {
82709                         oldProgram.structureIsReused = 1;
82710                         newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToMap(typesReferenceDirectives, resolutions_1);
82711                     }
82712                     else {
82713                         newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames;
82714                     }
82715                 }
82716             }
82717             if (oldProgram.structureIsReused !== 2) {
82718                 return oldProgram.structureIsReused;
82719             }
82720             if (host.hasChangedAutomaticTypeDirectiveNames) {
82721                 return oldProgram.structureIsReused = 1;
82722             }
82723             missingFilePaths = oldProgram.getMissingFilePaths();
82724             refFileMap = oldProgram.getRefFileMap();
82725             ts.Debug.assert(newSourceFiles.length === oldProgram.getSourceFiles().length);
82726             for (var _f = 0, newSourceFiles_1 = newSourceFiles; _f < newSourceFiles_1.length; _f++) {
82727                 var newSourceFile = newSourceFiles_1[_f];
82728                 filesByName.set(newSourceFile.path, newSourceFile);
82729             }
82730             var oldFilesByNameMap = oldProgram.getFilesByNameMap();
82731             oldFilesByNameMap.forEach(function (oldFile, path) {
82732                 if (!oldFile) {
82733                     filesByName.set(path, oldFile);
82734                     return;
82735                 }
82736                 if (oldFile.path === path) {
82737                     if (oldProgram.isSourceFileFromExternalLibrary(oldFile)) {
82738                         sourceFilesFoundSearchingNodeModules.set(oldFile.path, true);
82739                     }
82740                     return;
82741                 }
82742                 filesByName.set(path, filesByName.get(oldFile.path));
82743             });
82744             files = newSourceFiles;
82745             fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics();
82746             for (var _g = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _g < modifiedSourceFiles_2.length; _g++) {
82747                 var modifiedFile = modifiedSourceFiles_2[_g];
82748                 fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile.newFile);
82749             }
82750             resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives();
82751             sourceFileToPackageName = oldProgram.sourceFileToPackageName;
82752             redirectTargetsMap = oldProgram.redirectTargetsMap;
82753             return oldProgram.structureIsReused = 2;
82754         }
82755         function getEmitHost(writeFileCallback) {
82756             return {
82757                 getPrependNodes: getPrependNodes,
82758                 getCanonicalFileName: getCanonicalFileName,
82759                 getCommonSourceDirectory: program.getCommonSourceDirectory,
82760                 getCompilerOptions: program.getCompilerOptions,
82761                 getCurrentDirectory: function () { return currentDirectory; },
82762                 getNewLine: function () { return host.getNewLine(); },
82763                 getSourceFile: program.getSourceFile,
82764                 getSourceFileByPath: program.getSourceFileByPath,
82765                 getSourceFiles: program.getSourceFiles,
82766                 getLibFileFromReference: program.getLibFileFromReference,
82767                 isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary,
82768                 getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect,
82769                 getProjectReferenceRedirect: getProjectReferenceRedirect,
82770                 isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
82771                 getProbableSymlinks: getProbableSymlinks,
82772                 writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }),
82773                 isEmitBlocked: isEmitBlocked,
82774                 readFile: function (f) { return host.readFile(f); },
82775                 fileExists: function (f) {
82776                     var path = toPath(f);
82777                     if (getSourceFileByPath(path))
82778                         return true;
82779                     if (ts.contains(missingFilePaths, path))
82780                         return false;
82781                     return host.fileExists(f);
82782                 },
82783                 useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
82784                 getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); },
82785                 getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); },
82786                 redirectTargetsMap: redirectTargetsMap,
82787             };
82788         }
82789         function emitBuildInfo(writeFileCallback) {
82790             ts.Debug.assert(!options.out && !options.outFile);
82791             ts.performance.mark("beforeEmit");
82792             var emitResult = ts.emitFiles(ts.notImplementedResolver, getEmitHost(writeFileCallback), undefined, ts.noTransformers, false, true);
82793             ts.performance.mark("afterEmit");
82794             ts.performance.measure("Emit", "beforeEmit", "afterEmit");
82795             return emitResult;
82796         }
82797         function getResolvedProjectReferences() {
82798             return resolvedProjectReferences;
82799         }
82800         function getProjectReferences() {
82801             return projectReferences;
82802         }
82803         function getPrependNodes() {
82804             return createPrependNodes(projectReferences, function (_ref, index) { return resolvedProjectReferences[index].commandLine; }, function (fileName) {
82805                 var path = toPath(fileName);
82806                 var sourceFile = getSourceFileByPath(path);
82807                 return sourceFile ? sourceFile.text : filesByName.has(path) ? undefined : host.readFile(path);
82808             });
82809         }
82810         function isSourceFileFromExternalLibrary(file) {
82811             return !!sourceFilesFoundSearchingNodeModules.get(file.path);
82812         }
82813         function isSourceFileDefaultLibrary(file) {
82814             if (file.hasNoDefaultLib) {
82815                 return true;
82816             }
82817             if (!options.noLib) {
82818                 return false;
82819             }
82820             var equalityComparer = host.useCaseSensitiveFileNames() ? ts.equateStringsCaseSensitive : ts.equateStringsCaseInsensitive;
82821             if (!options.lib) {
82822                 return equalityComparer(file.fileName, getDefaultLibraryFileName());
82823             }
82824             else {
82825                 return ts.some(options.lib, function (libFileName) { return equalityComparer(file.fileName, ts.combinePaths(defaultLibraryPath, libFileName)); });
82826             }
82827         }
82828         function getDiagnosticsProducingTypeChecker() {
82829             return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true));
82830         }
82831         function dropDiagnosticsProducingTypeChecker() {
82832             diagnosticsProducingTypeChecker = undefined;
82833         }
82834         function getTypeChecker() {
82835             return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false));
82836         }
82837         function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) {
82838             return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); });
82839         }
82840         function isEmitBlocked(emitFileName) {
82841             return hasEmitBlockingDiagnostics.has(toPath(emitFileName));
82842         }
82843         function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit) {
82844             if (!forceDtsEmit) {
82845                 var result = handleNoEmitOptions(program, sourceFile, cancellationToken);
82846                 if (result)
82847                     return result;
82848             }
82849             var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile, cancellationToken);
82850             ts.performance.mark("beforeEmit");
82851             var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles, false, forceDtsEmit);
82852             ts.performance.mark("afterEmit");
82853             ts.performance.measure("Emit", "beforeEmit", "afterEmit");
82854             return emitResult;
82855         }
82856         function getSourceFile(fileName) {
82857             return getSourceFileByPath(toPath(fileName));
82858         }
82859         function getSourceFileByPath(path) {
82860             return filesByName.get(path) || undefined;
82861         }
82862         function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) {
82863             if (sourceFile) {
82864                 return getDiagnostics(sourceFile, cancellationToken);
82865             }
82866             return ts.sortAndDeduplicateDiagnostics(ts.flatMap(program.getSourceFiles(), function (sourceFile) {
82867                 if (cancellationToken) {
82868                     cancellationToken.throwIfCancellationRequested();
82869                 }
82870                 return getDiagnostics(sourceFile, cancellationToken);
82871             }));
82872         }
82873         function getSyntacticDiagnostics(sourceFile, cancellationToken) {
82874             return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile, cancellationToken);
82875         }
82876         function getSemanticDiagnostics(sourceFile, cancellationToken) {
82877             return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile, cancellationToken);
82878         }
82879         function getBindAndCheckDiagnostics(sourceFile, cancellationToken) {
82880             return getBindAndCheckDiagnosticsForFile(sourceFile, cancellationToken);
82881         }
82882         function getProgramDiagnostics(sourceFile) {
82883             if (ts.skipTypeChecking(sourceFile, options, program)) {
82884                 return ts.emptyArray;
82885             }
82886             var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName);
82887             var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName);
82888             return getMergedProgramDiagnostics(sourceFile, fileProcessingDiagnosticsInFile, programDiagnosticsInFile);
82889         }
82890         function getMergedProgramDiagnostics(sourceFile) {
82891             var _a;
82892             var allDiagnostics = [];
82893             for (var _i = 1; _i < arguments.length; _i++) {
82894                 allDiagnostics[_i - 1] = arguments[_i];
82895             }
82896             var flatDiagnostics = ts.flatten(allDiagnostics);
82897             if (!((_a = sourceFile.commentDirectives) === null || _a === void 0 ? void 0 : _a.length)) {
82898                 return flatDiagnostics;
82899             }
82900             return getDiagnosticsWithPrecedingDirectives(sourceFile, sourceFile.commentDirectives, flatDiagnostics).diagnostics;
82901         }
82902         function getDeclarationDiagnostics(sourceFile, cancellationToken) {
82903             var options = program.getCompilerOptions();
82904             if (!sourceFile || options.out || options.outFile) {
82905                 return getDeclarationDiagnosticsWorker(sourceFile, cancellationToken);
82906             }
82907             else {
82908                 return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken);
82909             }
82910         }
82911         function getSyntacticDiagnosticsForFile(sourceFile) {
82912             if (ts.isSourceFileJS(sourceFile)) {
82913                 if (!sourceFile.additionalSyntacticDiagnostics) {
82914                     sourceFile.additionalSyntacticDiagnostics = getJSSyntacticDiagnosticsForFile(sourceFile);
82915                 }
82916                 return ts.concatenate(sourceFile.additionalSyntacticDiagnostics, sourceFile.parseDiagnostics);
82917             }
82918             return sourceFile.parseDiagnostics;
82919         }
82920         function runWithCancellationToken(func) {
82921             try {
82922                 return func();
82923             }
82924             catch (e) {
82925                 if (e instanceof ts.OperationCanceledException) {
82926                     noDiagnosticsTypeChecker = undefined;
82927                     diagnosticsProducingTypeChecker = undefined;
82928                 }
82929                 throw e;
82930             }
82931         }
82932         function getSemanticDiagnosticsForFile(sourceFile, cancellationToken) {
82933             return ts.concatenate(getBindAndCheckDiagnosticsForFile(sourceFile, cancellationToken), getProgramDiagnostics(sourceFile));
82934         }
82935         function getBindAndCheckDiagnosticsForFile(sourceFile, cancellationToken) {
82936             return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedBindAndCheckDiagnosticsForFile, getBindAndCheckDiagnosticsForFileNoCache);
82937         }
82938         function getBindAndCheckDiagnosticsForFileNoCache(sourceFile, cancellationToken) {
82939             return runWithCancellationToken(function () {
82940                 if (ts.skipTypeChecking(sourceFile, options, program)) {
82941                     return ts.emptyArray;
82942                 }
82943                 var typeChecker = getDiagnosticsProducingTypeChecker();
82944                 ts.Debug.assert(!!sourceFile.bindDiagnostics);
82945                 var isCheckJs = ts.isCheckJsEnabledForFile(sourceFile, options);
82946                 var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false;
82947                 var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 || sourceFile.scriptKind === 4 ||
82948                     sourceFile.scriptKind === 5 || isCheckJs || sourceFile.scriptKind === 7);
82949                 var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray;
82950                 var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray;
82951                 return getMergedBindAndCheckDiagnostics(sourceFile, bindDiagnostics, checkDiagnostics, isCheckJs ? sourceFile.jsDocDiagnostics : undefined);
82952             });
82953         }
82954         function getMergedBindAndCheckDiagnostics(sourceFile) {
82955             var _a;
82956             var allDiagnostics = [];
82957             for (var _i = 1; _i < arguments.length; _i++) {
82958                 allDiagnostics[_i - 1] = arguments[_i];
82959             }
82960             var flatDiagnostics = ts.flatten(allDiagnostics);
82961             if (!((_a = sourceFile.commentDirectives) === null || _a === void 0 ? void 0 : _a.length)) {
82962                 return flatDiagnostics;
82963             }
82964             var _b = getDiagnosticsWithPrecedingDirectives(sourceFile, sourceFile.commentDirectives, flatDiagnostics), diagnostics = _b.diagnostics, directives = _b.directives;
82965             for (var _c = 0, _d = directives.getUnusedExpectations(); _c < _d.length; _c++) {
82966                 var errorExpectation = _d[_c];
82967                 diagnostics.push(ts.createDiagnosticForRange(sourceFile, errorExpectation.range, ts.Diagnostics.Unused_ts_expect_error_directive));
82968             }
82969             return diagnostics;
82970         }
82971         function getDiagnosticsWithPrecedingDirectives(sourceFile, commentDirectives, flatDiagnostics) {
82972             var directives = ts.createCommentDirectivesMap(sourceFile, commentDirectives);
82973             var diagnostics = flatDiagnostics.filter(function (diagnostic) { return markPrecedingCommentDirectiveLine(diagnostic, directives) === -1; });
82974             return { diagnostics: diagnostics, directives: directives };
82975         }
82976         function getSuggestionDiagnostics(sourceFile, cancellationToken) {
82977             return runWithCancellationToken(function () {
82978                 return getDiagnosticsProducingTypeChecker().getSuggestionDiagnostics(sourceFile, cancellationToken);
82979             });
82980         }
82981         function markPrecedingCommentDirectiveLine(diagnostic, directives) {
82982             var file = diagnostic.file, start = diagnostic.start;
82983             if (!file) {
82984                 return -1;
82985             }
82986             var lineStarts = ts.getLineStarts(file);
82987             var line = ts.computeLineAndCharacterOfPosition(lineStarts, start).line - 1;
82988             while (line >= 0) {
82989                 if (directives.markUsed(line)) {
82990                     return line;
82991                 }
82992                 var lineText = file.text.slice(lineStarts[line], lineStarts[line + 1]).trim();
82993                 if (lineText !== "" && !/^(\s*)\/\/(.*)$/.test(lineText)) {
82994                     return -1;
82995                 }
82996                 line--;
82997             }
82998             return -1;
82999         }
83000         function getJSSyntacticDiagnosticsForFile(sourceFile) {
83001             return runWithCancellationToken(function () {
83002                 var diagnostics = [];
83003                 walk(sourceFile, sourceFile);
83004                 ts.forEachChildRecursively(sourceFile, walk, walkArray);
83005                 return diagnostics;
83006                 function walk(node, parent) {
83007                     switch (parent.kind) {
83008                         case 156:
83009                         case 159:
83010                         case 161:
83011                             if (parent.questionToken === node) {
83012                                 diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?"));
83013                                 return "skip";
83014                             }
83015                         case 160:
83016                         case 162:
83017                         case 163:
83018                         case 164:
83019                         case 201:
83020                         case 244:
83021                         case 202:
83022                         case 242:
83023                             if (parent.type === node) {
83024                                 diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files));
83025                                 return "skip";
83026                             }
83027                     }
83028                     switch (node.kind) {
83029                         case 255:
83030                             if (node.isTypeOnly) {
83031                                 diagnostics.push(createDiagnosticForNode(node.parent, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "import type"));
83032                                 return "skip";
83033                             }
83034                             break;
83035                         case 260:
83036                             if (node.isTypeOnly) {
83037                                 diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "export type"));
83038                                 return "skip";
83039                             }
83040                             break;
83041                         case 253:
83042                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files));
83043                             return "skip";
83044                         case 259:
83045                             if (node.isExportEquals) {
83046                                 diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_TypeScript_files));
83047                                 return "skip";
83048                             }
83049                             break;
83050                         case 279:
83051                             var heritageClause = node;
83052                             if (heritageClause.token === 113) {
83053                                 diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_TypeScript_files));
83054                                 return "skip";
83055                             }
83056                             break;
83057                         case 246:
83058                             var interfaceKeyword = ts.tokenToString(114);
83059                             ts.Debug.assertIsDefined(interfaceKeyword);
83060                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, interfaceKeyword));
83061                             return "skip";
83062                         case 249:
83063                             var moduleKeyword = node.flags & 16 ? ts.tokenToString(136) : ts.tokenToString(135);
83064                             ts.Debug.assertIsDefined(moduleKeyword);
83065                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword));
83066                             return "skip";
83067                         case 247:
83068                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files));
83069                             return "skip";
83070                         case 248:
83071                             var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(88));
83072                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, enumKeyword));
83073                             return "skip";
83074                         case 218:
83075                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files));
83076                             return "skip";
83077                         case 217:
83078                             diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files));
83079                             return "skip";
83080                         case 199:
83081                             ts.Debug.fail();
83082                     }
83083                 }
83084                 function walkArray(nodes, parent) {
83085                     if (parent.decorators === nodes && !options.experimentalDecorators) {
83086                         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));
83087                     }
83088                     switch (parent.kind) {
83089                         case 245:
83090                         case 214:
83091                         case 161:
83092                         case 162:
83093                         case 163:
83094                         case 164:
83095                         case 201:
83096                         case 244:
83097                         case 202:
83098                             if (nodes === parent.typeParameters) {
83099                                 diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files));
83100                                 return "skip";
83101                             }
83102                         case 225:
83103                             if (nodes === parent.modifiers) {
83104                                 checkModifiers(parent.modifiers, parent.kind === 225);
83105                                 return "skip";
83106                             }
83107                             break;
83108                         case 159:
83109                             if (nodes === parent.modifiers) {
83110                                 for (var _i = 0, _a = nodes; _i < _a.length; _i++) {
83111                                     var modifier = _a[_i];
83112                                     if (modifier.kind !== 120) {
83113                                         diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind)));
83114                                     }
83115                                 }
83116                                 return "skip";
83117                             }
83118                             break;
83119                         case 156:
83120                             if (nodes === parent.modifiers) {
83121                                 diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files));
83122                                 return "skip";
83123                             }
83124                             break;
83125                         case 196:
83126                         case 197:
83127                         case 216:
83128                         case 267:
83129                         case 268:
83130                         case 198:
83131                             if (nodes === parent.typeArguments) {
83132                                 diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files));
83133                                 return "skip";
83134                             }
83135                             break;
83136                     }
83137                 }
83138                 function checkModifiers(modifiers, isConstValid) {
83139                     for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) {
83140                         var modifier = modifiers_1[_i];
83141                         switch (modifier.kind) {
83142                             case 81:
83143                                 if (isConstValid) {
83144                                     continue;
83145                                 }
83146                             case 119:
83147                             case 117:
83148                             case 118:
83149                             case 138:
83150                             case 130:
83151                             case 122:
83152                                 diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind)));
83153                                 break;
83154                             case 120:
83155                             case 89:
83156                             case 84:
83157                         }
83158                     }
83159                 }
83160                 function createDiagnosticForNodeArray(nodes, message, arg0, arg1, arg2) {
83161                     var start = nodes.pos;
83162                     return ts.createFileDiagnostic(sourceFile, start, nodes.end - start, message, arg0, arg1, arg2);
83163                 }
83164                 function createDiagnosticForNode(node, message, arg0, arg1, arg2) {
83165                     return ts.createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2);
83166                 }
83167             });
83168         }
83169         function getDeclarationDiagnosticsWorker(sourceFile, cancellationToken) {
83170             return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedDeclarationDiagnosticsForFile, getDeclarationDiagnosticsForFileNoCache);
83171         }
83172         function getDeclarationDiagnosticsForFileNoCache(sourceFile, cancellationToken) {
83173             return runWithCancellationToken(function () {
83174                 var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken);
83175                 return ts.getDeclarationDiagnostics(getEmitHost(ts.noop), resolver, sourceFile) || ts.emptyArray;
83176             });
83177         }
83178         function getAndCacheDiagnostics(sourceFile, cancellationToken, cache, getDiagnostics) {
83179             var cachedResult = sourceFile
83180                 ? cache.perFile && cache.perFile.get(sourceFile.path)
83181                 : cache.allDiagnostics;
83182             if (cachedResult) {
83183                 return cachedResult;
83184             }
83185             var result = getDiagnostics(sourceFile, cancellationToken);
83186             if (sourceFile) {
83187                 if (!cache.perFile) {
83188                     cache.perFile = ts.createMap();
83189                 }
83190                 cache.perFile.set(sourceFile.path, result);
83191             }
83192             else {
83193                 cache.allDiagnostics = result;
83194             }
83195             return result;
83196         }
83197         function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) {
83198             return sourceFile.isDeclarationFile ? [] : getDeclarationDiagnosticsWorker(sourceFile, cancellationToken);
83199         }
83200         function getOptionsDiagnostics() {
83201             return ts.sortAndDeduplicateDiagnostics(ts.concatenate(fileProcessingDiagnostics.getGlobalDiagnostics(), ts.concatenate(programDiagnostics.getGlobalDiagnostics(), getOptionsDiagnosticsOfConfigFile())));
83202         }
83203         function getOptionsDiagnosticsOfConfigFile() {
83204             if (!options.configFile) {
83205                 return ts.emptyArray;
83206             }
83207             var diagnostics = programDiagnostics.getDiagnostics(options.configFile.fileName);
83208             forEachResolvedProjectReference(function (resolvedRef) {
83209                 if (resolvedRef) {
83210                     diagnostics = ts.concatenate(diagnostics, programDiagnostics.getDiagnostics(resolvedRef.sourceFile.fileName));
83211                 }
83212             });
83213             return diagnostics;
83214         }
83215         function getGlobalDiagnostics() {
83216             return rootNames.length ? ts.sortAndDeduplicateDiagnostics(getDiagnosticsProducingTypeChecker().getGlobalDiagnostics().slice()) : ts.emptyArray;
83217         }
83218         function getConfigFileParsingDiagnostics() {
83219             return configFileParsingDiagnostics || ts.emptyArray;
83220         }
83221         function processRootFile(fileName, isDefaultLib, ignoreNoDefaultLib) {
83222             processSourceFile(ts.normalizePath(fileName), isDefaultLib, ignoreNoDefaultLib, undefined);
83223         }
83224         function fileReferenceIsEqualTo(a, b) {
83225             return a.fileName === b.fileName;
83226         }
83227         function moduleNameIsEqualTo(a, b) {
83228             return a.kind === 75
83229                 ? b.kind === 75 && a.escapedText === b.escapedText
83230                 : b.kind === 10 && a.text === b.text;
83231         }
83232         function collectExternalModuleReferences(file) {
83233             if (file.imports) {
83234                 return;
83235             }
83236             var isJavaScriptFile = ts.isSourceFileJS(file);
83237             var isExternalModuleFile = ts.isExternalModule(file);
83238             var imports;
83239             var moduleAugmentations;
83240             var ambientModules;
83241             if (options.importHelpers
83242                 && (options.isolatedModules || isExternalModuleFile)
83243                 && !file.isDeclarationFile) {
83244                 var externalHelpersModuleReference = ts.createLiteral(ts.externalHelpersModuleNameText);
83245                 var importDecl = ts.createImportDeclaration(undefined, undefined, undefined, externalHelpersModuleReference);
83246                 ts.addEmitFlags(importDecl, 67108864);
83247                 externalHelpersModuleReference.parent = importDecl;
83248                 importDecl.parent = file;
83249                 imports = [externalHelpersModuleReference];
83250             }
83251             for (var _i = 0, _a = file.statements; _i < _a.length; _i++) {
83252                 var node = _a[_i];
83253                 collectModuleReferences(node, false);
83254             }
83255             if ((file.flags & 1048576) || isJavaScriptFile) {
83256                 collectDynamicImportOrRequireCalls(file);
83257             }
83258             file.imports = imports || ts.emptyArray;
83259             file.moduleAugmentations = moduleAugmentations || ts.emptyArray;
83260             file.ambientModuleNames = ambientModules || ts.emptyArray;
83261             return;
83262             function collectModuleReferences(node, inAmbientModule) {
83263                 if (ts.isAnyImportOrReExport(node)) {
83264                     var moduleNameExpr = ts.getExternalModuleName(node);
83265                     if (moduleNameExpr && ts.isStringLiteral(moduleNameExpr) && moduleNameExpr.text && (!inAmbientModule || !ts.isExternalModuleNameRelative(moduleNameExpr.text))) {
83266                         imports = ts.append(imports, moduleNameExpr);
83267                     }
83268                 }
83269                 else if (ts.isModuleDeclaration(node)) {
83270                     if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2) || file.isDeclarationFile)) {
83271                         var nameText = ts.getTextOfIdentifierOrLiteral(node.name);
83272                         if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(nameText))) {
83273                             (moduleAugmentations || (moduleAugmentations = [])).push(node.name);
83274                         }
83275                         else if (!inAmbientModule) {
83276                             if (file.isDeclarationFile) {
83277                                 (ambientModules || (ambientModules = [])).push(nameText);
83278                             }
83279                             var body = node.body;
83280                             if (body) {
83281                                 for (var _i = 0, _a = body.statements; _i < _a.length; _i++) {
83282                                     var statement = _a[_i];
83283                                     collectModuleReferences(statement, true);
83284                                 }
83285                             }
83286                         }
83287                     }
83288                 }
83289             }
83290             function collectDynamicImportOrRequireCalls(file) {
83291                 var r = /import|require/g;
83292                 while (r.exec(file.text) !== null) {
83293                     var node = getNodeAtPosition(file, r.lastIndex);
83294                     if (ts.isRequireCall(node, true)) {
83295                         imports = ts.append(imports, node.arguments[0]);
83296                     }
83297                     else if (ts.isImportCall(node) && node.arguments.length === 1 && ts.isStringLiteralLike(node.arguments[0])) {
83298                         imports = ts.append(imports, node.arguments[0]);
83299                     }
83300                     else if (ts.isLiteralImportTypeNode(node)) {
83301                         imports = ts.append(imports, node.argument.literal);
83302                     }
83303                 }
83304             }
83305             function getNodeAtPosition(sourceFile, position) {
83306                 var current = sourceFile;
83307                 var getContainingChild = function (child) {
83308                     if (child.pos <= position && (position < child.end || (position === child.end && (child.kind === 1)))) {
83309                         return child;
83310                     }
83311                 };
83312                 while (true) {
83313                     var child = isJavaScriptFile && ts.hasJSDocNodes(current) && ts.forEach(current.jsDoc, getContainingChild) || ts.forEachChild(current, getContainingChild);
83314                     if (!child) {
83315                         return current;
83316                     }
83317                     current = child;
83318                 }
83319             }
83320         }
83321         function getLibFileFromReference(ref) {
83322             var libName = ts.toFileNameLowerCase(ref.fileName);
83323             var libFileName = ts.libMap.get(libName);
83324             if (libFileName) {
83325                 return getSourceFile(ts.combinePaths(defaultLibraryPath, libFileName));
83326             }
83327         }
83328         function getSourceFileFromReference(referencingFile, ref) {
83329             return getSourceFileFromReferenceWorker(resolveTripleslashReference(ref.fileName, referencingFile.fileName), function (fileName) { return filesByName.get(toPath(fileName)) || undefined; });
83330         }
83331         function getSourceFileFromReferenceWorker(fileName, getSourceFile, fail, refFile) {
83332             if (ts.hasExtension(fileName)) {
83333                 var canonicalFileName_1 = host.getCanonicalFileName(fileName);
83334                 if (!options.allowNonTsExtensions && !ts.forEach(supportedExtensionsWithJsonIfResolveJsonModule, function (extension) { return ts.fileExtensionIs(canonicalFileName_1, extension); })) {
83335                     if (fail) {
83336                         if (ts.hasJSFileExtension(canonicalFileName_1)) {
83337                             fail(ts.Diagnostics.File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option, fileName);
83338                         }
83339                         else {
83340                             fail(ts.Diagnostics.File_0_has_an_unsupported_extension_The_only_supported_extensions_are_1, fileName, "'" + supportedExtensions.join("', '") + "'");
83341                         }
83342                     }
83343                     return undefined;
83344                 }
83345                 var sourceFile = getSourceFile(fileName);
83346                 if (fail) {
83347                     if (!sourceFile) {
83348                         var redirect = getProjectReferenceRedirect(fileName);
83349                         if (redirect) {
83350                             fail(ts.Diagnostics.Output_file_0_has_not_been_built_from_source_file_1, redirect, fileName);
83351                         }
83352                         else {
83353                             fail(ts.Diagnostics.File_0_not_found, fileName);
83354                         }
83355                     }
83356                     else if (refFile && canonicalFileName_1 === host.getCanonicalFileName(refFile.fileName)) {
83357                         fail(ts.Diagnostics.A_file_cannot_have_a_reference_to_itself);
83358                     }
83359                 }
83360                 return sourceFile;
83361             }
83362             else {
83363                 var sourceFileNoExtension = options.allowNonTsExtensions && getSourceFile(fileName);
83364                 if (sourceFileNoExtension)
83365                     return sourceFileNoExtension;
83366                 if (fail && options.allowNonTsExtensions) {
83367                     fail(ts.Diagnostics.File_0_not_found, fileName);
83368                     return undefined;
83369                 }
83370                 var sourceFileWithAddedExtension = ts.forEach(supportedExtensions, function (extension) { return getSourceFile(fileName + extension); });
83371                 if (fail && !sourceFileWithAddedExtension)
83372                     fail(ts.Diagnostics.Could_not_resolve_the_path_0_with_the_extensions_Colon_1, fileName, "'" + supportedExtensions.join("', '") + "'");
83373                 return sourceFileWithAddedExtension;
83374             }
83375         }
83376         function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile) {
83377             getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, packageId); }, function (diagnostic) {
83378                 var args = [];
83379                 for (var _i = 1; _i < arguments.length; _i++) {
83380                     args[_i - 1] = arguments[_i];
83381                 }
83382                 return fileProcessingDiagnostics.add(createRefFileDiagnostic.apply(void 0, __spreadArrays([refFile, diagnostic], args)));
83383             }, refFile && refFile.file);
83384         }
83385         function reportFileNamesDifferOnlyInCasingError(fileName, existingFile, refFile) {
83386             var refs = !refFile ? refFileMap && refFileMap.get(existingFile.path) : undefined;
83387             var refToReportErrorOn = refs && ts.find(refs, function (ref) { return ref.referencedFileName === existingFile.fileName; });
83388             fileProcessingDiagnostics.add(refToReportErrorOn ?
83389                 createFileDiagnosticAtReference(refToReportErrorOn, ts.Diagnostics.Already_included_file_name_0_differs_from_file_name_1_only_in_casing, existingFile.fileName, fileName) :
83390                 createRefFileDiagnostic(refFile, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFile.fileName));
83391         }
83392         function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) {
83393             var redirect = Object.create(redirectTarget);
83394             redirect.fileName = fileName;
83395             redirect.path = path;
83396             redirect.resolvedPath = resolvedPath;
83397             redirect.originalFileName = originalFileName;
83398             redirect.redirectInfo = { redirectTarget: redirectTarget, unredirected: unredirected };
83399             sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
83400             Object.defineProperties(redirect, {
83401                 id: {
83402                     get: function () { return this.redirectInfo.redirectTarget.id; },
83403                     set: function (value) { this.redirectInfo.redirectTarget.id = value; },
83404                 },
83405                 symbol: {
83406                     get: function () { return this.redirectInfo.redirectTarget.symbol; },
83407                     set: function (value) { this.redirectInfo.redirectTarget.symbol = value; },
83408                 },
83409             });
83410             return redirect;
83411         }
83412         function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, packageId) {
83413             if (useSourceOfProjectReferenceRedirect) {
83414                 var source = getSourceOfProjectReferenceRedirect(fileName);
83415                 if (!source &&
83416                     host.realpath &&
83417                     options.preserveSymlinks &&
83418                     ts.isDeclarationFileName(fileName) &&
83419                     ts.stringContains(fileName, ts.nodeModulesPathPart)) {
83420                     var realPath = host.realpath(fileName);
83421                     if (realPath !== fileName)
83422                         source = getSourceOfProjectReferenceRedirect(realPath);
83423                 }
83424                 if (source) {
83425                     var file_1 = ts.isString(source) ?
83426                         findSourceFile(source, toPath(source), isDefaultLib, ignoreNoDefaultLib, refFile, packageId) :
83427                         undefined;
83428                     if (file_1)
83429                         addFileToFilesByName(file_1, path, undefined);
83430                     return file_1;
83431                 }
83432             }
83433             var originalFileName = fileName;
83434             if (filesByName.has(path)) {
83435                 var file_2 = filesByName.get(path);
83436                 addFileToRefFileMap(fileName, file_2 || undefined, refFile);
83437                 if (file_2 && options.forceConsistentCasingInFileNames) {
83438                     var checkedName = file_2.fileName;
83439                     var isRedirect = toPath(checkedName) !== toPath(fileName);
83440                     if (isRedirect) {
83441                         fileName = getProjectReferenceRedirect(fileName) || fileName;
83442                     }
83443                     var checkedAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(checkedName, currentDirectory);
83444                     var inputAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory);
83445                     if (checkedAbsolutePath !== inputAbsolutePath) {
83446                         reportFileNamesDifferOnlyInCasingError(fileName, file_2, refFile);
83447                     }
83448                 }
83449                 if (file_2 && sourceFilesFoundSearchingNodeModules.get(file_2.path) && currentNodeModulesDepth === 0) {
83450                     sourceFilesFoundSearchingNodeModules.set(file_2.path, false);
83451                     if (!options.noResolve) {
83452                         processReferencedFiles(file_2, isDefaultLib);
83453                         processTypeReferenceDirectives(file_2);
83454                     }
83455                     if (!options.noLib) {
83456                         processLibReferenceDirectives(file_2);
83457                     }
83458                     modulesWithElidedImports.set(file_2.path, false);
83459                     processImportedModules(file_2);
83460                 }
83461                 else if (file_2 && modulesWithElidedImports.get(file_2.path)) {
83462                     if (currentNodeModulesDepth < maxNodeModuleJsDepth) {
83463                         modulesWithElidedImports.set(file_2.path, false);
83464                         processImportedModules(file_2);
83465                     }
83466                 }
83467                 return file_2 || undefined;
83468             }
83469             var redirectedPath;
83470             if (refFile && !useSourceOfProjectReferenceRedirect) {
83471                 var redirectProject = getProjectReferenceRedirectProject(fileName);
83472                 if (redirectProject) {
83473                     if (redirectProject.commandLine.options.outFile || redirectProject.commandLine.options.out) {
83474                         return undefined;
83475                     }
83476                     var redirect = getProjectReferenceOutputName(redirectProject, fileName);
83477                     fileName = redirect;
83478                     redirectedPath = toPath(redirect);
83479                 }
83480             }
83481             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);
83482             if (packageId) {
83483                 var packageIdKey = ts.packageIdToString(packageId);
83484                 var fileFromPackageId = packageIdToSourceFile.get(packageIdKey);
83485                 if (fileFromPackageId) {
83486                     var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName);
83487                     redirectTargetsMap.add(fileFromPackageId.path, fileName);
83488                     addFileToFilesByName(dupFile, path, redirectedPath);
83489                     sourceFileToPackageName.set(path, packageId.name);
83490                     processingOtherFiles.push(dupFile);
83491                     return dupFile;
83492                 }
83493                 else if (file) {
83494                     packageIdToSourceFile.set(packageIdKey, file);
83495                     sourceFileToPackageName.set(path, packageId.name);
83496                 }
83497             }
83498             addFileToFilesByName(file, path, redirectedPath);
83499             if (file) {
83500                 sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
83501                 file.fileName = fileName;
83502                 file.path = path;
83503                 file.resolvedPath = toPath(fileName);
83504                 file.originalFileName = originalFileName;
83505                 addFileToRefFileMap(fileName, file, refFile);
83506                 if (host.useCaseSensitiveFileNames()) {
83507                     var pathLowerCase = ts.toFileNameLowerCase(path);
83508                     var existingFile = filesByNameIgnoreCase.get(pathLowerCase);
83509                     if (existingFile) {
83510                         reportFileNamesDifferOnlyInCasingError(fileName, existingFile, refFile);
83511                     }
83512                     else {
83513                         filesByNameIgnoreCase.set(pathLowerCase, file);
83514                     }
83515                 }
83516                 skipDefaultLib = skipDefaultLib || (file.hasNoDefaultLib && !ignoreNoDefaultLib);
83517                 if (!options.noResolve) {
83518                     processReferencedFiles(file, isDefaultLib);
83519                     processTypeReferenceDirectives(file);
83520                 }
83521                 if (!options.noLib) {
83522                     processLibReferenceDirectives(file);
83523                 }
83524                 processImportedModules(file);
83525                 if (isDefaultLib) {
83526                     processingDefaultLibFiles.push(file);
83527                 }
83528                 else {
83529                     processingOtherFiles.push(file);
83530                 }
83531             }
83532             return file;
83533         }
83534         function addFileToRefFileMap(referencedFileName, file, refFile) {
83535             if (refFile && file) {
83536                 (refFileMap || (refFileMap = ts.createMultiMap())).add(file.path, {
83537                     referencedFileName: referencedFileName,
83538                     kind: refFile.kind,
83539                     index: refFile.index,
83540                     file: refFile.file.path
83541                 });
83542             }
83543         }
83544         function addFileToFilesByName(file, path, redirectedPath) {
83545             if (redirectedPath) {
83546                 filesByName.set(redirectedPath, file);
83547                 filesByName.set(path, file || false);
83548             }
83549             else {
83550                 filesByName.set(path, file);
83551             }
83552         }
83553         function getProjectReferenceRedirect(fileName) {
83554             var referencedProject = getProjectReferenceRedirectProject(fileName);
83555             return referencedProject && getProjectReferenceOutputName(referencedProject, fileName);
83556         }
83557         function getProjectReferenceRedirectProject(fileName) {
83558             if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts") || ts.fileExtensionIs(fileName, ".json")) {
83559                 return undefined;
83560             }
83561             return getResolvedProjectReferenceToRedirect(fileName);
83562         }
83563         function getProjectReferenceOutputName(referencedProject, fileName) {
83564             var out = referencedProject.commandLine.options.outFile || referencedProject.commandLine.options.out;
83565             return out ?
83566                 ts.changeExtension(out, ".d.ts") :
83567                 ts.getOutputDeclarationFileName(fileName, referencedProject.commandLine, !host.useCaseSensitiveFileNames());
83568         }
83569         function getResolvedProjectReferenceToRedirect(fileName) {
83570             if (mapFromFileToProjectReferenceRedirects === undefined) {
83571                 mapFromFileToProjectReferenceRedirects = ts.createMap();
83572                 forEachResolvedProjectReference(function (referencedProject, referenceProjectPath) {
83573                     if (referencedProject &&
83574                         toPath(options.configFilePath) !== referenceProjectPath) {
83575                         referencedProject.commandLine.fileNames.forEach(function (f) {
83576                             return mapFromFileToProjectReferenceRedirects.set(toPath(f), referenceProjectPath);
83577                         });
83578                     }
83579                 });
83580             }
83581             var referencedProjectPath = mapFromFileToProjectReferenceRedirects.get(toPath(fileName));
83582             return referencedProjectPath && getResolvedProjectReferenceByPath(referencedProjectPath);
83583         }
83584         function forEachResolvedProjectReference(cb) {
83585             return forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) {
83586                 var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index];
83587                 var resolvedRefPath = toPath(resolveProjectReferencePath(ref));
83588                 return cb(resolvedRef, resolvedRefPath);
83589             });
83590         }
83591         function getSourceOfProjectReferenceRedirect(file) {
83592             if (!ts.isDeclarationFileName(file))
83593                 return undefined;
83594             if (mapFromToProjectReferenceRedirectSource === undefined) {
83595                 mapFromToProjectReferenceRedirectSource = ts.createMap();
83596                 forEachResolvedProjectReference(function (resolvedRef) {
83597                     if (resolvedRef) {
83598                         var out = resolvedRef.commandLine.options.outFile || resolvedRef.commandLine.options.out;
83599                         if (out) {
83600                             var outputDts = ts.changeExtension(out, ".d.ts");
83601                             mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), true);
83602                         }
83603                         else {
83604                             ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) {
83605                                 if (!ts.fileExtensionIs(fileName, ".d.ts") && !ts.fileExtensionIs(fileName, ".json")) {
83606                                     var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, host.useCaseSensitiveFileNames());
83607                                     mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName);
83608                                 }
83609                             });
83610                         }
83611                     }
83612                 });
83613             }
83614             return mapFromToProjectReferenceRedirectSource.get(toPath(file));
83615         }
83616         function isSourceOfProjectReferenceRedirect(fileName) {
83617             return useSourceOfProjectReferenceRedirect && !!getResolvedProjectReferenceToRedirect(fileName);
83618         }
83619         function forEachProjectReference(projectReferences, resolvedProjectReferences, cbResolvedRef, cbRef) {
83620             var seenResolvedRefs;
83621             return worker(projectReferences, resolvedProjectReferences, undefined, cbResolvedRef, cbRef);
83622             function worker(projectReferences, resolvedProjectReferences, parent, cbResolvedRef, cbRef) {
83623                 if (cbRef) {
83624                     var result = cbRef(projectReferences, parent);
83625                     if (result) {
83626                         return result;
83627                     }
83628                 }
83629                 return ts.forEach(resolvedProjectReferences, function (resolvedRef, index) {
83630                     if (ts.contains(seenResolvedRefs, resolvedRef)) {
83631                         return undefined;
83632                     }
83633                     var result = cbResolvedRef(resolvedRef, index, parent);
83634                     if (result) {
83635                         return result;
83636                     }
83637                     if (!resolvedRef)
83638                         return undefined;
83639                     (seenResolvedRefs || (seenResolvedRefs = [])).push(resolvedRef);
83640                     return worker(resolvedRef.commandLine.projectReferences, resolvedRef.references, resolvedRef, cbResolvedRef, cbRef);
83641                 });
83642             }
83643         }
83644         function getResolvedProjectReferenceByPath(projectReferencePath) {
83645             if (!projectReferenceRedirects) {
83646                 return undefined;
83647             }
83648             return projectReferenceRedirects.get(projectReferencePath) || undefined;
83649         }
83650         function processReferencedFiles(file, isDefaultLib) {
83651             ts.forEach(file.referencedFiles, function (ref, index) {
83652                 var referencedFileName = resolveTripleslashReference(ref.fileName, file.originalFileName);
83653                 processSourceFile(referencedFileName, isDefaultLib, false, undefined, {
83654                     kind: ts.RefFileKind.ReferenceFile,
83655                     index: index,
83656                     file: file,
83657                     pos: ref.pos,
83658                     end: ref.end
83659                 });
83660             });
83661         }
83662         function processTypeReferenceDirectives(file) {
83663             var typeDirectives = ts.map(file.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
83664             if (!typeDirectives) {
83665                 return;
83666             }
83667             var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeDirectives, file.originalFileName, getResolvedProjectReferenceToRedirect(file.originalFileName));
83668             for (var i = 0; i < typeDirectives.length; i++) {
83669                 var ref = file.typeReferenceDirectives[i];
83670                 var resolvedTypeReferenceDirective = resolutions[i];
83671                 var fileName = ts.toFileNameLowerCase(ref.fileName);
83672                 ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
83673                 processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, {
83674                     kind: ts.RefFileKind.TypeReferenceDirective,
83675                     index: i,
83676                     file: file,
83677                     pos: ref.pos,
83678                     end: ref.end
83679                 });
83680             }
83681         }
83682         function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile) {
83683             var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective);
83684             if (previousResolution && previousResolution.primary) {
83685                 return;
83686             }
83687             var saveResolution = true;
83688             if (resolvedTypeReferenceDirective) {
83689                 if (resolvedTypeReferenceDirective.isExternalLibraryImport)
83690                     currentNodeModulesDepth++;
83691                 if (resolvedTypeReferenceDirective.primary) {
83692                     processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, false, resolvedTypeReferenceDirective.packageId, refFile);
83693                 }
83694                 else {
83695                     if (previousResolution) {
83696                         if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) {
83697                             var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName);
83698                             var existingFile_1 = getSourceFile(previousResolution.resolvedFileName);
83699                             if (otherFileText !== existingFile_1.text) {
83700                                 var refs = !refFile ? refFileMap && refFileMap.get(existingFile_1.path) : undefined;
83701                                 var refToReportErrorOn = refs && ts.find(refs, function (ref) { return ref.referencedFileName === existingFile_1.fileName; });
83702                                 fileProcessingDiagnostics.add(refToReportErrorOn ?
83703                                     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) :
83704                                     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));
83705                             }
83706                         }
83707                         saveResolution = false;
83708                     }
83709                     else {
83710                         processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, false, resolvedTypeReferenceDirective.packageId, refFile);
83711                     }
83712                 }
83713                 if (resolvedTypeReferenceDirective.isExternalLibraryImport)
83714                     currentNodeModulesDepth--;
83715             }
83716             else {
83717                 fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective));
83718             }
83719             if (saveResolution) {
83720                 resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective);
83721             }
83722         }
83723         function processLibReferenceDirectives(file) {
83724             ts.forEach(file.libReferenceDirectives, function (libReference) {
83725                 var libName = ts.toFileNameLowerCase(libReference.fileName);
83726                 var libFileName = ts.libMap.get(libName);
83727                 if (libFileName) {
83728                     processRootFile(ts.combinePaths(defaultLibraryPath, libFileName), true, true);
83729                 }
83730                 else {
83731                     var unqualifiedLibName = ts.removeSuffix(ts.removePrefix(libName, "lib."), ".d.ts");
83732                     var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity);
83733                     var message = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0;
83734                     fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, libReference.pos, libReference.end - libReference.pos, message, libName, suggestion));
83735                 }
83736             });
83737         }
83738         function createRefFileDiagnostic(refFile, message) {
83739             var args = [];
83740             for (var _i = 2; _i < arguments.length; _i++) {
83741                 args[_i - 2] = arguments[_i];
83742             }
83743             if (!refFile) {
83744                 return ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args));
83745             }
83746             else {
83747                 return ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile.file, refFile.pos, refFile.end - refFile.pos, message], args));
83748             }
83749         }
83750         function getCanonicalFileName(fileName) {
83751             return host.getCanonicalFileName(fileName);
83752         }
83753         function processImportedModules(file) {
83754             collectExternalModuleReferences(file);
83755             if (file.imports.length || file.moduleAugmentations.length) {
83756                 var moduleNames = getModuleNames(file);
83757                 var resolutions = resolveModuleNamesReusingOldState(moduleNames, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory), file);
83758                 ts.Debug.assert(resolutions.length === moduleNames.length);
83759                 for (var i = 0; i < moduleNames.length; i++) {
83760                     var resolution = resolutions[i];
83761                     ts.setResolvedModule(file, moduleNames[i], resolution);
83762                     if (!resolution) {
83763                         continue;
83764                     }
83765                     var isFromNodeModulesSearch = resolution.isExternalLibraryImport;
83766                     var isJsFile = !ts.resolutionExtensionIsTSOrJson(resolution.extension);
83767                     var isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile;
83768                     var resolvedFileName = resolution.resolvedFileName;
83769                     if (isFromNodeModulesSearch) {
83770                         currentNodeModulesDepth++;
83771                     }
83772                     var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModuleJsDepth;
83773                     var shouldAddFile = resolvedFileName
83774                         && !getResolutionDiagnostic(options, resolution)
83775                         && !options.noResolve
83776                         && i < file.imports.length
83777                         && !elideImport
83778                         && !(isJsFile && !options.allowJs)
83779                         && (ts.isInJSFile(file.imports[i]) || !(file.imports[i].flags & 4194304));
83780                     if (elideImport) {
83781                         modulesWithElidedImports.set(file.path, true);
83782                     }
83783                     else if (shouldAddFile) {
83784                         var path = toPath(resolvedFileName);
83785                         var pos = ts.skipTrivia(file.text, file.imports[i].pos);
83786                         findSourceFile(resolvedFileName, path, false, false, {
83787                             kind: ts.RefFileKind.Import,
83788                             index: i,
83789                             file: file,
83790                             pos: pos,
83791                             end: file.imports[i].end
83792                         }, resolution.packageId);
83793                     }
83794                     if (isFromNodeModulesSearch) {
83795                         currentNodeModulesDepth--;
83796                     }
83797                 }
83798             }
83799             else {
83800                 file.resolvedModules = undefined;
83801             }
83802         }
83803         function computeCommonSourceDirectory(sourceFiles) {
83804             var fileNames = ts.mapDefined(sourceFiles, function (file) { return file.isDeclarationFile ? undefined : file.fileName; });
83805             return computeCommonSourceDirectoryOfFilenames(fileNames, currentDirectory, getCanonicalFileName);
83806         }
83807         function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) {
83808             var allFilesBelongToPath = true;
83809             var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory));
83810             var rootPaths;
83811             for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) {
83812                 var sourceFile = sourceFiles_2[_i];
83813                 if (!sourceFile.isDeclarationFile) {
83814                     var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory));
83815                     if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) {
83816                         if (!rootPaths)
83817                             rootPaths = ts.arrayToSet(rootNames, toPath);
83818                         addProgramDiagnosticAtRefPath(sourceFile, rootPaths, ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory);
83819                         allFilesBelongToPath = false;
83820                     }
83821                 }
83822             }
83823             return allFilesBelongToPath;
83824         }
83825         function parseProjectReferenceConfigFile(ref) {
83826             if (!projectReferenceRedirects) {
83827                 projectReferenceRedirects = ts.createMap();
83828             }
83829             var refPath = resolveProjectReferencePath(ref);
83830             var sourceFilePath = toPath(refPath);
83831             var fromCache = projectReferenceRedirects.get(sourceFilePath);
83832             if (fromCache !== undefined) {
83833                 return fromCache || undefined;
83834             }
83835             var commandLine;
83836             var sourceFile;
83837             if (host.getParsedCommandLine) {
83838                 commandLine = host.getParsedCommandLine(refPath);
83839                 if (!commandLine) {
83840                     addFileToFilesByName(undefined, sourceFilePath, undefined);
83841                     projectReferenceRedirects.set(sourceFilePath, false);
83842                     return undefined;
83843                 }
83844                 sourceFile = ts.Debug.checkDefined(commandLine.options.configFile);
83845                 ts.Debug.assert(!sourceFile.path || sourceFile.path === sourceFilePath);
83846                 addFileToFilesByName(sourceFile, sourceFilePath, undefined);
83847             }
83848             else {
83849                 var basePath = ts.getNormalizedAbsolutePath(ts.getDirectoryPath(refPath), host.getCurrentDirectory());
83850                 sourceFile = host.getSourceFile(refPath, 100);
83851                 addFileToFilesByName(sourceFile, sourceFilePath, undefined);
83852                 if (sourceFile === undefined) {
83853                     projectReferenceRedirects.set(sourceFilePath, false);
83854                     return undefined;
83855                 }
83856                 commandLine = ts.parseJsonSourceFileConfigFileContent(sourceFile, configParsingHost, basePath, undefined, refPath);
83857             }
83858             sourceFile.fileName = refPath;
83859             sourceFile.path = sourceFilePath;
83860             sourceFile.resolvedPath = sourceFilePath;
83861             sourceFile.originalFileName = refPath;
83862             var resolvedRef = { commandLine: commandLine, sourceFile: sourceFile };
83863             projectReferenceRedirects.set(sourceFilePath, resolvedRef);
83864             if (commandLine.projectReferences) {
83865                 resolvedRef.references = commandLine.projectReferences.map(parseProjectReferenceConfigFile);
83866             }
83867             return resolvedRef;
83868         }
83869         function verifyCompilerOptions() {
83870             if (options.strictPropertyInitialization && !ts.getStrictOptionValue(options, "strictNullChecks")) {
83871                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks");
83872             }
83873             if (options.isolatedModules) {
83874                 if (options.out) {
83875                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules");
83876                 }
83877                 if (options.outFile) {
83878                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules");
83879                 }
83880             }
83881             if (options.inlineSourceMap) {
83882                 if (options.sourceMap) {
83883                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap");
83884                 }
83885                 if (options.mapRoot) {
83886                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap");
83887                 }
83888             }
83889             if (options.paths && options.baseUrl === undefined) {
83890                 createDiagnosticForOptionName(ts.Diagnostics.Option_paths_cannot_be_used_without_specifying_baseUrl_option, "paths");
83891             }
83892             if (options.composite) {
83893                 if (options.declaration === false) {
83894                     createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_declaration_emit, "declaration");
83895                 }
83896                 if (options.incremental === false) {
83897                     createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_incremental_compilation, "declaration");
83898                 }
83899             }
83900             if (options.tsBuildInfoFile) {
83901                 if (!ts.isIncrementalCompilation(options)) {
83902                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "tsBuildInfoFile", "incremental", "composite");
83903                 }
83904             }
83905             else if (options.incremental && !options.outFile && !options.out && !options.configFilePath) {
83906                 programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified));
83907             }
83908             if (!options.listFilesOnly && options.noEmit && ts.isIncrementalCompilation(options)) {
83909                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", options.incremental ? "incremental" : "composite");
83910             }
83911             verifyProjectReferences();
83912             if (options.composite) {
83913                 var rootPaths = ts.arrayToSet(rootNames, toPath);
83914                 for (var _i = 0, files_3 = files; _i < files_3.length; _i++) {
83915                     var file = files_3[_i];
83916                     if (ts.sourceFileMayBeEmitted(file, program) && !rootPaths.has(file.path)) {
83917                         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 || "");
83918                     }
83919                 }
83920             }
83921             if (options.paths) {
83922                 for (var key in options.paths) {
83923                     if (!ts.hasProperty(options.paths, key)) {
83924                         continue;
83925                     }
83926                     if (!ts.hasZeroOrOneAsteriskCharacter(key)) {
83927                         createDiagnosticForOptionPaths(true, key, ts.Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, key);
83928                     }
83929                     if (ts.isArray(options.paths[key])) {
83930                         var len = options.paths[key].length;
83931                         if (len === 0) {
83932                             createDiagnosticForOptionPaths(false, key, ts.Diagnostics.Substitutions_for_pattern_0_shouldn_t_be_an_empty_array, key);
83933                         }
83934                         for (var i = 0; i < len; i++) {
83935                             var subst = options.paths[key][i];
83936                             var typeOfSubst = typeof subst;
83937                             if (typeOfSubst === "string") {
83938                                 if (!ts.hasZeroOrOneAsteriskCharacter(subst)) {
83939                                     createDiagnosticForOptionPathKeyValue(key, i, ts.Diagnostics.Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character, subst, key);
83940                                 }
83941                             }
83942                             else {
83943                                 createDiagnosticForOptionPathKeyValue(key, i, ts.Diagnostics.Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2, subst, key, typeOfSubst);
83944                             }
83945                         }
83946                     }
83947                     else {
83948                         createDiagnosticForOptionPaths(false, key, ts.Diagnostics.Substitutions_for_pattern_0_should_be_an_array, key);
83949                     }
83950                 }
83951             }
83952             if (!options.sourceMap && !options.inlineSourceMap) {
83953                 if (options.inlineSources) {
83954                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided, "inlineSources");
83955                 }
83956                 if (options.sourceRoot) {
83957                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided, "sourceRoot");
83958                 }
83959             }
83960             if (options.out && options.outFile) {
83961                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile");
83962             }
83963             if (options.mapRoot && !(options.sourceMap || options.declarationMap)) {
83964                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "mapRoot", "sourceMap", "declarationMap");
83965             }
83966             if (options.declarationDir) {
83967                 if (!ts.getEmitDeclarations(options)) {
83968                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "declarationDir", "declaration", "composite");
83969                 }
83970                 if (options.out || options.outFile) {
83971                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declarationDir", options.out ? "out" : "outFile");
83972                 }
83973             }
83974             if (options.declarationMap && !ts.getEmitDeclarations(options)) {
83975                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "declarationMap", "declaration", "composite");
83976             }
83977             if (options.lib && options.noLib) {
83978                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "lib", "noLib");
83979             }
83980             if (options.noImplicitUseStrict && ts.getStrictOptionValue(options, "alwaysStrict")) {
83981                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noImplicitUseStrict", "alwaysStrict");
83982             }
83983             var languageVersion = options.target || 0;
83984             var outFile = options.outFile || options.out;
83985             var firstNonAmbientExternalModuleSourceFile = ts.find(files, function (f) { return ts.isExternalModule(f) && !f.isDeclarationFile; });
83986             if (options.isolatedModules) {
83987                 if (options.module === ts.ModuleKind.None && languageVersion < 2) {
83988                     createDiagnosticForOptionName(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher, "isolatedModules", "target");
83989                 }
83990                 var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !ts.isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== 6; });
83991                 if (firstNonExternalModuleSourceFile) {
83992                     var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile);
83993                     programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.All_files_must_be_modules_when_the_isolatedModules_flag_is_provided));
83994                 }
83995             }
83996             else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 && options.module === ts.ModuleKind.None) {
83997                 var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
83998                 programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none));
83999             }
84000             if (outFile && !options.emitDeclarationOnly) {
84001                 if (options.module && !(options.module === ts.ModuleKind.AMD || options.module === ts.ModuleKind.System)) {
84002                     createDiagnosticForOptionName(ts.Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile", "module");
84003                 }
84004                 else if (options.module === undefined && firstNonAmbientExternalModuleSourceFile) {
84005                     var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
84006                     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"));
84007                 }
84008             }
84009             if (options.resolveJsonModule) {
84010                 if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs) {
84011                     createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule");
84012                 }
84013                 else if (!ts.hasJsonModuleEmitEnabled(options)) {
84014                     createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs_amd_es2015_or_esNext, "resolveJsonModule", "module");
84015                 }
84016             }
84017             if (options.outDir ||
84018                 options.sourceRoot ||
84019                 options.mapRoot) {
84020                 var dir = getCommonSourceDirectory();
84021                 if (options.outDir && dir === "" && files.some(function (file) { return ts.getRootLength(file.fileName) > 1; })) {
84022                     createDiagnosticForOptionName(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir");
84023                 }
84024             }
84025             if (options.useDefineForClassFields && languageVersion === 0) {
84026                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields");
84027             }
84028             if (options.checkJs && !options.allowJs) {
84029                 programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "checkJs", "allowJs"));
84030             }
84031             if (options.emitDeclarationOnly) {
84032                 if (!ts.getEmitDeclarations(options)) {
84033                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "emitDeclarationOnly", "declaration", "composite");
84034                 }
84035                 if (options.noEmit) {
84036                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "emitDeclarationOnly", "noEmit");
84037                 }
84038             }
84039             if (options.emitDecoratorMetadata &&
84040                 !options.experimentalDecorators) {
84041                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators");
84042             }
84043             if (options.jsxFactory) {
84044                 if (options.reactNamespace) {
84045                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "reactNamespace", "jsxFactory");
84046                 }
84047                 if (!ts.parseIsolatedEntityName(options.jsxFactory, languageVersion)) {
84048                     createOptionValueDiagnostic("jsxFactory", ts.Diagnostics.Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name, options.jsxFactory);
84049                 }
84050             }
84051             else if (options.reactNamespace && !ts.isIdentifierText(options.reactNamespace, languageVersion)) {
84052                 createOptionValueDiagnostic("reactNamespace", ts.Diagnostics.Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier, options.reactNamespace);
84053             }
84054             if (!options.noEmit && !options.suppressOutputPathCheck) {
84055                 var emitHost = getEmitHost();
84056                 var emitFilesSeen_1 = ts.createMap();
84057                 ts.forEachEmittedFile(emitHost, function (emitFileNames) {
84058                     if (!options.emitDeclarationOnly) {
84059                         verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen_1);
84060                     }
84061                     verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen_1);
84062                 });
84063             }
84064             function verifyEmitFilePath(emitFileName, emitFilesSeen) {
84065                 if (emitFileName) {
84066                     var emitFilePath = toPath(emitFileName);
84067                     if (filesByName.has(emitFilePath)) {
84068                         var chain = void 0;
84069                         if (!options.configFilePath) {
84070                             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);
84071                         }
84072                         chain = ts.chainDiagnosticMessages(chain, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file, emitFileName);
84073                         blockEmittingOfFile(emitFileName, ts.createCompilerDiagnosticFromMessageChain(chain));
84074                     }
84075                     var emitFileKey = !host.useCaseSensitiveFileNames() ? ts.toFileNameLowerCase(emitFilePath) : emitFilePath;
84076                     if (emitFilesSeen.has(emitFileKey)) {
84077                         blockEmittingOfFile(emitFileName, ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files, emitFileName));
84078                     }
84079                     else {
84080                         emitFilesSeen.set(emitFileKey, true);
84081                     }
84082                 }
84083             }
84084         }
84085         function createFileDiagnosticAtReference(refPathToReportErrorOn, message) {
84086             var _a, _b;
84087             var args = [];
84088             for (var _i = 2; _i < arguments.length; _i++) {
84089                 args[_i - 2] = arguments[_i];
84090             }
84091             var refFile = ts.Debug.checkDefined(getSourceFileByPath(refPathToReportErrorOn.file));
84092             var kind = refPathToReportErrorOn.kind, index = refPathToReportErrorOn.index;
84093             var pos, end;
84094             switch (kind) {
84095                 case ts.RefFileKind.Import:
84096                     pos = ts.skipTrivia(refFile.text, refFile.imports[index].pos);
84097                     end = refFile.imports[index].end;
84098                     break;
84099                 case ts.RefFileKind.ReferenceFile:
84100                     (_a = refFile.referencedFiles[index], pos = _a.pos, end = _a.end);
84101                     break;
84102                 case ts.RefFileKind.TypeReferenceDirective:
84103                     (_b = refFile.typeReferenceDirectives[index], pos = _b.pos, end = _b.end);
84104                     break;
84105                 default:
84106                     return ts.Debug.assertNever(kind);
84107             }
84108             return ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile, pos, end - pos, message], args));
84109         }
84110         function addProgramDiagnosticAtRefPath(file, rootPaths, message) {
84111             var args = [];
84112             for (var _i = 3; _i < arguments.length; _i++) {
84113                 args[_i - 3] = arguments[_i];
84114             }
84115             var refPaths = refFileMap && refFileMap.get(file.path);
84116             var refPathToReportErrorOn = ts.forEach(refPaths, function (refPath) { return rootPaths.has(refPath.file) ? refPath : undefined; }) ||
84117                 ts.elementAt(refPaths, 0);
84118             programDiagnostics.add(refPathToReportErrorOn ? createFileDiagnosticAtReference.apply(void 0, __spreadArrays([refPathToReportErrorOn, message], args)) : ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)));
84119         }
84120         function verifyProjectReferences() {
84121             var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getTsBuildInfoEmitOutputFilePath(options) : undefined;
84122             forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) {
84123                 var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index];
84124                 var parentFile = parent && parent.sourceFile;
84125                 if (!resolvedRef) {
84126                     createDiagnosticForReference(parentFile, index, ts.Diagnostics.File_0_not_found, ref.path);
84127                     return;
84128                 }
84129                 var options = resolvedRef.commandLine.options;
84130                 if (!options.composite) {
84131                     var inputs = parent ? parent.commandLine.fileNames : rootNames;
84132                     if (inputs.length) {
84133                         createDiagnosticForReference(parentFile, index, ts.Diagnostics.Referenced_project_0_must_have_setting_composite_Colon_true, ref.path);
84134                     }
84135                 }
84136                 if (ref.prepend) {
84137                     var out = options.outFile || options.out;
84138                     if (out) {
84139                         if (!host.fileExists(out)) {
84140                             createDiagnosticForReference(parentFile, index, ts.Diagnostics.Output_file_0_from_project_1_does_not_exist, out, ref.path);
84141                         }
84142                     }
84143                     else {
84144                         createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path);
84145                     }
84146                 }
84147                 if (!parent && buildInfoPath && buildInfoPath === ts.getTsBuildInfoEmitOutputFilePath(options)) {
84148                     createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1, buildInfoPath, ref.path);
84149                     hasEmitBlockingDiagnostics.set(toPath(buildInfoPath), true);
84150                 }
84151             });
84152         }
84153         function createDiagnosticForOptionPathKeyValue(key, valueIndex, message, arg0, arg1, arg2) {
84154             var needCompilerDiagnostic = true;
84155             var pathsSyntax = getOptionPathsSyntax();
84156             for (var _i = 0, pathsSyntax_1 = pathsSyntax; _i < pathsSyntax_1.length; _i++) {
84157                 var pathProp = pathsSyntax_1[_i];
84158                 if (ts.isObjectLiteralExpression(pathProp.initializer)) {
84159                     for (var _a = 0, _b = ts.getPropertyAssignment(pathProp.initializer, key); _a < _b.length; _a++) {
84160                         var keyProps = _b[_a];
84161                         var initializer = keyProps.initializer;
84162                         if (ts.isArrayLiteralExpression(initializer) && initializer.elements.length > valueIndex) {
84163                             programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(options.configFile, initializer.elements[valueIndex], message, arg0, arg1, arg2));
84164                             needCompilerDiagnostic = false;
84165                         }
84166                     }
84167                 }
84168             }
84169             if (needCompilerDiagnostic) {
84170                 programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0, arg1, arg2));
84171             }
84172         }
84173         function createDiagnosticForOptionPaths(onKey, key, message, arg0) {
84174             var needCompilerDiagnostic = true;
84175             var pathsSyntax = getOptionPathsSyntax();
84176             for (var _i = 0, pathsSyntax_2 = pathsSyntax; _i < pathsSyntax_2.length; _i++) {
84177                 var pathProp = pathsSyntax_2[_i];
84178                 if (ts.isObjectLiteralExpression(pathProp.initializer) &&
84179                     createOptionDiagnosticInObjectLiteralSyntax(pathProp.initializer, onKey, key, undefined, message, arg0)) {
84180                     needCompilerDiagnostic = false;
84181                 }
84182             }
84183             if (needCompilerDiagnostic) {
84184                 programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0));
84185             }
84186         }
84187         function getOptionsSyntaxByName(name) {
84188             var compilerOptionsObjectLiteralSyntax = getCompilerOptionsObjectLiteralSyntax();
84189             if (compilerOptionsObjectLiteralSyntax) {
84190                 return ts.getPropertyAssignment(compilerOptionsObjectLiteralSyntax, name);
84191             }
84192             return undefined;
84193         }
84194         function getOptionPathsSyntax() {
84195             return getOptionsSyntaxByName("paths") || ts.emptyArray;
84196         }
84197         function createDiagnosticForOptionName(message, option1, option2, option3) {
84198             createDiagnosticForOption(true, option1, option2, message, option1, option2, option3);
84199         }
84200         function createOptionValueDiagnostic(option1, message, arg0) {
84201             createDiagnosticForOption(false, option1, undefined, message, arg0);
84202         }
84203         function createDiagnosticForReference(sourceFile, index, message, arg0, arg1) {
84204             var referencesSyntax = ts.firstDefined(ts.getTsConfigPropArray(sourceFile || options.configFile, "references"), function (property) { return ts.isArrayLiteralExpression(property.initializer) ? property.initializer : undefined; });
84205             if (referencesSyntax && referencesSyntax.elements.length > index) {
84206                 programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(sourceFile || options.configFile, referencesSyntax.elements[index], message, arg0, arg1));
84207             }
84208             else {
84209                 programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0, arg1));
84210             }
84211         }
84212         function createDiagnosticForOption(onKey, option1, option2, message, arg0, arg1, arg2) {
84213             var compilerOptionsObjectLiteralSyntax = getCompilerOptionsObjectLiteralSyntax();
84214             var needCompilerDiagnostic = !compilerOptionsObjectLiteralSyntax ||
84215                 !createOptionDiagnosticInObjectLiteralSyntax(compilerOptionsObjectLiteralSyntax, onKey, option1, option2, message, arg0, arg1, arg2);
84216             if (needCompilerDiagnostic) {
84217                 programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0, arg1, arg2));
84218             }
84219         }
84220         function getCompilerOptionsObjectLiteralSyntax() {
84221             if (_compilerOptionsObjectLiteralSyntax === undefined) {
84222                 _compilerOptionsObjectLiteralSyntax = null;
84223                 var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(options.configFile);
84224                 if (jsonObjectLiteral) {
84225                     for (var _i = 0, _a = ts.getPropertyAssignment(jsonObjectLiteral, "compilerOptions"); _i < _a.length; _i++) {
84226                         var prop = _a[_i];
84227                         if (ts.isObjectLiteralExpression(prop.initializer)) {
84228                             _compilerOptionsObjectLiteralSyntax = prop.initializer;
84229                             break;
84230                         }
84231                     }
84232                 }
84233             }
84234             return _compilerOptionsObjectLiteralSyntax;
84235         }
84236         function createOptionDiagnosticInObjectLiteralSyntax(objectLiteral, onKey, key1, key2, message, arg0, arg1, arg2) {
84237             var props = ts.getPropertyAssignment(objectLiteral, key1, key2);
84238             for (var _i = 0, props_3 = props; _i < props_3.length; _i++) {
84239                 var prop = props_3[_i];
84240                 programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(options.configFile, onKey ? prop.name : prop.initializer, message, arg0, arg1, arg2));
84241             }
84242             return !!props.length;
84243         }
84244         function blockEmittingOfFile(emitFileName, diag) {
84245             hasEmitBlockingDiagnostics.set(toPath(emitFileName), true);
84246             programDiagnostics.add(diag);
84247         }
84248         function isEmittedFile(file) {
84249             if (options.noEmit) {
84250                 return false;
84251             }
84252             var filePath = toPath(file);
84253             if (getSourceFileByPath(filePath)) {
84254                 return false;
84255             }
84256             var out = options.outFile || options.out;
84257             if (out) {
84258                 return isSameFile(filePath, out) || isSameFile(filePath, ts.removeFileExtension(out) + ".d.ts");
84259             }
84260             if (options.declarationDir && ts.containsPath(options.declarationDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames())) {
84261                 return true;
84262             }
84263             if (options.outDir) {
84264                 return ts.containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames());
84265             }
84266             if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensions) || ts.fileExtensionIs(filePath, ".d.ts")) {
84267                 var filePathWithoutExtension = ts.removeFileExtension(filePath);
84268                 return !!getSourceFileByPath((filePathWithoutExtension + ".ts")) ||
84269                     !!getSourceFileByPath((filePathWithoutExtension + ".tsx"));
84270             }
84271             return false;
84272         }
84273         function isSameFile(file1, file2) {
84274             return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0;
84275         }
84276         function getProbableSymlinks() {
84277             if (host.getSymlinks) {
84278                 return host.getSymlinks();
84279             }
84280             return symlinks || (symlinks = ts.discoverProbableSymlinks(files, getCanonicalFileName, host.getCurrentDirectory()));
84281         }
84282     }
84283     ts.createProgram = createProgram;
84284     function updateHostForUseSourceOfProjectReferenceRedirect(host) {
84285         var mapOfDeclarationDirectories;
84286         var symlinkedDirectories;
84287         var symlinkedFiles;
84288         var originalFileExists = host.compilerHost.fileExists;
84289         var originalDirectoryExists = host.compilerHost.directoryExists;
84290         var originalGetDirectories = host.compilerHost.getDirectories;
84291         var originalRealpath = host.compilerHost.realpath;
84292         if (!host.useSourceOfProjectReferenceRedirect)
84293             return { onProgramCreateComplete: ts.noop, fileExists: fileExists };
84294         host.compilerHost.fileExists = fileExists;
84295         if (originalDirectoryExists) {
84296             host.compilerHost.directoryExists = function (path) {
84297                 if (originalDirectoryExists.call(host.compilerHost, path)) {
84298                     handleDirectoryCouldBeSymlink(path);
84299                     return true;
84300                 }
84301                 if (!host.getResolvedProjectReferences())
84302                     return false;
84303                 if (!mapOfDeclarationDirectories) {
84304                     mapOfDeclarationDirectories = ts.createMap();
84305                     host.forEachResolvedProjectReference(function (ref) {
84306                         if (!ref)
84307                             return;
84308                         var out = ref.commandLine.options.outFile || ref.commandLine.options.out;
84309                         if (out) {
84310                             mapOfDeclarationDirectories.set(ts.getDirectoryPath(host.toPath(out)), true);
84311                         }
84312                         else {
84313                             var declarationDir = ref.commandLine.options.declarationDir || ref.commandLine.options.outDir;
84314                             if (declarationDir) {
84315                                 mapOfDeclarationDirectories.set(host.toPath(declarationDir), true);
84316                             }
84317                         }
84318                     });
84319                 }
84320                 return fileOrDirectoryExistsUsingSource(path, false);
84321             };
84322         }
84323         if (originalGetDirectories) {
84324             host.compilerHost.getDirectories = function (path) {
84325                 return !host.getResolvedProjectReferences() || (originalDirectoryExists && originalDirectoryExists.call(host.compilerHost, path)) ?
84326                     originalGetDirectories.call(host.compilerHost, path) :
84327                     [];
84328             };
84329         }
84330         if (originalRealpath) {
84331             host.compilerHost.realpath = function (s) {
84332                 return (symlinkedFiles === null || symlinkedFiles === void 0 ? void 0 : symlinkedFiles.get(host.toPath(s))) ||
84333                     originalRealpath.call(host.compilerHost, s);
84334             };
84335         }
84336         return { onProgramCreateComplete: onProgramCreateComplete, fileExists: fileExists };
84337         function onProgramCreateComplete() {
84338             host.compilerHost.fileExists = originalFileExists;
84339             host.compilerHost.directoryExists = originalDirectoryExists;
84340             host.compilerHost.getDirectories = originalGetDirectories;
84341         }
84342         function fileExists(file) {
84343             if (originalFileExists.call(host.compilerHost, file))
84344                 return true;
84345             if (!host.getResolvedProjectReferences())
84346                 return false;
84347             if (!ts.isDeclarationFileName(file))
84348                 return false;
84349             return fileOrDirectoryExistsUsingSource(file, true);
84350         }
84351         function fileExistsIfProjectReferenceDts(file) {
84352             var source = host.getSourceOfProjectReferenceRedirect(file);
84353             return source !== undefined ?
84354                 ts.isString(source) ? originalFileExists.call(host.compilerHost, source) : true :
84355                 undefined;
84356         }
84357         function directoryExistsIfProjectReferenceDeclDir(dir) {
84358             var dirPath = host.toPath(dir);
84359             var dirPathWithTrailingDirectorySeparator = "" + dirPath + ts.directorySeparator;
84360             return ts.forEachKey(mapOfDeclarationDirectories, function (declDirPath) { return dirPath === declDirPath ||
84361                 ts.startsWith(declDirPath, dirPathWithTrailingDirectorySeparator) ||
84362                 ts.startsWith(dirPath, declDirPath + "/"); });
84363         }
84364         function handleDirectoryCouldBeSymlink(directory) {
84365             if (!host.getResolvedProjectReferences())
84366                 return;
84367             if (!originalRealpath || !ts.stringContains(directory, ts.nodeModulesPathPart))
84368                 return;
84369             if (!symlinkedDirectories)
84370                 symlinkedDirectories = ts.createMap();
84371             var directoryPath = ts.ensureTrailingDirectorySeparator(host.toPath(directory));
84372             if (symlinkedDirectories.has(directoryPath))
84373                 return;
84374             var real = ts.normalizePath(originalRealpath.call(host.compilerHost, directory));
84375             var realPath;
84376             if (real === directory ||
84377                 (realPath = ts.ensureTrailingDirectorySeparator(host.toPath(real))) === directoryPath) {
84378                 symlinkedDirectories.set(directoryPath, false);
84379                 return;
84380             }
84381             symlinkedDirectories.set(directoryPath, {
84382                 real: ts.ensureTrailingDirectorySeparator(real),
84383                 realPath: realPath
84384             });
84385         }
84386         function fileOrDirectoryExistsUsingSource(fileOrDirectory, isFile) {
84387             var fileOrDirectoryExistsUsingSource = isFile ?
84388                 function (file) { return fileExistsIfProjectReferenceDts(file); } :
84389                 function (dir) { return directoryExistsIfProjectReferenceDeclDir(dir); };
84390             var result = fileOrDirectoryExistsUsingSource(fileOrDirectory);
84391             if (result !== undefined)
84392                 return result;
84393             if (!symlinkedDirectories)
84394                 return false;
84395             var fileOrDirectoryPath = host.toPath(fileOrDirectory);
84396             if (!ts.stringContains(fileOrDirectoryPath, ts.nodeModulesPathPart))
84397                 return false;
84398             if (isFile && symlinkedFiles && symlinkedFiles.has(fileOrDirectoryPath))
84399                 return true;
84400             return ts.firstDefinedIterator(symlinkedDirectories.entries(), function (_a) {
84401                 var directoryPath = _a[0], symlinkedDirectory = _a[1];
84402                 if (!symlinkedDirectory || !ts.startsWith(fileOrDirectoryPath, directoryPath))
84403                     return undefined;
84404                 var result = fileOrDirectoryExistsUsingSource(fileOrDirectoryPath.replace(directoryPath, symlinkedDirectory.realPath));
84405                 if (isFile && result) {
84406                     if (!symlinkedFiles)
84407                         symlinkedFiles = ts.createMap();
84408                     var absolutePath = ts.getNormalizedAbsolutePath(fileOrDirectory, host.compilerHost.getCurrentDirectory());
84409                     symlinkedFiles.set(fileOrDirectoryPath, "" + symlinkedDirectory.real + absolutePath.replace(new RegExp(directoryPath, "i"), ""));
84410                 }
84411                 return result;
84412             }) || false;
84413         }
84414     }
84415     function handleNoEmitOptions(program, sourceFile, cancellationToken) {
84416         var options = program.getCompilerOptions();
84417         if (options.noEmit) {
84418             return { diagnostics: ts.emptyArray, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true };
84419         }
84420         if (!options.noEmitOnError)
84421             return undefined;
84422         var diagnostics = __spreadArrays(program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken));
84423         if (diagnostics.length === 0 && ts.getEmitDeclarations(program.getCompilerOptions())) {
84424             diagnostics = program.getDeclarationDiagnostics(undefined, cancellationToken);
84425         }
84426         return diagnostics.length > 0 ?
84427             { diagnostics: diagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true } :
84428             undefined;
84429     }
84430     ts.handleNoEmitOptions = handleNoEmitOptions;
84431     function parseConfigHostFromCompilerHostLike(host, directoryStructureHost) {
84432         if (directoryStructureHost === void 0) { directoryStructureHost = host; }
84433         return {
84434             fileExists: function (f) { return directoryStructureHost.fileExists(f); },
84435             readDirectory: function (root, extensions, excludes, includes, depth) {
84436                 ts.Debug.assertIsDefined(directoryStructureHost.readDirectory, "'CompilerHost.readDirectory' must be implemented to correctly process 'projectReferences'");
84437                 return directoryStructureHost.readDirectory(root, extensions, excludes, includes, depth);
84438             },
84439             readFile: function (f) { return directoryStructureHost.readFile(f); },
84440             useCaseSensitiveFileNames: host.useCaseSensitiveFileNames(),
84441             getCurrentDirectory: function () { return host.getCurrentDirectory(); },
84442             onUnRecoverableConfigFileDiagnostic: host.onUnRecoverableConfigFileDiagnostic || ts.returnUndefined,
84443             trace: host.trace ? function (s) { return host.trace(s); } : undefined
84444         };
84445     }
84446     ts.parseConfigHostFromCompilerHostLike = parseConfigHostFromCompilerHostLike;
84447     function createPrependNodes(projectReferences, getCommandLine, readFile) {
84448         if (!projectReferences)
84449             return ts.emptyArray;
84450         var nodes;
84451         for (var i = 0; i < projectReferences.length; i++) {
84452             var ref = projectReferences[i];
84453             var resolvedRefOpts = getCommandLine(ref, i);
84454             if (ref.prepend && resolvedRefOpts && resolvedRefOpts.options) {
84455                 var out = resolvedRefOpts.options.outFile || resolvedRefOpts.options.out;
84456                 if (!out)
84457                     continue;
84458                 var _a = ts.getOutputPathsForBundle(resolvedRefOpts.options, true), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath;
84459                 var node = ts.createInputFiles(readFile, jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath);
84460                 (nodes || (nodes = [])).push(node);
84461             }
84462         }
84463         return nodes || ts.emptyArray;
84464     }
84465     ts.createPrependNodes = createPrependNodes;
84466     function resolveProjectReferencePath(hostOrRef, ref) {
84467         var passedInRef = ref ? ref : hostOrRef;
84468         return ts.resolveConfigFileProjectName(passedInRef.path);
84469     }
84470     ts.resolveProjectReferencePath = resolveProjectReferencePath;
84471     function getResolutionDiagnostic(options, _a) {
84472         var extension = _a.extension;
84473         switch (extension) {
84474             case ".ts":
84475             case ".d.ts":
84476                 return undefined;
84477             case ".tsx":
84478                 return needJsx();
84479             case ".jsx":
84480                 return needJsx() || needAllowJs();
84481             case ".js":
84482                 return needAllowJs();
84483             case ".json":
84484                 return needResolveJsonModule();
84485         }
84486         function needJsx() {
84487             return options.jsx ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set;
84488         }
84489         function needAllowJs() {
84490             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;
84491         }
84492         function needResolveJsonModule() {
84493             return options.resolveJsonModule ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used;
84494         }
84495     }
84496     ts.getResolutionDiagnostic = getResolutionDiagnostic;
84497     function getModuleNames(_a) {
84498         var imports = _a.imports, moduleAugmentations = _a.moduleAugmentations;
84499         var res = imports.map(function (i) { return i.text; });
84500         for (var _i = 0, moduleAugmentations_1 = moduleAugmentations; _i < moduleAugmentations_1.length; _i++) {
84501             var aug = moduleAugmentations_1[_i];
84502             if (aug.kind === 10) {
84503                 res.push(aug.text);
84504             }
84505         }
84506         return res;
84507     }
84508 })(ts || (ts = {}));
84509 var ts;
84510 (function (ts) {
84511     function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) {
84512         var outputFiles = [];
84513         var _a = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit), emitSkipped = _a.emitSkipped, diagnostics = _a.diagnostics, exportedModulesFromDeclarationEmit = _a.exportedModulesFromDeclarationEmit;
84514         return { outputFiles: outputFiles, emitSkipped: emitSkipped, diagnostics: diagnostics, exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit };
84515         function writeFile(fileName, text, writeByteOrderMark) {
84516             outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text });
84517         }
84518     }
84519     ts.getFileEmitOutput = getFileEmitOutput;
84520     var BuilderState;
84521     (function (BuilderState) {
84522         function getReferencedFileFromImportedModuleSymbol(symbol) {
84523             if (symbol.declarations && symbol.declarations[0]) {
84524                 var declarationSourceFile = ts.getSourceFileOfNode(symbol.declarations[0]);
84525                 return declarationSourceFile && declarationSourceFile.resolvedPath;
84526             }
84527         }
84528         function getReferencedFileFromImportLiteral(checker, importName) {
84529             var symbol = checker.getSymbolAtLocation(importName);
84530             return symbol && getReferencedFileFromImportedModuleSymbol(symbol);
84531         }
84532         function getReferencedFileFromFileName(program, fileName, sourceFileDirectory, getCanonicalFileName) {
84533             return ts.toPath(program.getProjectReferenceRedirect(fileName) || fileName, sourceFileDirectory, getCanonicalFileName);
84534         }
84535         function getReferencedFiles(program, sourceFile, getCanonicalFileName) {
84536             var referencedFiles;
84537             if (sourceFile.imports && sourceFile.imports.length > 0) {
84538                 var checker = program.getTypeChecker();
84539                 for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) {
84540                     var importName = _a[_i];
84541                     var declarationSourceFilePath = getReferencedFileFromImportLiteral(checker, importName);
84542                     if (declarationSourceFilePath) {
84543                         addReferencedFile(declarationSourceFilePath);
84544                     }
84545                 }
84546             }
84547             var sourceFileDirectory = ts.getDirectoryPath(sourceFile.resolvedPath);
84548             if (sourceFile.referencedFiles && sourceFile.referencedFiles.length > 0) {
84549                 for (var _b = 0, _c = sourceFile.referencedFiles; _b < _c.length; _b++) {
84550                     var referencedFile = _c[_b];
84551                     var referencedPath = getReferencedFileFromFileName(program, referencedFile.fileName, sourceFileDirectory, getCanonicalFileName);
84552                     addReferencedFile(referencedPath);
84553                 }
84554             }
84555             if (sourceFile.resolvedTypeReferenceDirectiveNames) {
84556                 sourceFile.resolvedTypeReferenceDirectiveNames.forEach(function (resolvedTypeReferenceDirective) {
84557                     if (!resolvedTypeReferenceDirective) {
84558                         return;
84559                     }
84560                     var fileName = resolvedTypeReferenceDirective.resolvedFileName;
84561                     var typeFilePath = getReferencedFileFromFileName(program, fileName, sourceFileDirectory, getCanonicalFileName);
84562                     addReferencedFile(typeFilePath);
84563                 });
84564             }
84565             if (sourceFile.moduleAugmentations.length) {
84566                 var checker = program.getTypeChecker();
84567                 for (var _d = 0, _e = sourceFile.moduleAugmentations; _d < _e.length; _d++) {
84568                     var moduleName = _e[_d];
84569                     if (!ts.isStringLiteral(moduleName)) {
84570                         continue;
84571                     }
84572                     var symbol = checker.getSymbolAtLocation(moduleName);
84573                     if (!symbol) {
84574                         continue;
84575                     }
84576                     addReferenceFromAmbientModule(symbol);
84577                 }
84578             }
84579             for (var _f = 0, _g = program.getTypeChecker().getAmbientModules(); _f < _g.length; _f++) {
84580                 var ambientModule = _g[_f];
84581                 if (ambientModule.declarations.length > 1) {
84582                     addReferenceFromAmbientModule(ambientModule);
84583                 }
84584             }
84585             return referencedFiles;
84586             function addReferenceFromAmbientModule(symbol) {
84587                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
84588                     var declaration = _a[_i];
84589                     var declarationSourceFile = ts.getSourceFileOfNode(declaration);
84590                     if (declarationSourceFile &&
84591                         declarationSourceFile !== sourceFile) {
84592                         addReferencedFile(declarationSourceFile.resolvedPath);
84593                     }
84594                 }
84595             }
84596             function addReferencedFile(referencedPath) {
84597                 if (!referencedFiles) {
84598                     referencedFiles = ts.createMap();
84599                 }
84600                 referencedFiles.set(referencedPath, true);
84601             }
84602         }
84603         function canReuseOldState(newReferencedMap, oldState) {
84604             return oldState && !oldState.referencedMap === !newReferencedMap;
84605         }
84606         BuilderState.canReuseOldState = canReuseOldState;
84607         function create(newProgram, getCanonicalFileName, oldState) {
84608             var fileInfos = ts.createMap();
84609             var referencedMap = newProgram.getCompilerOptions().module !== ts.ModuleKind.None ? ts.createMap() : undefined;
84610             var exportedModulesMap = referencedMap ? ts.createMap() : undefined;
84611             var hasCalledUpdateShapeSignature = ts.createMap();
84612             var useOldState = canReuseOldState(referencedMap, oldState);
84613             for (var _i = 0, _a = newProgram.getSourceFiles(); _i < _a.length; _i++) {
84614                 var sourceFile = _a[_i];
84615                 var version_1 = ts.Debug.checkDefined(sourceFile.version, "Program intended to be used with Builder should have source files with versions set");
84616                 var oldInfo = useOldState ? oldState.fileInfos.get(sourceFile.resolvedPath) : undefined;
84617                 if (referencedMap) {
84618                     var newReferences = getReferencedFiles(newProgram, sourceFile, getCanonicalFileName);
84619                     if (newReferences) {
84620                         referencedMap.set(sourceFile.resolvedPath, newReferences);
84621                     }
84622                     if (useOldState) {
84623                         var exportedModules = oldState.exportedModulesMap.get(sourceFile.resolvedPath);
84624                         if (exportedModules) {
84625                             exportedModulesMap.set(sourceFile.resolvedPath, exportedModules);
84626                         }
84627                     }
84628                 }
84629                 fileInfos.set(sourceFile.resolvedPath, { version: version_1, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) });
84630             }
84631             return {
84632                 fileInfos: fileInfos,
84633                 referencedMap: referencedMap,
84634                 exportedModulesMap: exportedModulesMap,
84635                 hasCalledUpdateShapeSignature: hasCalledUpdateShapeSignature
84636             };
84637         }
84638         BuilderState.create = create;
84639         function releaseCache(state) {
84640             state.allFilesExcludingDefaultLibraryFile = undefined;
84641             state.allFileNames = undefined;
84642         }
84643         BuilderState.releaseCache = releaseCache;
84644         function clone(state) {
84645             var fileInfos = ts.createMap();
84646             state.fileInfos.forEach(function (value, key) {
84647                 fileInfos.set(key, __assign({}, value));
84648             });
84649             return {
84650                 fileInfos: fileInfos,
84651                 referencedMap: cloneMapOrUndefined(state.referencedMap),
84652                 exportedModulesMap: cloneMapOrUndefined(state.exportedModulesMap),
84653                 hasCalledUpdateShapeSignature: ts.cloneMap(state.hasCalledUpdateShapeSignature),
84654             };
84655         }
84656         BuilderState.clone = clone;
84657         function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, cacheToUpdateSignature, exportedModulesMapCache) {
84658             var signatureCache = cacheToUpdateSignature || ts.createMap();
84659             var sourceFile = programOfThisState.getSourceFileByPath(path);
84660             if (!sourceFile) {
84661                 return ts.emptyArray;
84662             }
84663             if (!updateShapeSignature(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache)) {
84664                 return [sourceFile];
84665             }
84666             var result = (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache);
84667             if (!cacheToUpdateSignature) {
84668                 updateSignaturesFromCache(state, signatureCache);
84669             }
84670             return result;
84671         }
84672         BuilderState.getFilesAffectedBy = getFilesAffectedBy;
84673         function updateSignaturesFromCache(state, signatureCache) {
84674             signatureCache.forEach(function (signature, path) { return updateSignatureOfFile(state, signature, path); });
84675         }
84676         BuilderState.updateSignaturesFromCache = updateSignaturesFromCache;
84677         function updateSignatureOfFile(state, signature, path) {
84678             state.fileInfos.get(path).signature = signature;
84679             state.hasCalledUpdateShapeSignature.set(path, true);
84680         }
84681         BuilderState.updateSignatureOfFile = updateSignatureOfFile;
84682         function updateShapeSignature(state, programOfThisState, sourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache) {
84683             ts.Debug.assert(!!sourceFile);
84684             ts.Debug.assert(!exportedModulesMapCache || !!state.exportedModulesMap, "Compute visible to outside map only if visibleToOutsideReferencedMap present in the state");
84685             if (state.hasCalledUpdateShapeSignature.has(sourceFile.resolvedPath) || cacheToUpdateSignature.has(sourceFile.resolvedPath)) {
84686                 return false;
84687             }
84688             var info = state.fileInfos.get(sourceFile.resolvedPath);
84689             if (!info)
84690                 return ts.Debug.fail();
84691             var prevSignature = info.signature;
84692             var latestSignature;
84693             if (sourceFile.isDeclarationFile) {
84694                 latestSignature = sourceFile.version;
84695                 if (exportedModulesMapCache && latestSignature !== prevSignature) {
84696                     var references = state.referencedMap ? state.referencedMap.get(sourceFile.resolvedPath) : undefined;
84697                     exportedModulesMapCache.set(sourceFile.resolvedPath, references || false);
84698                 }
84699             }
84700             else {
84701                 var emitOutput_1 = getFileEmitOutput(programOfThisState, sourceFile, true, cancellationToken, undefined, true);
84702                 var firstDts_1 = emitOutput_1.outputFiles &&
84703                     programOfThisState.getCompilerOptions().declarationMap ?
84704                     emitOutput_1.outputFiles.length > 1 ? emitOutput_1.outputFiles[1] : undefined :
84705                     emitOutput_1.outputFiles.length > 0 ? emitOutput_1.outputFiles[0] : undefined;
84706                 if (firstDts_1) {
84707                     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; })); });
84708                     latestSignature = computeHash(firstDts_1.text);
84709                     if (exportedModulesMapCache && latestSignature !== prevSignature) {
84710                         updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
84711                     }
84712                 }
84713                 else {
84714                     latestSignature = prevSignature;
84715                 }
84716             }
84717             cacheToUpdateSignature.set(sourceFile.resolvedPath, latestSignature);
84718             return !prevSignature || latestSignature !== prevSignature;
84719         }
84720         BuilderState.updateShapeSignature = updateShapeSignature;
84721         function updateExportedModules(sourceFile, exportedModulesFromDeclarationEmit, exportedModulesMapCache) {
84722             if (!exportedModulesFromDeclarationEmit) {
84723                 exportedModulesMapCache.set(sourceFile.resolvedPath, false);
84724                 return;
84725             }
84726             var exportedModules;
84727             exportedModulesFromDeclarationEmit.forEach(function (symbol) { return addExportedModule(getReferencedFileFromImportedModuleSymbol(symbol)); });
84728             exportedModulesMapCache.set(sourceFile.resolvedPath, exportedModules || false);
84729             function addExportedModule(exportedModulePath) {
84730                 if (exportedModulePath) {
84731                     if (!exportedModules) {
84732                         exportedModules = ts.createMap();
84733                     }
84734                     exportedModules.set(exportedModulePath, true);
84735                 }
84736             }
84737         }
84738         function updateExportedFilesMapFromCache(state, exportedModulesMapCache) {
84739             if (exportedModulesMapCache) {
84740                 ts.Debug.assert(!!state.exportedModulesMap);
84741                 exportedModulesMapCache.forEach(function (exportedModules, path) {
84742                     if (exportedModules) {
84743                         state.exportedModulesMap.set(path, exportedModules);
84744                     }
84745                     else {
84746                         state.exportedModulesMap.delete(path);
84747                     }
84748                 });
84749             }
84750         }
84751         BuilderState.updateExportedFilesMapFromCache = updateExportedFilesMapFromCache;
84752         function getAllDependencies(state, programOfThisState, sourceFile) {
84753             var compilerOptions = programOfThisState.getCompilerOptions();
84754             if (compilerOptions.outFile || compilerOptions.out) {
84755                 return getAllFileNames(state, programOfThisState);
84756             }
84757             if (!state.referencedMap || isFileAffectingGlobalScope(sourceFile)) {
84758                 return getAllFileNames(state, programOfThisState);
84759             }
84760             var seenMap = ts.createMap();
84761             var queue = [sourceFile.resolvedPath];
84762             while (queue.length) {
84763                 var path = queue.pop();
84764                 if (!seenMap.has(path)) {
84765                     seenMap.set(path, true);
84766                     var references = state.referencedMap.get(path);
84767                     if (references) {
84768                         var iterator = references.keys();
84769                         for (var iterResult = iterator.next(); !iterResult.done; iterResult = iterator.next()) {
84770                             queue.push(iterResult.value);
84771                         }
84772                     }
84773                 }
84774             }
84775             return ts.arrayFrom(ts.mapDefinedIterator(seenMap.keys(), function (path) {
84776                 var file = programOfThisState.getSourceFileByPath(path);
84777                 return file ? file.fileName : path;
84778             }));
84779         }
84780         BuilderState.getAllDependencies = getAllDependencies;
84781         function getAllFileNames(state, programOfThisState) {
84782             if (!state.allFileNames) {
84783                 var sourceFiles = programOfThisState.getSourceFiles();
84784                 state.allFileNames = sourceFiles === ts.emptyArray ? ts.emptyArray : sourceFiles.map(function (file) { return file.fileName; });
84785             }
84786             return state.allFileNames;
84787         }
84788         function getReferencedByPaths(state, referencedFilePath) {
84789             return ts.arrayFrom(ts.mapDefinedIterator(state.referencedMap.entries(), function (_a) {
84790                 var filePath = _a[0], referencesInFile = _a[1];
84791                 return referencesInFile.has(referencedFilePath) ? filePath : undefined;
84792             }));
84793         }
84794         BuilderState.getReferencedByPaths = getReferencedByPaths;
84795         function containsOnlyAmbientModules(sourceFile) {
84796             for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) {
84797                 var statement = _a[_i];
84798                 if (!ts.isModuleWithStringLiteralName(statement)) {
84799                     return false;
84800                 }
84801             }
84802             return true;
84803         }
84804         function containsGlobalScopeAugmentation(sourceFile) {
84805             return ts.some(sourceFile.moduleAugmentations, function (augmentation) { return ts.isGlobalScopeAugmentation(augmentation.parent); });
84806         }
84807         function isFileAffectingGlobalScope(sourceFile) {
84808             return containsGlobalScopeAugmentation(sourceFile) ||
84809                 !ts.isExternalModule(sourceFile) && !containsOnlyAmbientModules(sourceFile);
84810         }
84811         function getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, firstSourceFile) {
84812             if (state.allFilesExcludingDefaultLibraryFile) {
84813                 return state.allFilesExcludingDefaultLibraryFile;
84814             }
84815             var result;
84816             if (firstSourceFile)
84817                 addSourceFile(firstSourceFile);
84818             for (var _i = 0, _a = programOfThisState.getSourceFiles(); _i < _a.length; _i++) {
84819                 var sourceFile = _a[_i];
84820                 if (sourceFile !== firstSourceFile) {
84821                     addSourceFile(sourceFile);
84822                 }
84823             }
84824             state.allFilesExcludingDefaultLibraryFile = result || ts.emptyArray;
84825             return state.allFilesExcludingDefaultLibraryFile;
84826             function addSourceFile(sourceFile) {
84827                 if (!programOfThisState.isSourceFileDefaultLibrary(sourceFile)) {
84828                     (result || (result = [])).push(sourceFile);
84829                 }
84830             }
84831         }
84832         BuilderState.getAllFilesExcludingDefaultLibraryFile = getAllFilesExcludingDefaultLibraryFile;
84833         function getFilesAffectedByUpdatedShapeWhenNonModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape) {
84834             var compilerOptions = programOfThisState.getCompilerOptions();
84835             if (compilerOptions && (compilerOptions.out || compilerOptions.outFile)) {
84836                 return [sourceFileWithUpdatedShape];
84837             }
84838             return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
84839         }
84840         function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache) {
84841             if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) {
84842                 return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
84843             }
84844             var compilerOptions = programOfThisState.getCompilerOptions();
84845             if (compilerOptions && (compilerOptions.isolatedModules || compilerOptions.out || compilerOptions.outFile)) {
84846                 return [sourceFileWithUpdatedShape];
84847             }
84848             var seenFileNamesMap = ts.createMap();
84849             seenFileNamesMap.set(sourceFileWithUpdatedShape.resolvedPath, sourceFileWithUpdatedShape);
84850             var queue = getReferencedByPaths(state, sourceFileWithUpdatedShape.resolvedPath);
84851             while (queue.length > 0) {
84852                 var currentPath = queue.pop();
84853                 if (!seenFileNamesMap.has(currentPath)) {
84854                     var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath);
84855                     seenFileNamesMap.set(currentPath, currentSourceFile);
84856                     if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache)) {
84857                         queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath));
84858                     }
84859                 }
84860             }
84861             return ts.arrayFrom(ts.mapDefinedIterator(seenFileNamesMap.values(), function (value) { return value; }));
84862         }
84863     })(BuilderState = ts.BuilderState || (ts.BuilderState = {}));
84864     function cloneMapOrUndefined(map) {
84865         return map ? ts.cloneMap(map) : undefined;
84866     }
84867     ts.cloneMapOrUndefined = cloneMapOrUndefined;
84868 })(ts || (ts = {}));
84869 var ts;
84870 (function (ts) {
84871     function hasSameKeys(map1, map2) {
84872         return map1 === map2 || map1 !== undefined && map2 !== undefined && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); });
84873     }
84874     function createBuilderProgramState(newProgram, getCanonicalFileName, oldState) {
84875         var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState);
84876         state.program = newProgram;
84877         var compilerOptions = newProgram.getCompilerOptions();
84878         state.compilerOptions = compilerOptions;
84879         if (!compilerOptions.outFile && !compilerOptions.out) {
84880             state.semanticDiagnosticsPerFile = ts.createMap();
84881         }
84882         state.changedFilesSet = ts.createMap();
84883         var useOldState = ts.BuilderState.canReuseOldState(state.referencedMap, oldState);
84884         var oldCompilerOptions = useOldState ? oldState.compilerOptions : undefined;
84885         var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile &&
84886             !ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions);
84887         if (useOldState) {
84888             if (!oldState.currentChangedFilePath) {
84889                 var affectedSignatures = oldState.currentAffectedFilesSignatures;
84890                 ts.Debug.assert(!oldState.affectedFiles && (!affectedSignatures || !affectedSignatures.size), "Cannot reuse if only few affected files of currentChangedFile were iterated");
84891             }
84892             var changedFilesSet = oldState.changedFilesSet;
84893             if (canCopySemanticDiagnostics) {
84894                 ts.Debug.assert(!changedFilesSet || !ts.forEachKey(changedFilesSet, function (path) { return oldState.semanticDiagnosticsPerFile.has(path); }), "Semantic diagnostics shouldnt be available for changed files");
84895             }
84896             if (changedFilesSet) {
84897                 ts.copyEntries(changedFilesSet, state.changedFilesSet);
84898             }
84899             if (!compilerOptions.outFile && !compilerOptions.out && oldState.affectedFilesPendingEmit) {
84900                 state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice();
84901                 state.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(oldState.affectedFilesPendingEmitKind);
84902                 state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex;
84903                 state.seenAffectedFiles = ts.createMap();
84904             }
84905         }
84906         var referencedMap = state.referencedMap;
84907         var oldReferencedMap = useOldState ? oldState.referencedMap : undefined;
84908         var copyDeclarationFileDiagnostics = canCopySemanticDiagnostics && !compilerOptions.skipLibCheck === !oldCompilerOptions.skipLibCheck;
84909         var copyLibFileDiagnostics = copyDeclarationFileDiagnostics && !compilerOptions.skipDefaultLibCheck === !oldCompilerOptions.skipDefaultLibCheck;
84910         state.fileInfos.forEach(function (info, sourceFilePath) {
84911             var oldInfo;
84912             var newReferences;
84913             if (!useOldState ||
84914                 !(oldInfo = oldState.fileInfos.get(sourceFilePath)) ||
84915                 oldInfo.version !== info.version ||
84916                 !hasSameKeys(newReferences = referencedMap && referencedMap.get(sourceFilePath), oldReferencedMap && oldReferencedMap.get(sourceFilePath)) ||
84917                 newReferences && ts.forEachKey(newReferences, function (path) { return !state.fileInfos.has(path) && oldState.fileInfos.has(path); })) {
84918                 state.changedFilesSet.set(sourceFilePath, true);
84919             }
84920             else if (canCopySemanticDiagnostics) {
84921                 var sourceFile = newProgram.getSourceFileByPath(sourceFilePath);
84922                 if (sourceFile.isDeclarationFile && !copyDeclarationFileDiagnostics) {
84923                     return;
84924                 }
84925                 if (sourceFile.hasNoDefaultLib && !copyLibFileDiagnostics) {
84926                     return;
84927                 }
84928                 var diagnostics = oldState.semanticDiagnosticsPerFile.get(sourceFilePath);
84929                 if (diagnostics) {
84930                     state.semanticDiagnosticsPerFile.set(sourceFilePath, oldState.hasReusableDiagnostic ? convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) : diagnostics);
84931                     if (!state.semanticDiagnosticsFromOldState) {
84932                         state.semanticDiagnosticsFromOldState = ts.createMap();
84933                     }
84934                     state.semanticDiagnosticsFromOldState.set(sourceFilePath, true);
84935                 }
84936             }
84937         });
84938         if (useOldState && ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) { return info.affectsGlobalScope && !state.fileInfos.has(sourceFilePath); })) {
84939             ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, newProgram, undefined)
84940                 .forEach(function (file) { return state.changedFilesSet.set(file.resolvedPath, true); });
84941         }
84942         else if (oldCompilerOptions && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
84943             newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1); });
84944             ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
84945             state.seenAffectedFiles = state.seenAffectedFiles || ts.createMap();
84946         }
84947         state.emittedBuildInfo = !state.changedFilesSet.size && !state.affectedFilesPendingEmit;
84948         return state;
84949     }
84950     function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) {
84951         if (!diagnostics.length)
84952             return ts.emptyArray;
84953         var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory()));
84954         return diagnostics.map(function (diagnostic) {
84955             var result = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath);
84956             result.reportsUnnecessary = diagnostic.reportsUnnecessary;
84957             result.source = diagnostic.source;
84958             var relatedInformation = diagnostic.relatedInformation;
84959             result.relatedInformation = relatedInformation ?
84960                 relatedInformation.length ?
84961                     relatedInformation.map(function (r) { return convertToDiagnosticRelatedInformation(r, newProgram, toPath); }) :
84962                     ts.emptyArray :
84963                 undefined;
84964             return result;
84965         });
84966         function toPath(path) {
84967             return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
84968         }
84969     }
84970     function convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath) {
84971         var file = diagnostic.file;
84972         return __assign(__assign({}, diagnostic), { file: file ? newProgram.getSourceFileByPath(toPath(file)) : undefined });
84973     }
84974     function releaseCache(state) {
84975         ts.BuilderState.releaseCache(state);
84976         state.program = undefined;
84977     }
84978     function cloneBuilderProgramState(state) {
84979         var newState = ts.BuilderState.clone(state);
84980         newState.semanticDiagnosticsPerFile = ts.cloneMapOrUndefined(state.semanticDiagnosticsPerFile);
84981         newState.changedFilesSet = ts.cloneMap(state.changedFilesSet);
84982         newState.affectedFiles = state.affectedFiles;
84983         newState.affectedFilesIndex = state.affectedFilesIndex;
84984         newState.currentChangedFilePath = state.currentChangedFilePath;
84985         newState.currentAffectedFilesSignatures = ts.cloneMapOrUndefined(state.currentAffectedFilesSignatures);
84986         newState.currentAffectedFilesExportedModulesMap = ts.cloneMapOrUndefined(state.currentAffectedFilesExportedModulesMap);
84987         newState.seenAffectedFiles = ts.cloneMapOrUndefined(state.seenAffectedFiles);
84988         newState.cleanedDiagnosticsOfLibFiles = state.cleanedDiagnosticsOfLibFiles;
84989         newState.semanticDiagnosticsFromOldState = ts.cloneMapOrUndefined(state.semanticDiagnosticsFromOldState);
84990         newState.program = state.program;
84991         newState.compilerOptions = state.compilerOptions;
84992         newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice();
84993         newState.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(state.affectedFilesPendingEmitKind);
84994         newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex;
84995         newState.seenEmittedFiles = ts.cloneMapOrUndefined(state.seenEmittedFiles);
84996         newState.programEmitComplete = state.programEmitComplete;
84997         return newState;
84998     }
84999     function assertSourceFileOkWithoutNextAffectedCall(state, sourceFile) {
85000         ts.Debug.assert(!sourceFile || !state.affectedFiles || state.affectedFiles[state.affectedFilesIndex - 1] !== sourceFile || !state.semanticDiagnosticsPerFile.has(sourceFile.resolvedPath));
85001     }
85002     function getNextAffectedFile(state, cancellationToken, computeHash) {
85003         while (true) {
85004             var affectedFiles = state.affectedFiles;
85005             if (affectedFiles) {
85006                 var seenAffectedFiles = state.seenAffectedFiles;
85007                 var affectedFilesIndex = state.affectedFilesIndex;
85008                 while (affectedFilesIndex < affectedFiles.length) {
85009                     var affectedFile = affectedFiles[affectedFilesIndex];
85010                     if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
85011                         state.affectedFilesIndex = affectedFilesIndex;
85012                         handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash);
85013                         return affectedFile;
85014                     }
85015                     affectedFilesIndex++;
85016                 }
85017                 state.changedFilesSet.delete(state.currentChangedFilePath);
85018                 state.currentChangedFilePath = undefined;
85019                 ts.BuilderState.updateSignaturesFromCache(state, state.currentAffectedFilesSignatures);
85020                 state.currentAffectedFilesSignatures.clear();
85021                 ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
85022                 state.affectedFiles = undefined;
85023             }
85024             var nextKey = state.changedFilesSet.keys().next();
85025             if (nextKey.done) {
85026                 return undefined;
85027             }
85028             var program = ts.Debug.checkDefined(state.program);
85029             var compilerOptions = program.getCompilerOptions();
85030             if (compilerOptions.outFile || compilerOptions.out) {
85031                 ts.Debug.assert(!state.semanticDiagnosticsPerFile);
85032                 return program;
85033             }
85034             state.currentAffectedFilesSignatures = state.currentAffectedFilesSignatures || ts.createMap();
85035             if (state.exportedModulesMap) {
85036                 state.currentAffectedFilesExportedModulesMap = state.currentAffectedFilesExportedModulesMap || ts.createMap();
85037             }
85038             state.affectedFiles = ts.BuilderState.getFilesAffectedBy(state, program, nextKey.value, cancellationToken, computeHash, state.currentAffectedFilesSignatures, state.currentAffectedFilesExportedModulesMap);
85039             state.currentChangedFilePath = nextKey.value;
85040             state.affectedFilesIndex = 0;
85041             state.seenAffectedFiles = state.seenAffectedFiles || ts.createMap();
85042         }
85043     }
85044     function getNextAffectedFilePendingEmit(state) {
85045         var affectedFilesPendingEmit = state.affectedFilesPendingEmit;
85046         if (affectedFilesPendingEmit) {
85047             var seenEmittedFiles = state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap());
85048             for (var i = state.affectedFilesPendingEmitIndex; i < affectedFilesPendingEmit.length; i++) {
85049                 var affectedFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(affectedFilesPendingEmit[i]);
85050                 if (affectedFile) {
85051                     var seenKind = seenEmittedFiles.get(affectedFile.resolvedPath);
85052                     var emitKind = ts.Debug.checkDefined(ts.Debug.checkDefined(state.affectedFilesPendingEmitKind).get(affectedFile.resolvedPath));
85053                     if (seenKind === undefined || seenKind < emitKind) {
85054                         state.affectedFilesPendingEmitIndex = i;
85055                         return { affectedFile: affectedFile, emitKind: emitKind };
85056                     }
85057                 }
85058             }
85059             state.affectedFilesPendingEmit = undefined;
85060             state.affectedFilesPendingEmitKind = undefined;
85061             state.affectedFilesPendingEmitIndex = undefined;
85062         }
85063         return undefined;
85064     }
85065     function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash) {
85066         removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
85067         if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
85068             if (!state.cleanedDiagnosticsOfLibFiles) {
85069                 state.cleanedDiagnosticsOfLibFiles = true;
85070                 var program_1 = ts.Debug.checkDefined(state.program);
85071                 var options_2 = program_1.getCompilerOptions();
85072                 ts.forEach(program_1.getSourceFiles(), function (f) {
85073                     return program_1.isSourceFileDefaultLibrary(f) &&
85074                         !ts.skipTypeChecking(f, options_2, program_1) &&
85075                         removeSemanticDiagnosticsOf(state, f.resolvedPath);
85076                 });
85077             }
85078             return;
85079         }
85080         if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) {
85081             forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash); });
85082         }
85083     }
85084     function handleDtsMayChangeOf(state, path, cancellationToken, computeHash) {
85085         removeSemanticDiagnosticsOf(state, path);
85086         if (!state.changedFilesSet.has(path)) {
85087             var program = ts.Debug.checkDefined(state.program);
85088             var sourceFile = program.getSourceFileByPath(path);
85089             if (sourceFile) {
85090                 ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap);
85091                 if (ts.getEmitDeclarations(state.compilerOptions)) {
85092                     addToAffectedFilesPendingEmit(state, path, 0);
85093                 }
85094             }
85095         }
85096         return false;
85097     }
85098     function removeSemanticDiagnosticsOf(state, path) {
85099         if (!state.semanticDiagnosticsFromOldState) {
85100             return true;
85101         }
85102         state.semanticDiagnosticsFromOldState.delete(path);
85103         state.semanticDiagnosticsPerFile.delete(path);
85104         return !state.semanticDiagnosticsFromOldState.size;
85105     }
85106     function isChangedSignagure(state, path) {
85107         var newSignature = ts.Debug.checkDefined(state.currentAffectedFilesSignatures).get(path);
85108         var oldSignagure = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
85109         return newSignature !== oldSignagure;
85110     }
85111     function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) {
85112         if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) {
85113             return;
85114         }
85115         if (!isChangedSignagure(state, affectedFile.resolvedPath))
85116             return;
85117         if (state.compilerOptions.isolatedModules) {
85118             var seenFileNamesMap = ts.createMap();
85119             seenFileNamesMap.set(affectedFile.resolvedPath, true);
85120             var queue = ts.BuilderState.getReferencedByPaths(state, affectedFile.resolvedPath);
85121             while (queue.length > 0) {
85122                 var currentPath = queue.pop();
85123                 if (!seenFileNamesMap.has(currentPath)) {
85124                     seenFileNamesMap.set(currentPath, true);
85125                     var result = fn(state, currentPath);
85126                     if (result && isChangedSignagure(state, currentPath)) {
85127                         var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
85128                         queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
85129                     }
85130                 }
85131             }
85132         }
85133         ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
85134         var seenFileAndExportsOfFile = ts.createMap();
85135         if (ts.forEachEntry(state.currentAffectedFilesExportedModulesMap, function (exportedModules, exportedFromPath) {
85136             return exportedModules &&
85137                 exportedModules.has(affectedFile.resolvedPath) &&
85138                 forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
85139         })) {
85140             return;
85141         }
85142         ts.forEachEntry(state.exportedModulesMap, function (exportedModules, exportedFromPath) {
85143             return !state.currentAffectedFilesExportedModulesMap.has(exportedFromPath) &&
85144                 exportedModules.has(affectedFile.resolvedPath) &&
85145                 forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
85146         });
85147     }
85148     function forEachFilesReferencingPath(state, referencedPath, seenFileAndExportsOfFile, fn) {
85149         return ts.forEachEntry(state.referencedMap, function (referencesInFile, filePath) {
85150             return referencesInFile.has(referencedPath) && forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn);
85151         });
85152     }
85153     function forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn) {
85154         if (!ts.addToSeen(seenFileAndExportsOfFile, filePath)) {
85155             return false;
85156         }
85157         if (fn(state, filePath)) {
85158             return true;
85159         }
85160         ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
85161         if (ts.forEachEntry(state.currentAffectedFilesExportedModulesMap, function (exportedModules, exportedFromPath) {
85162             return exportedModules &&
85163                 exportedModules.has(filePath) &&
85164                 forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
85165         })) {
85166             return true;
85167         }
85168         if (ts.forEachEntry(state.exportedModulesMap, function (exportedModules, exportedFromPath) {
85169             return !state.currentAffectedFilesExportedModulesMap.has(exportedFromPath) &&
85170                 exportedModules.has(filePath) &&
85171                 forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
85172         })) {
85173             return true;
85174         }
85175         return !!ts.forEachEntry(state.referencedMap, function (referencesInFile, referencingFilePath) {
85176             return referencesInFile.has(filePath) &&
85177                 !seenFileAndExportsOfFile.has(referencingFilePath) &&
85178                 fn(state, referencingFilePath);
85179         });
85180     }
85181     function doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit) {
85182         if (isBuildInfoEmit) {
85183             state.emittedBuildInfo = true;
85184         }
85185         else if (affected === state.program) {
85186             state.changedFilesSet.clear();
85187             state.programEmitComplete = true;
85188         }
85189         else {
85190             state.seenAffectedFiles.set(affected.resolvedPath, true);
85191             if (emitKind !== undefined) {
85192                 (state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap())).set(affected.resolvedPath, emitKind);
85193             }
85194             if (isPendingEmit) {
85195                 state.affectedFilesPendingEmitIndex++;
85196             }
85197             else {
85198                 state.affectedFilesIndex++;
85199             }
85200         }
85201     }
85202     function toAffectedFileResult(state, result, affected) {
85203         doneWithAffectedFile(state, affected);
85204         return { result: result, affected: affected };
85205     }
85206     function toAffectedFileEmitResult(state, result, affected, emitKind, isPendingEmit, isBuildInfoEmit) {
85207         doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit);
85208         return { result: result, affected: affected };
85209     }
85210     function getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken) {
85211         return ts.concatenate(getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationToken), ts.Debug.checkDefined(state.program).getProgramDiagnostics(sourceFile));
85212     }
85213     function getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationToken) {
85214         var path = sourceFile.resolvedPath;
85215         if (state.semanticDiagnosticsPerFile) {
85216             var cachedDiagnostics = state.semanticDiagnosticsPerFile.get(path);
85217             if (cachedDiagnostics) {
85218                 return cachedDiagnostics;
85219             }
85220         }
85221         var diagnostics = ts.Debug.checkDefined(state.program).getBindAndCheckDiagnostics(sourceFile, cancellationToken);
85222         if (state.semanticDiagnosticsPerFile) {
85223             state.semanticDiagnosticsPerFile.set(path, diagnostics);
85224         }
85225         return diagnostics;
85226     }
85227     function getProgramBuildInfo(state, getCanonicalFileName) {
85228         if (state.compilerOptions.outFile || state.compilerOptions.out)
85229             return undefined;
85230         var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory();
85231         var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
85232         var fileInfos = {};
85233         state.fileInfos.forEach(function (value, key) {
85234             var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key);
85235             fileInfos[relativeToBuildInfo(key)] = signature === undefined ? value : { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope };
85236         });
85237         var result = {
85238             fileInfos: fileInfos,
85239             options: convertToReusableCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath)
85240         };
85241         if (state.referencedMap) {
85242             var referencedMap = {};
85243             for (var _i = 0, _a = ts.arrayFrom(state.referencedMap.keys()).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) {
85244                 var key = _a[_i];
85245                 referencedMap[relativeToBuildInfo(key)] = ts.arrayFrom(state.referencedMap.get(key).keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive);
85246             }
85247             result.referencedMap = referencedMap;
85248         }
85249         if (state.exportedModulesMap) {
85250             var exportedModulesMap = {};
85251             for (var _b = 0, _c = ts.arrayFrom(state.exportedModulesMap.keys()).sort(ts.compareStringsCaseSensitive); _b < _c.length; _b++) {
85252                 var key = _c[_b];
85253                 var newValue = state.currentAffectedFilesExportedModulesMap && state.currentAffectedFilesExportedModulesMap.get(key);
85254                 if (newValue === undefined)
85255                     exportedModulesMap[relativeToBuildInfo(key)] = ts.arrayFrom(state.exportedModulesMap.get(key).keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive);
85256                 else if (newValue)
85257                     exportedModulesMap[relativeToBuildInfo(key)] = ts.arrayFrom(newValue.keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive);
85258             }
85259             result.exportedModulesMap = exportedModulesMap;
85260         }
85261         if (state.semanticDiagnosticsPerFile) {
85262             var semanticDiagnosticsPerFile = [];
85263             for (var _d = 0, _e = ts.arrayFrom(state.semanticDiagnosticsPerFile.keys()).sort(ts.compareStringsCaseSensitive); _d < _e.length; _d++) {
85264                 var key = _e[_d];
85265                 var value = state.semanticDiagnosticsPerFile.get(key);
85266                 semanticDiagnosticsPerFile.push(value.length ?
85267                     [
85268                         relativeToBuildInfo(key),
85269                         state.hasReusableDiagnostic ?
85270                             value :
85271                             convertToReusableDiagnostics(value, relativeToBuildInfo)
85272                     ] :
85273                     relativeToBuildInfo(key));
85274             }
85275             result.semanticDiagnosticsPerFile = semanticDiagnosticsPerFile;
85276         }
85277         return result;
85278         function relativeToBuildInfoEnsuringAbsolutePath(path) {
85279             return relativeToBuildInfo(ts.getNormalizedAbsolutePath(path, currentDirectory));
85280         }
85281         function relativeToBuildInfo(path) {
85282             return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(buildInfoDirectory, path, getCanonicalFileName));
85283         }
85284     }
85285     function convertToReusableCompilerOptions(options, relativeToBuildInfo) {
85286         var result = {};
85287         var optionsNameMap = ts.getOptionsNameMap().optionsNameMap;
85288         for (var name in options) {
85289             if (ts.hasProperty(options, name)) {
85290                 result[name] = convertToReusableCompilerOptionValue(optionsNameMap.get(name.toLowerCase()), options[name], relativeToBuildInfo);
85291             }
85292         }
85293         if (result.configFilePath) {
85294             result.configFilePath = relativeToBuildInfo(result.configFilePath);
85295         }
85296         return result;
85297     }
85298     function convertToReusableCompilerOptionValue(option, value, relativeToBuildInfo) {
85299         if (option) {
85300             if (option.type === "list") {
85301                 var values = value;
85302                 if (option.element.isFilePath && values.length) {
85303                     return values.map(relativeToBuildInfo);
85304                 }
85305             }
85306             else if (option.isFilePath) {
85307                 return relativeToBuildInfo(value);
85308             }
85309         }
85310         return value;
85311     }
85312     function convertToReusableDiagnostics(diagnostics, relativeToBuildInfo) {
85313         ts.Debug.assert(!!diagnostics.length);
85314         return diagnostics.map(function (diagnostic) {
85315             var result = convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo);
85316             result.reportsUnnecessary = diagnostic.reportsUnnecessary;
85317             result.source = diagnostic.source;
85318             var relatedInformation = diagnostic.relatedInformation;
85319             result.relatedInformation = relatedInformation ?
85320                 relatedInformation.length ?
85321                     relatedInformation.map(function (r) { return convertToReusableDiagnosticRelatedInformation(r, relativeToBuildInfo); }) :
85322                     ts.emptyArray :
85323                 undefined;
85324             return result;
85325         });
85326     }
85327     function convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo) {
85328         var file = diagnostic.file;
85329         return __assign(__assign({}, diagnostic), { file: file ? relativeToBuildInfo(file.resolvedPath) : undefined });
85330     }
85331     var BuilderProgramKind;
85332     (function (BuilderProgramKind) {
85333         BuilderProgramKind[BuilderProgramKind["SemanticDiagnosticsBuilderProgram"] = 0] = "SemanticDiagnosticsBuilderProgram";
85334         BuilderProgramKind[BuilderProgramKind["EmitAndSemanticDiagnosticsBuilderProgram"] = 1] = "EmitAndSemanticDiagnosticsBuilderProgram";
85335     })(BuilderProgramKind = ts.BuilderProgramKind || (ts.BuilderProgramKind = {}));
85336     function getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
85337         var host;
85338         var newProgram;
85339         var oldProgram;
85340         if (newProgramOrRootNames === undefined) {
85341             ts.Debug.assert(hostOrOptions === undefined);
85342             host = oldProgramOrHost;
85343             oldProgram = configFileParsingDiagnosticsOrOldProgram;
85344             ts.Debug.assert(!!oldProgram);
85345             newProgram = oldProgram.getProgram();
85346         }
85347         else if (ts.isArray(newProgramOrRootNames)) {
85348             oldProgram = configFileParsingDiagnosticsOrOldProgram;
85349             newProgram = ts.createProgram({
85350                 rootNames: newProgramOrRootNames,
85351                 options: hostOrOptions,
85352                 host: oldProgramOrHost,
85353                 oldProgram: oldProgram && oldProgram.getProgramOrUndefined(),
85354                 configFileParsingDiagnostics: configFileParsingDiagnostics,
85355                 projectReferences: projectReferences
85356             });
85357             host = oldProgramOrHost;
85358         }
85359         else {
85360             newProgram = newProgramOrRootNames;
85361             host = hostOrOptions;
85362             oldProgram = oldProgramOrHost;
85363             configFileParsingDiagnostics = configFileParsingDiagnosticsOrOldProgram;
85364         }
85365         return { host: host, newProgram: newProgram, oldProgram: oldProgram, configFileParsingDiagnostics: configFileParsingDiagnostics || ts.emptyArray };
85366     }
85367     ts.getBuilderCreationParameters = getBuilderCreationParameters;
85368     function createBuilderProgram(kind, _a) {
85369         var newProgram = _a.newProgram, host = _a.host, oldProgram = _a.oldProgram, configFileParsingDiagnostics = _a.configFileParsingDiagnostics;
85370         var oldState = oldProgram && oldProgram.getState();
85371         if (oldState && newProgram === oldState.program && configFileParsingDiagnostics === newProgram.getConfigFileParsingDiagnostics()) {
85372             newProgram = undefined;
85373             oldState = undefined;
85374             return oldProgram;
85375         }
85376         var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
85377         var computeHash = host.createHash || ts.generateDjb2Hash;
85378         var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState);
85379         var backupState;
85380         newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); };
85381         newProgram = undefined;
85382         oldProgram = undefined;
85383         oldState = undefined;
85384         var builderProgram = createRedirectedBuilderProgram(state, configFileParsingDiagnostics);
85385         builderProgram.getState = function () { return state; };
85386         builderProgram.backupState = function () {
85387             ts.Debug.assert(backupState === undefined);
85388             backupState = cloneBuilderProgramState(state);
85389         };
85390         builderProgram.restoreState = function () {
85391             state = ts.Debug.checkDefined(backupState);
85392             backupState = undefined;
85393         };
85394         builderProgram.getAllDependencies = function (sourceFile) { return ts.BuilderState.getAllDependencies(state, ts.Debug.checkDefined(state.program), sourceFile); };
85395         builderProgram.getSemanticDiagnostics = getSemanticDiagnostics;
85396         builderProgram.emit = emit;
85397         builderProgram.releaseProgram = function () {
85398             releaseCache(state);
85399             backupState = undefined;
85400         };
85401         if (kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram) {
85402             builderProgram.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile;
85403         }
85404         else if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
85405             builderProgram.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile;
85406             builderProgram.emitNextAffectedFile = emitNextAffectedFile;
85407         }
85408         else {
85409             ts.notImplemented();
85410         }
85411         return builderProgram;
85412         function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
85413             var affected = getNextAffectedFile(state, cancellationToken, computeHash);
85414             var emitKind = 1;
85415             var isPendingEmitFile = false;
85416             if (!affected) {
85417                 if (!state.compilerOptions.out && !state.compilerOptions.outFile) {
85418                     var pendingAffectedFile = getNextAffectedFilePendingEmit(state);
85419                     if (!pendingAffectedFile) {
85420                         if (state.emittedBuildInfo) {
85421                             return undefined;
85422                         }
85423                         var affected_1 = ts.Debug.checkDefined(state.program);
85424                         return toAffectedFileEmitResult(state, affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1, false, true);
85425                     }
85426                     (affected = pendingAffectedFile.affectedFile, emitKind = pendingAffectedFile.emitKind);
85427                     isPendingEmitFile = true;
85428                 }
85429                 else {
85430                     var program = ts.Debug.checkDefined(state.program);
85431                     if (state.programEmitComplete)
85432                         return undefined;
85433                     affected = program;
85434                 }
85435             }
85436             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);
85437         }
85438         function emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
85439             if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
85440                 assertSourceFileOkWithoutNextAffectedCall(state, targetSourceFile);
85441                 var result = ts.handleNoEmitOptions(builderProgram, targetSourceFile, cancellationToken);
85442                 if (result)
85443                     return result;
85444                 if (!targetSourceFile) {
85445                     var sourceMaps = [];
85446                     var emitSkipped = false;
85447                     var diagnostics = void 0;
85448                     var emittedFiles = [];
85449                     var affectedEmitResult = void 0;
85450                     while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) {
85451                         emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped;
85452                         diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics);
85453                         emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles);
85454                         sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps);
85455                     }
85456                     return {
85457                         emitSkipped: emitSkipped,
85458                         diagnostics: diagnostics || ts.emptyArray,
85459                         emittedFiles: emittedFiles,
85460                         sourceMaps: sourceMaps
85461                     };
85462                 }
85463             }
85464             return ts.Debug.checkDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
85465         }
85466         function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
85467             while (true) {
85468                 var affected = getNextAffectedFile(state, cancellationToken, computeHash);
85469                 if (!affected) {
85470                     return undefined;
85471                 }
85472                 else if (affected === state.program) {
85473                     return toAffectedFileResult(state, state.program.getSemanticDiagnostics(undefined, cancellationToken), affected);
85474                 }
85475                 if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
85476                     addToAffectedFilesPendingEmit(state, affected.resolvedPath, 1);
85477                 }
85478                 if (ignoreSourceFile && ignoreSourceFile(affected)) {
85479                     doneWithAffectedFile(state, affected);
85480                     continue;
85481                 }
85482                 return toAffectedFileResult(state, getSemanticDiagnosticsOfFile(state, affected, cancellationToken), affected);
85483             }
85484         }
85485         function getSemanticDiagnostics(sourceFile, cancellationToken) {
85486             assertSourceFileOkWithoutNextAffectedCall(state, sourceFile);
85487             var compilerOptions = ts.Debug.checkDefined(state.program).getCompilerOptions();
85488             if (compilerOptions.outFile || compilerOptions.out) {
85489                 ts.Debug.assert(!state.semanticDiagnosticsPerFile);
85490                 return ts.Debug.checkDefined(state.program).getSemanticDiagnostics(sourceFile, cancellationToken);
85491             }
85492             if (sourceFile) {
85493                 return getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken);
85494             }
85495             while (getSemanticDiagnosticsOfNextAffectedFile(cancellationToken)) {
85496             }
85497             var diagnostics;
85498             for (var _i = 0, _a = ts.Debug.checkDefined(state.program).getSourceFiles(); _i < _a.length; _i++) {
85499                 var sourceFile_1 = _a[_i];
85500                 diagnostics = ts.addRange(diagnostics, getSemanticDiagnosticsOfFile(state, sourceFile_1, cancellationToken));
85501             }
85502             return diagnostics || ts.emptyArray;
85503         }
85504     }
85505     ts.createBuilderProgram = createBuilderProgram;
85506     function addToAffectedFilesPendingEmit(state, affectedFilePendingEmit, kind) {
85507         if (!state.affectedFilesPendingEmit)
85508             state.affectedFilesPendingEmit = [];
85509         if (!state.affectedFilesPendingEmitKind)
85510             state.affectedFilesPendingEmitKind = ts.createMap();
85511         var existingKind = state.affectedFilesPendingEmitKind.get(affectedFilePendingEmit);
85512         state.affectedFilesPendingEmit.push(affectedFilePendingEmit);
85513         state.affectedFilesPendingEmitKind.set(affectedFilePendingEmit, existingKind || kind);
85514         if (state.affectedFilesPendingEmitIndex === undefined) {
85515             state.affectedFilesPendingEmitIndex = 0;
85516         }
85517     }
85518     function getMapOfReferencedSet(mapLike, toPath) {
85519         if (!mapLike)
85520             return undefined;
85521         var map = ts.createMap();
85522         for (var key in mapLike) {
85523             if (ts.hasProperty(mapLike, key)) {
85524                 map.set(toPath(key), ts.arrayToSet(mapLike[key], toPath));
85525             }
85526         }
85527         return map;
85528     }
85529     function createBuildProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
85530         var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
85531         var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
85532         var fileInfos = ts.createMap();
85533         for (var key in program.fileInfos) {
85534             if (ts.hasProperty(program.fileInfos, key)) {
85535                 fileInfos.set(toPath(key), program.fileInfos[key]);
85536             }
85537         }
85538         var state = {
85539             fileInfos: fileInfos,
85540             compilerOptions: ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath),
85541             referencedMap: getMapOfReferencedSet(program.referencedMap, toPath),
85542             exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap, toPath),
85543             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]; }),
85544             hasReusableDiagnostic: true
85545         };
85546         return {
85547             getState: function () { return state; },
85548             backupState: ts.noop,
85549             restoreState: ts.noop,
85550             getProgram: ts.notImplemented,
85551             getProgramOrUndefined: ts.returnUndefined,
85552             releaseProgram: ts.noop,
85553             getCompilerOptions: function () { return state.compilerOptions; },
85554             getSourceFile: ts.notImplemented,
85555             getSourceFiles: ts.notImplemented,
85556             getOptionsDiagnostics: ts.notImplemented,
85557             getGlobalDiagnostics: ts.notImplemented,
85558             getConfigFileParsingDiagnostics: ts.notImplemented,
85559             getSyntacticDiagnostics: ts.notImplemented,
85560             getDeclarationDiagnostics: ts.notImplemented,
85561             getSemanticDiagnostics: ts.notImplemented,
85562             emit: ts.notImplemented,
85563             getAllDependencies: ts.notImplemented,
85564             getCurrentDirectory: ts.notImplemented,
85565             emitNextAffectedFile: ts.notImplemented,
85566             getSemanticDiagnosticsOfNextAffectedFile: ts.notImplemented,
85567             close: ts.noop,
85568         };
85569         function toPath(path) {
85570             return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
85571         }
85572         function toAbsolutePath(path) {
85573             return ts.getNormalizedAbsolutePath(path, buildInfoDirectory);
85574         }
85575     }
85576     ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo;
85577     function createRedirectedBuilderProgram(state, configFileParsingDiagnostics) {
85578         return {
85579             getState: ts.notImplemented,
85580             backupState: ts.noop,
85581             restoreState: ts.noop,
85582             getProgram: getProgram,
85583             getProgramOrUndefined: function () { return state.program; },
85584             releaseProgram: function () { return state.program = undefined; },
85585             getCompilerOptions: function () { return state.compilerOptions; },
85586             getSourceFile: function (fileName) { return getProgram().getSourceFile(fileName); },
85587             getSourceFiles: function () { return getProgram().getSourceFiles(); },
85588             getOptionsDiagnostics: function (cancellationToken) { return getProgram().getOptionsDiagnostics(cancellationToken); },
85589             getGlobalDiagnostics: function (cancellationToken) { return getProgram().getGlobalDiagnostics(cancellationToken); },
85590             getConfigFileParsingDiagnostics: function () { return configFileParsingDiagnostics; },
85591             getSyntacticDiagnostics: function (sourceFile, cancellationToken) { return getProgram().getSyntacticDiagnostics(sourceFile, cancellationToken); },
85592             getDeclarationDiagnostics: function (sourceFile, cancellationToken) { return getProgram().getDeclarationDiagnostics(sourceFile, cancellationToken); },
85593             getSemanticDiagnostics: function (sourceFile, cancellationToken) { return getProgram().getSemanticDiagnostics(sourceFile, cancellationToken); },
85594             emit: function (sourceFile, writeFile, cancellationToken, emitOnlyDts, customTransformers) { return getProgram().emit(sourceFile, writeFile, cancellationToken, emitOnlyDts, customTransformers); },
85595             getAllDependencies: ts.notImplemented,
85596             getCurrentDirectory: function () { return getProgram().getCurrentDirectory(); },
85597             close: ts.noop,
85598         };
85599         function getProgram() {
85600             return ts.Debug.checkDefined(state.program);
85601         }
85602     }
85603     ts.createRedirectedBuilderProgram = createRedirectedBuilderProgram;
85604 })(ts || (ts = {}));
85605 var ts;
85606 (function (ts) {
85607     function createSemanticDiagnosticsBuilderProgram(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
85608         return ts.createBuilderProgram(ts.BuilderProgramKind.SemanticDiagnosticsBuilderProgram, ts.getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences));
85609     }
85610     ts.createSemanticDiagnosticsBuilderProgram = createSemanticDiagnosticsBuilderProgram;
85611     function createEmitAndSemanticDiagnosticsBuilderProgram(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
85612         return ts.createBuilderProgram(ts.BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram, ts.getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences));
85613     }
85614     ts.createEmitAndSemanticDiagnosticsBuilderProgram = createEmitAndSemanticDiagnosticsBuilderProgram;
85615     function createAbstractBuilder(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
85616         var _a = ts.getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences), newProgram = _a.newProgram, newConfigFileParsingDiagnostics = _a.configFileParsingDiagnostics;
85617         return ts.createRedirectedBuilderProgram({ program: newProgram, compilerOptions: newProgram.getCompilerOptions() }, newConfigFileParsingDiagnostics);
85618     }
85619     ts.createAbstractBuilder = createAbstractBuilder;
85620 })(ts || (ts = {}));
85621 var ts;
85622 (function (ts) {
85623     function removeIgnoredPath(path) {
85624         if (ts.endsWith(path, "/node_modules/.staging")) {
85625             return ts.removeSuffix(path, "/.staging");
85626         }
85627         return ts.some(ts.ignoredPaths, function (searchPath) { return ts.stringContains(path, searchPath); }) ?
85628             undefined :
85629             path;
85630     }
85631     ts.removeIgnoredPath = removeIgnoredPath;
85632     function canWatchDirectory(dirPath) {
85633         var rootLength = ts.getRootLength(dirPath);
85634         if (dirPath.length === rootLength) {
85635             return false;
85636         }
85637         var nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, rootLength);
85638         if (nextDirectorySeparator === -1) {
85639             return false;
85640         }
85641         var pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1);
85642         var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47;
85643         if (isNonDirectorySeparatorRoot &&
85644             dirPath.search(/[a-zA-Z]:/) !== 0 &&
85645             pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) {
85646             nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, nextDirectorySeparator + 1);
85647             if (nextDirectorySeparator === -1) {
85648                 return false;
85649             }
85650             pathPartForUserCheck = dirPath.substring(rootLength + pathPartForUserCheck.length, nextDirectorySeparator + 1);
85651         }
85652         if (isNonDirectorySeparatorRoot &&
85653             pathPartForUserCheck.search(/users\//i) !== 0) {
85654             return true;
85655         }
85656         for (var searchIndex = nextDirectorySeparator + 1, searchLevels = 2; searchLevels > 0; searchLevels--) {
85657             searchIndex = dirPath.indexOf(ts.directorySeparator, searchIndex) + 1;
85658             if (searchIndex === 0) {
85659                 return false;
85660             }
85661         }
85662         return true;
85663     }
85664     ts.canWatchDirectory = canWatchDirectory;
85665     function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) {
85666         var filesWithChangedSetOfUnresolvedImports;
85667         var filesWithInvalidatedResolutions;
85668         var filesWithInvalidatedNonRelativeUnresolvedImports;
85669         var nonRelativeExternalModuleResolutions = ts.createMultiMap();
85670         var resolutionsWithFailedLookups = [];
85671         var resolvedFileToResolution = ts.createMultiMap();
85672         var getCurrentDirectory = ts.memoize(function () { return resolutionHost.getCurrentDirectory(); });
85673         var cachedDirectoryStructureHost = resolutionHost.getCachedDirectoryStructureHost();
85674         var resolvedModuleNames = ts.createMap();
85675         var perDirectoryResolvedModuleNames = ts.createCacheWithRedirects();
85676         var nonRelativeModuleNameCache = ts.createCacheWithRedirects();
85677         var moduleResolutionCache = ts.createModuleResolutionCacheWithMaps(perDirectoryResolvedModuleNames, nonRelativeModuleNameCache, getCurrentDirectory(), resolutionHost.getCanonicalFileName);
85678         var resolvedTypeReferenceDirectives = ts.createMap();
85679         var perDirectoryResolvedTypeReferenceDirectives = ts.createCacheWithRedirects();
85680         var failedLookupDefaultExtensions = [".ts", ".tsx", ".js", ".jsx", ".json"];
85681         var customFailedLookupPaths = ts.createMap();
85682         var directoryWatchesOfFailedLookups = ts.createMap();
85683         var rootDir = rootDirForResolution && ts.removeTrailingDirectorySeparator(ts.getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory()));
85684         var rootPath = (rootDir && resolutionHost.toPath(rootDir));
85685         var rootSplitLength = rootPath !== undefined ? rootPath.split(ts.directorySeparator).length : 0;
85686         var typeRootsWatches = ts.createMap();
85687         return {
85688             startRecordingFilesWithChangedResolutions: startRecordingFilesWithChangedResolutions,
85689             finishRecordingFilesWithChangedResolutions: finishRecordingFilesWithChangedResolutions,
85690             startCachingPerDirectoryResolution: clearPerDirectoryResolutions,
85691             finishCachingPerDirectoryResolution: finishCachingPerDirectoryResolution,
85692             resolveModuleNames: resolveModuleNames,
85693             getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
85694             resolveTypeReferenceDirectives: resolveTypeReferenceDirectives,
85695             removeResolutionsFromProjectReferenceRedirects: removeResolutionsFromProjectReferenceRedirects,
85696             removeResolutionsOfFile: removeResolutionsOfFile,
85697             invalidateResolutionOfFile: invalidateResolutionOfFile,
85698             setFilesWithInvalidatedNonRelativeUnresolvedImports: setFilesWithInvalidatedNonRelativeUnresolvedImports,
85699             createHasInvalidatedResolution: createHasInvalidatedResolution,
85700             updateTypeRootsWatch: updateTypeRootsWatch,
85701             closeTypeRootsWatch: closeTypeRootsWatch,
85702             clear: clear
85703         };
85704         function getResolvedModule(resolution) {
85705             return resolution.resolvedModule;
85706         }
85707         function getResolvedTypeReferenceDirective(resolution) {
85708             return resolution.resolvedTypeReferenceDirective;
85709         }
85710         function isInDirectoryPath(dir, file) {
85711             if (dir === undefined || file.length <= dir.length) {
85712                 return false;
85713             }
85714             return ts.startsWith(file, dir) && file[dir.length] === ts.directorySeparator;
85715         }
85716         function clear() {
85717             ts.clearMap(directoryWatchesOfFailedLookups, ts.closeFileWatcherOf);
85718             customFailedLookupPaths.clear();
85719             nonRelativeExternalModuleResolutions.clear();
85720             closeTypeRootsWatch();
85721             resolvedModuleNames.clear();
85722             resolvedTypeReferenceDirectives.clear();
85723             resolvedFileToResolution.clear();
85724             resolutionsWithFailedLookups.length = 0;
85725             clearPerDirectoryResolutions();
85726         }
85727         function startRecordingFilesWithChangedResolutions() {
85728             filesWithChangedSetOfUnresolvedImports = [];
85729         }
85730         function finishRecordingFilesWithChangedResolutions() {
85731             var collected = filesWithChangedSetOfUnresolvedImports;
85732             filesWithChangedSetOfUnresolvedImports = undefined;
85733             return collected;
85734         }
85735         function isFileWithInvalidatedNonRelativeUnresolvedImports(path) {
85736             if (!filesWithInvalidatedNonRelativeUnresolvedImports) {
85737                 return false;
85738             }
85739             var value = filesWithInvalidatedNonRelativeUnresolvedImports.get(path);
85740             return !!value && !!value.length;
85741         }
85742         function createHasInvalidatedResolution(forceAllFilesAsInvalidated) {
85743             if (forceAllFilesAsInvalidated) {
85744                 filesWithInvalidatedResolutions = undefined;
85745                 return ts.returnTrue;
85746             }
85747             var collected = filesWithInvalidatedResolutions;
85748             filesWithInvalidatedResolutions = undefined;
85749             return function (path) { return (!!collected && collected.has(path)) ||
85750                 isFileWithInvalidatedNonRelativeUnresolvedImports(path); };
85751         }
85752         function clearPerDirectoryResolutions() {
85753             perDirectoryResolvedModuleNames.clear();
85754             nonRelativeModuleNameCache.clear();
85755             perDirectoryResolvedTypeReferenceDirectives.clear();
85756             nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
85757             nonRelativeExternalModuleResolutions.clear();
85758         }
85759         function finishCachingPerDirectoryResolution() {
85760             filesWithInvalidatedNonRelativeUnresolvedImports = undefined;
85761             clearPerDirectoryResolutions();
85762             directoryWatchesOfFailedLookups.forEach(function (watcher, path) {
85763                 if (watcher.refCount === 0) {
85764                     directoryWatchesOfFailedLookups.delete(path);
85765                     watcher.watcher.close();
85766                 }
85767             });
85768         }
85769         function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference) {
85770             var _a;
85771             var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference);
85772             if (!resolutionHost.getGlobalCache) {
85773                 return primaryResult;
85774             }
85775             var globalCache = resolutionHost.getGlobalCache();
85776             if (globalCache !== undefined && !ts.isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && ts.extensionIsTS(primaryResult.resolvedModule.extension))) {
85777                 var _b = ts.loadModuleFromGlobalCache(ts.Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache), resolvedModule = _b.resolvedModule, failedLookupLocations = _b.failedLookupLocations;
85778                 if (resolvedModule) {
85779                     primaryResult.resolvedModule = resolvedModule;
85780                     (_a = primaryResult.failedLookupLocations).push.apply(_a, failedLookupLocations);
85781                     return primaryResult;
85782                 }
85783             }
85784             return primaryResult;
85785         }
85786         function resolveNamesWithLocalCache(_a) {
85787             var _b;
85788             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;
85789             var path = resolutionHost.toPath(containingFile);
85790             var resolutionsInFile = cache.get(path) || cache.set(path, ts.createMap()).get(path);
85791             var dirPath = ts.getDirectoryPath(path);
85792             var perDirectoryCache = perDirectoryCacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
85793             var perDirectoryResolution = perDirectoryCache.get(dirPath);
85794             if (!perDirectoryResolution) {
85795                 perDirectoryResolution = ts.createMap();
85796                 perDirectoryCache.set(dirPath, perDirectoryResolution);
85797             }
85798             var resolvedModules = [];
85799             var compilerOptions = resolutionHost.getCompilationSettings();
85800             var hasInvalidatedNonRelativeUnresolvedImport = logChanges && isFileWithInvalidatedNonRelativeUnresolvedImports(path);
85801             var program = resolutionHost.getCurrentProgram();
85802             var oldRedirect = program && program.getResolvedProjectReferenceToRedirect(containingFile);
85803             var unmatchedRedirects = oldRedirect ?
85804                 !redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path :
85805                 !!redirectedReference;
85806             var seenNamesInFile = ts.createMap();
85807             for (var _i = 0, names_3 = names; _i < names_3.length; _i++) {
85808                 var name = names_3[_i];
85809                 var resolution = resolutionsInFile.get(name);
85810                 if (!seenNamesInFile.has(name) &&
85811                     unmatchedRedirects || !resolution || resolution.isInvalidated ||
85812                     (hasInvalidatedNonRelativeUnresolvedImport && !ts.isExternalModuleNameRelative(name) && shouldRetryResolution(resolution))) {
85813                     var existingResolution = resolution;
85814                     var resolutionInDirectory = perDirectoryResolution.get(name);
85815                     if (resolutionInDirectory) {
85816                         resolution = resolutionInDirectory;
85817                     }
85818                     else {
85819                         resolution = loader(name, containingFile, compilerOptions, ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost, redirectedReference);
85820                         perDirectoryResolution.set(name, resolution);
85821                     }
85822                     resolutionsInFile.set(name, resolution);
85823                     watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, path, getResolutionWithResolvedFileName);
85824                     if (existingResolution) {
85825                         stopWatchFailedLookupLocationOfResolution(existingResolution, path, getResolutionWithResolvedFileName);
85826                     }
85827                     if (logChanges && filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) {
85828                         filesWithChangedSetOfUnresolvedImports.push(path);
85829                         logChanges = false;
85830                     }
85831                 }
85832                 ts.Debug.assert(resolution !== undefined && !resolution.isInvalidated);
85833                 seenNamesInFile.set(name, true);
85834                 resolvedModules.push(getResolutionWithResolvedFileName(resolution));
85835             }
85836             resolutionsInFile.forEach(function (resolution, name) {
85837                 if (!seenNamesInFile.has(name) && !ts.contains(reusedNames, name)) {
85838                     stopWatchFailedLookupLocationOfResolution(resolution, path, getResolutionWithResolvedFileName);
85839                     resolutionsInFile.delete(name);
85840                 }
85841             });
85842             return resolvedModules;
85843             function resolutionIsEqualTo(oldResolution, newResolution) {
85844                 if (oldResolution === newResolution) {
85845                     return true;
85846                 }
85847                 if (!oldResolution || !newResolution) {
85848                     return false;
85849                 }
85850                 var oldResult = getResolutionWithResolvedFileName(oldResolution);
85851                 var newResult = getResolutionWithResolvedFileName(newResolution);
85852                 if (oldResult === newResult) {
85853                     return true;
85854                 }
85855                 if (!oldResult || !newResult) {
85856                     return false;
85857                 }
85858                 return oldResult.resolvedFileName === newResult.resolvedFileName;
85859             }
85860         }
85861         function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference) {
85862             return resolveNamesWithLocalCache({
85863                 names: typeDirectiveNames,
85864                 containingFile: containingFile,
85865                 redirectedReference: redirectedReference,
85866                 cache: resolvedTypeReferenceDirectives,
85867                 perDirectoryCacheWithRedirects: perDirectoryResolvedTypeReferenceDirectives,
85868                 loader: ts.resolveTypeReferenceDirective,
85869                 getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective,
85870                 shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; },
85871             });
85872         }
85873         function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference) {
85874             return resolveNamesWithLocalCache({
85875                 names: moduleNames,
85876                 containingFile: containingFile,
85877                 redirectedReference: redirectedReference,
85878                 cache: resolvedModuleNames,
85879                 perDirectoryCacheWithRedirects: perDirectoryResolvedModuleNames,
85880                 loader: resolveModuleName,
85881                 getResolutionWithResolvedFileName: getResolvedModule,
85882                 shouldRetryResolution: function (resolution) { return !resolution.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension); },
85883                 reusedNames: reusedNames,
85884                 logChanges: logChangesWhenResolvingModule
85885             });
85886         }
85887         function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile) {
85888             var cache = resolvedModuleNames.get(resolutionHost.toPath(containingFile));
85889             return cache && cache.get(moduleName);
85890         }
85891         function isNodeModulesAtTypesDirectory(dirPath) {
85892             return ts.endsWith(dirPath, "/node_modules/@types");
85893         }
85894         function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath) {
85895             if (isInDirectoryPath(rootPath, failedLookupLocationPath)) {
85896                 failedLookupLocation = ts.isRootedDiskPath(failedLookupLocation) ? ts.normalizePath(failedLookupLocation) : ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory());
85897                 var failedLookupPathSplit = failedLookupLocationPath.split(ts.directorySeparator);
85898                 var failedLookupSplit = failedLookupLocation.split(ts.directorySeparator);
85899                 ts.Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath);
85900                 if (failedLookupPathSplit.length > rootSplitLength + 1) {
85901                     return {
85902                         dir: failedLookupSplit.slice(0, rootSplitLength + 1).join(ts.directorySeparator),
85903                         dirPath: failedLookupPathSplit.slice(0, rootSplitLength + 1).join(ts.directorySeparator)
85904                     };
85905                 }
85906                 else {
85907                     return {
85908                         dir: rootDir,
85909                         dirPath: rootPath,
85910                         nonRecursive: false
85911                     };
85912                 }
85913             }
85914             return getDirectoryToWatchFromFailedLookupLocationDirectory(ts.getDirectoryPath(ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory())), ts.getDirectoryPath(failedLookupLocationPath));
85915         }
85916         function getDirectoryToWatchFromFailedLookupLocationDirectory(dir, dirPath) {
85917             while (ts.pathContainsNodeModules(dirPath)) {
85918                 dir = ts.getDirectoryPath(dir);
85919                 dirPath = ts.getDirectoryPath(dirPath);
85920             }
85921             if (ts.isNodeModulesDirectory(dirPath)) {
85922                 return canWatchDirectory(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined;
85923             }
85924             var nonRecursive = true;
85925             var subDirectoryPath, subDirectory;
85926             if (rootPath !== undefined) {
85927                 while (!isInDirectoryPath(dirPath, rootPath)) {
85928                     var parentPath = ts.getDirectoryPath(dirPath);
85929                     if (parentPath === dirPath) {
85930                         break;
85931                     }
85932                     nonRecursive = false;
85933                     subDirectoryPath = dirPath;
85934                     subDirectory = dir;
85935                     dirPath = parentPath;
85936                     dir = ts.getDirectoryPath(dir);
85937                 }
85938             }
85939             return canWatchDirectory(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined;
85940         }
85941         function isPathWithDefaultFailedLookupExtension(path) {
85942             return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions);
85943         }
85944         function watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, filePath, getResolutionWithResolvedFileName) {
85945             if (resolution.refCount) {
85946                 resolution.refCount++;
85947                 ts.Debug.assertDefined(resolution.files);
85948             }
85949             else {
85950                 resolution.refCount = 1;
85951                 ts.Debug.assert(resolution.files === undefined);
85952                 if (ts.isExternalModuleNameRelative(name)) {
85953                     watchFailedLookupLocationOfResolution(resolution);
85954                 }
85955                 else {
85956                     nonRelativeExternalModuleResolutions.add(name, resolution);
85957                 }
85958                 var resolved = getResolutionWithResolvedFileName(resolution);
85959                 if (resolved && resolved.resolvedFileName) {
85960                     resolvedFileToResolution.add(resolutionHost.toPath(resolved.resolvedFileName), resolution);
85961                 }
85962             }
85963             (resolution.files || (resolution.files = [])).push(filePath);
85964         }
85965         function watchFailedLookupLocationOfResolution(resolution) {
85966             ts.Debug.assert(!!resolution.refCount);
85967             var failedLookupLocations = resolution.failedLookupLocations;
85968             if (!failedLookupLocations.length)
85969                 return;
85970             resolutionsWithFailedLookups.push(resolution);
85971             var setAtRoot = false;
85972             for (var _i = 0, failedLookupLocations_1 = failedLookupLocations; _i < failedLookupLocations_1.length; _i++) {
85973                 var failedLookupLocation = failedLookupLocations_1[_i];
85974                 var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
85975                 var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
85976                 if (toWatch) {
85977                     var dir = toWatch.dir, dirPath = toWatch.dirPath, nonRecursive = toWatch.nonRecursive;
85978                     if (!isPathWithDefaultFailedLookupExtension(failedLookupLocationPath)) {
85979                         var refCount = customFailedLookupPaths.get(failedLookupLocationPath) || 0;
85980                         customFailedLookupPaths.set(failedLookupLocationPath, refCount + 1);
85981                     }
85982                     if (dirPath === rootPath) {
85983                         ts.Debug.assert(!nonRecursive);
85984                         setAtRoot = true;
85985                     }
85986                     else {
85987                         setDirectoryWatcher(dir, dirPath, nonRecursive);
85988                     }
85989                 }
85990             }
85991             if (setAtRoot) {
85992                 setDirectoryWatcher(rootDir, rootPath, true);
85993             }
85994         }
85995         function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) {
85996             var program = resolutionHost.getCurrentProgram();
85997             if (!program || !program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) {
85998                 resolutions.forEach(watchFailedLookupLocationOfResolution);
85999             }
86000         }
86001         function setDirectoryWatcher(dir, dirPath, nonRecursive) {
86002             var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
86003             if (dirWatcher) {
86004                 ts.Debug.assert(!!nonRecursive === !!dirWatcher.nonRecursive);
86005                 dirWatcher.refCount++;
86006             }
86007             else {
86008                 directoryWatchesOfFailedLookups.set(dirPath, { watcher: createDirectoryWatcher(dir, dirPath, nonRecursive), refCount: 1, nonRecursive: nonRecursive });
86009             }
86010         }
86011         function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName) {
86012             ts.unorderedRemoveItem(ts.Debug.assertDefined(resolution.files), filePath);
86013             resolution.refCount--;
86014             if (resolution.refCount) {
86015                 return;
86016             }
86017             var resolved = getResolutionWithResolvedFileName(resolution);
86018             if (resolved && resolved.resolvedFileName) {
86019                 resolvedFileToResolution.remove(resolutionHost.toPath(resolved.resolvedFileName), resolution);
86020             }
86021             if (!ts.unorderedRemoveItem(resolutionsWithFailedLookups, resolution)) {
86022                 return;
86023             }
86024             var failedLookupLocations = resolution.failedLookupLocations;
86025             var removeAtRoot = false;
86026             for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) {
86027                 var failedLookupLocation = failedLookupLocations_2[_i];
86028                 var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
86029                 var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
86030                 if (toWatch) {
86031                     var dirPath = toWatch.dirPath;
86032                     var refCount = customFailedLookupPaths.get(failedLookupLocationPath);
86033                     if (refCount) {
86034                         if (refCount === 1) {
86035                             customFailedLookupPaths.delete(failedLookupLocationPath);
86036                         }
86037                         else {
86038                             ts.Debug.assert(refCount > 1);
86039                             customFailedLookupPaths.set(failedLookupLocationPath, refCount - 1);
86040                         }
86041                     }
86042                     if (dirPath === rootPath) {
86043                         removeAtRoot = true;
86044                     }
86045                     else {
86046                         removeDirectoryWatcher(dirPath);
86047                     }
86048                 }
86049             }
86050             if (removeAtRoot) {
86051                 removeDirectoryWatcher(rootPath);
86052             }
86053         }
86054         function removeDirectoryWatcher(dirPath) {
86055             var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
86056             dirWatcher.refCount--;
86057         }
86058         function createDirectoryWatcher(directory, dirPath, nonRecursive) {
86059             return resolutionHost.watchDirectoryOfFailedLookupLocation(directory, function (fileOrDirectory) {
86060                 var fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory);
86061                 if (cachedDirectoryStructureHost) {
86062                     cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
86063                 }
86064                 if (invalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath)) {
86065                     resolutionHost.onInvalidatedResolution();
86066                 }
86067             }, nonRecursive ? 0 : 1);
86068         }
86069         function removeResolutionsOfFileFromCache(cache, filePath, getResolutionWithResolvedFileName) {
86070             var resolutions = cache.get(filePath);
86071             if (resolutions) {
86072                 resolutions.forEach(function (resolution) { return stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName); });
86073                 cache.delete(filePath);
86074             }
86075         }
86076         function removeResolutionsFromProjectReferenceRedirects(filePath) {
86077             if (!ts.fileExtensionIs(filePath, ".json")) {
86078                 return;
86079             }
86080             var program = resolutionHost.getCurrentProgram();
86081             if (!program) {
86082                 return;
86083             }
86084             var resolvedProjectReference = program.getResolvedProjectReferenceByPath(filePath);
86085             if (!resolvedProjectReference) {
86086                 return;
86087             }
86088             resolvedProjectReference.commandLine.fileNames.forEach(function (f) { return removeResolutionsOfFile(resolutionHost.toPath(f)); });
86089         }
86090         function removeResolutionsOfFile(filePath) {
86091             removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModule);
86092             removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirective);
86093         }
86094         function invalidateResolution(resolution) {
86095             resolution.isInvalidated = true;
86096             var changedInAutoTypeReferenced = false;
86097             for (var _i = 0, _a = ts.Debug.assertDefined(resolution.files); _i < _a.length; _i++) {
86098                 var containingFilePath = _a[_i];
86099                 (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = ts.createMap())).set(containingFilePath, true);
86100                 changedInAutoTypeReferenced = changedInAutoTypeReferenced || containingFilePath.endsWith(ts.inferredTypesContainingFile);
86101             }
86102             if (changedInAutoTypeReferenced) {
86103                 resolutionHost.onChangedAutomaticTypeDirectiveNames();
86104             }
86105         }
86106         function invalidateResolutionOfFile(filePath) {
86107             removeResolutionsOfFile(filePath);
86108             ts.forEach(resolvedFileToResolution.get(filePath), invalidateResolution);
86109         }
86110         function setFilesWithInvalidatedNonRelativeUnresolvedImports(filesMap) {
86111             ts.Debug.assert(filesWithInvalidatedNonRelativeUnresolvedImports === filesMap || filesWithInvalidatedNonRelativeUnresolvedImports === undefined);
86112             filesWithInvalidatedNonRelativeUnresolvedImports = filesMap;
86113         }
86114         function invalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, isCreatingWatchedDirectory) {
86115             var isChangedFailedLookupLocation;
86116             if (isCreatingWatchedDirectory) {
86117                 isChangedFailedLookupLocation = function (location) { return isInDirectoryPath(fileOrDirectoryPath, resolutionHost.toPath(location)); };
86118             }
86119             else {
86120                 var updatedPath = removeIgnoredPath(fileOrDirectoryPath);
86121                 if (!updatedPath)
86122                     return false;
86123                 fileOrDirectoryPath = updatedPath;
86124                 if (resolutionHost.fileIsOpen(fileOrDirectoryPath)) {
86125                     return false;
86126                 }
86127                 var dirOfFileOrDirectory = ts.getDirectoryPath(fileOrDirectoryPath);
86128                 if (isNodeModulesAtTypesDirectory(fileOrDirectoryPath) || ts.isNodeModulesDirectory(fileOrDirectoryPath) ||
86129                     isNodeModulesAtTypesDirectory(dirOfFileOrDirectory) || ts.isNodeModulesDirectory(dirOfFileOrDirectory)) {
86130                     isChangedFailedLookupLocation = function (location) {
86131                         var locationPath = resolutionHost.toPath(location);
86132                         return locationPath === fileOrDirectoryPath || ts.startsWith(resolutionHost.toPath(location), fileOrDirectoryPath);
86133                     };
86134                 }
86135                 else {
86136                     if (!isPathWithDefaultFailedLookupExtension(fileOrDirectoryPath) && !customFailedLookupPaths.has(fileOrDirectoryPath)) {
86137                         return false;
86138                     }
86139                     if (ts.isEmittedFileOfProgram(resolutionHost.getCurrentProgram(), fileOrDirectoryPath)) {
86140                         return false;
86141                     }
86142                     isChangedFailedLookupLocation = function (location) { return resolutionHost.toPath(location) === fileOrDirectoryPath; };
86143                 }
86144             }
86145             var invalidated = false;
86146             for (var _i = 0, resolutionsWithFailedLookups_1 = resolutionsWithFailedLookups; _i < resolutionsWithFailedLookups_1.length; _i++) {
86147                 var resolution = resolutionsWithFailedLookups_1[_i];
86148                 if (resolution.failedLookupLocations.some(isChangedFailedLookupLocation)) {
86149                     invalidateResolution(resolution);
86150                     invalidated = true;
86151                 }
86152             }
86153             return invalidated;
86154         }
86155         function closeTypeRootsWatch() {
86156             ts.clearMap(typeRootsWatches, ts.closeFileWatcher);
86157         }
86158         function getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath) {
86159             if (isInDirectoryPath(rootPath, typeRootPath)) {
86160                 return rootPath;
86161             }
86162             var toWatch = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath);
86163             return toWatch && directoryWatchesOfFailedLookups.has(toWatch.dirPath) ? toWatch.dirPath : undefined;
86164         }
86165         function createTypeRootsWatch(typeRootPath, typeRoot) {
86166             return resolutionHost.watchTypeRootsDirectory(typeRoot, function (fileOrDirectory) {
86167                 var fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory);
86168                 if (cachedDirectoryStructureHost) {
86169                     cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
86170                 }
86171                 resolutionHost.onChangedAutomaticTypeDirectiveNames();
86172                 var dirPath = getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath);
86173                 if (dirPath && invalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath)) {
86174                     resolutionHost.onInvalidatedResolution();
86175                 }
86176             }, 1);
86177         }
86178         function updateTypeRootsWatch() {
86179             var options = resolutionHost.getCompilationSettings();
86180             if (options.types) {
86181                 closeTypeRootsWatch();
86182                 return;
86183             }
86184             var typeRoots = ts.getEffectiveTypeRoots(options, { directoryExists: directoryExistsForTypeRootWatch, getCurrentDirectory: getCurrentDirectory });
86185             if (typeRoots) {
86186                 ts.mutateMap(typeRootsWatches, ts.arrayToMap(typeRoots, function (tr) { return resolutionHost.toPath(tr); }), {
86187                     createNewValue: createTypeRootsWatch,
86188                     onDeleteValue: ts.closeFileWatcher
86189                 });
86190             }
86191             else {
86192                 closeTypeRootsWatch();
86193             }
86194         }
86195         function directoryExistsForTypeRootWatch(nodeTypesDirectory) {
86196             var dir = ts.getDirectoryPath(ts.getDirectoryPath(nodeTypesDirectory));
86197             var dirPath = resolutionHost.toPath(dir);
86198             return dirPath === rootPath || canWatchDirectory(dirPath);
86199         }
86200     }
86201     ts.createResolutionCache = createResolutionCache;
86202 })(ts || (ts = {}));
86203 var ts;
86204 (function (ts) {
86205     var moduleSpecifiers;
86206     (function (moduleSpecifiers) {
86207         function getPreferences(_a, compilerOptions, importingSourceFile) {
86208             var importModuleSpecifierPreference = _a.importModuleSpecifierPreference, importModuleSpecifierEnding = _a.importModuleSpecifierEnding;
86209             return {
86210                 relativePreference: importModuleSpecifierPreference === "relative" ? 0 : importModuleSpecifierPreference === "non-relative" ? 1 : 2,
86211                 ending: getEnding(),
86212             };
86213             function getEnding() {
86214                 switch (importModuleSpecifierEnding) {
86215                     case "minimal": return 0;
86216                     case "index": return 1;
86217                     case "js": return 2;
86218                     default: return usesJsExtensionOnImports(importingSourceFile) ? 2
86219                         : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 : 0;
86220                 }
86221             }
86222         }
86223         function getPreferencesForUpdate(compilerOptions, oldImportSpecifier) {
86224             return {
86225                 relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 : 1,
86226                 ending: ts.hasJSFileExtension(oldImportSpecifier) ?
86227                     2 :
86228                     ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 : 0,
86229             };
86230         }
86231         function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, oldImportSpecifier) {
86232             var res = getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferencesForUpdate(compilerOptions, oldImportSpecifier));
86233             if (res === oldImportSpecifier)
86234                 return undefined;
86235             return res;
86236         }
86237         moduleSpecifiers.updateModuleSpecifier = updateModuleSpecifier;
86238         function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, preferences) {
86239             if (preferences === void 0) { preferences = {}; }
86240             return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferences(preferences, compilerOptions, importingSourceFile));
86241         }
86242         moduleSpecifiers.getModuleSpecifier = getModuleSpecifier;
86243         function getNodeModulesPackageName(compilerOptions, importingSourceFileName, nodeModulesFileName, host) {
86244             var info = getInfo(importingSourceFileName, host);
86245             var modulePaths = getAllModulePaths(importingSourceFileName, nodeModulesFileName, host);
86246             return ts.firstDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions, true); });
86247         }
86248         moduleSpecifiers.getNodeModulesPackageName = getNodeModulesPackageName;
86249         function getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, preferences) {
86250             var info = getInfo(importingSourceFileName, host);
86251             var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host);
86252             return ts.firstDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions); }) ||
86253                 getLocalModuleSpecifier(toFileName, info, compilerOptions, preferences);
86254         }
86255         function getModuleSpecifiers(moduleSymbol, compilerOptions, importingSourceFile, host, userPreferences) {
86256             var ambient = tryGetModuleNameFromAmbientModule(moduleSymbol);
86257             if (ambient)
86258                 return [ambient];
86259             var info = getInfo(importingSourceFile.path, host);
86260             var moduleSourceFile = ts.getSourceFileOfNode(moduleSymbol.valueDeclaration || ts.getNonAugmentationDeclaration(moduleSymbol));
86261             var modulePaths = getAllModulePaths(importingSourceFile.path, moduleSourceFile.originalFileName, host);
86262             var preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile);
86263             var global = ts.mapDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions); });
86264             return global.length ? global : modulePaths.map(function (moduleFileName) { return getLocalModuleSpecifier(moduleFileName, info, compilerOptions, preferences); });
86265         }
86266         moduleSpecifiers.getModuleSpecifiers = getModuleSpecifiers;
86267         function getInfo(importingSourceFileName, host) {
86268             var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames ? host.useCaseSensitiveFileNames() : true);
86269             var sourceDirectory = ts.getDirectoryPath(importingSourceFileName);
86270             return { getCanonicalFileName: getCanonicalFileName, sourceDirectory: sourceDirectory };
86271         }
86272         function getLocalModuleSpecifier(moduleFileName, _a, compilerOptions, _b) {
86273             var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory;
86274             var ending = _b.ending, relativePreference = _b.relativePreference;
86275             var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs;
86276             var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) ||
86277                 removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions);
86278             if (!baseUrl || relativePreference === 0) {
86279                 return relativePath;
86280             }
86281             var relativeToBaseUrl = getRelativePathIfInDirectory(moduleFileName, baseUrl, getCanonicalFileName);
86282             if (!relativeToBaseUrl) {
86283                 return relativePath;
86284             }
86285             var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions);
86286             var fromPaths = paths && tryGetModuleNameFromPaths(ts.removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths);
86287             var nonRelative = fromPaths === undefined ? importRelativeToBaseUrl : fromPaths;
86288             if (relativePreference === 1) {
86289                 return nonRelative;
86290             }
86291             if (relativePreference !== 2)
86292                 ts.Debug.assertNever(relativePreference);
86293             return isPathRelativeToParent(nonRelative) || countPathComponents(relativePath) < countPathComponents(nonRelative) ? relativePath : nonRelative;
86294         }
86295         function countPathComponents(path) {
86296             var count = 0;
86297             for (var i = ts.startsWith(path, "./") ? 2 : 0; i < path.length; i++) {
86298                 if (path.charCodeAt(i) === 47)
86299                     count++;
86300             }
86301             return count;
86302         }
86303         moduleSpecifiers.countPathComponents = countPathComponents;
86304         function usesJsExtensionOnImports(_a) {
86305             var imports = _a.imports;
86306             return ts.firstDefined(imports, function (_a) {
86307                 var text = _a.text;
86308                 return ts.pathIsRelative(text) ? ts.hasJSFileExtension(text) : undefined;
86309             }) || false;
86310         }
86311         function numberOfDirectorySeparators(str) {
86312             var match = str.match(/\//g);
86313             return match ? match.length : 0;
86314         }
86315         function comparePathsByNumberOfDirectorySeparators(a, b) {
86316             return ts.compareValues(numberOfDirectorySeparators(a), numberOfDirectorySeparators(b));
86317         }
86318         function forEachFileNameOfModule(importingFileName, importedFileName, host, preferSymlinks, cb) {
86319             var getCanonicalFileName = ts.hostGetCanonicalFileName(host);
86320             var cwd = host.getCurrentDirectory();
86321             var referenceRedirect = host.isSourceOfProjectReferenceRedirect(importedFileName) ? host.getProjectReferenceRedirect(importedFileName) : undefined;
86322             var redirects = host.redirectTargetsMap.get(ts.toPath(importedFileName, cwd, getCanonicalFileName)) || ts.emptyArray;
86323             var importedFileNames = __spreadArrays((referenceRedirect ? [referenceRedirect] : ts.emptyArray), [importedFileName], redirects);
86324             var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); });
86325             if (!preferSymlinks) {
86326                 var result_12 = ts.forEach(targets, cb);
86327                 if (result_12)
86328                     return result_12;
86329             }
86330             var links = host.getProbableSymlinks
86331                 ? host.getProbableSymlinks(host.getSourceFiles())
86332                 : ts.discoverProbableSymlinks(host.getSourceFiles(), getCanonicalFileName, cwd);
86333             var compareStrings = (!host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames()) ? ts.compareStringsCaseSensitive : ts.compareStringsCaseInsensitive;
86334             var result = ts.forEachEntry(links, function (resolved, path) {
86335                 if (ts.startsWithDirectory(importingFileName, resolved, getCanonicalFileName)) {
86336                     return undefined;
86337                 }
86338                 var target = ts.find(targets, function (t) { return compareStrings(t.slice(0, resolved.length + 1), resolved + "/") === 0; });
86339                 if (target === undefined)
86340                     return undefined;
86341                 var relative = ts.getRelativePathFromDirectory(resolved, target, getCanonicalFileName);
86342                 var option = ts.resolvePath(path, relative);
86343                 if (!host.fileExists || host.fileExists(option)) {
86344                     var result_13 = cb(option);
86345                     if (result_13)
86346                         return result_13;
86347                 }
86348             });
86349             return result ||
86350                 (preferSymlinks ? ts.forEach(targets, cb) : undefined);
86351         }
86352         moduleSpecifiers.forEachFileNameOfModule = forEachFileNameOfModule;
86353         function getAllModulePaths(importingFileName, importedFileName, host) {
86354             var cwd = host.getCurrentDirectory();
86355             var getCanonicalFileName = ts.hostGetCanonicalFileName(host);
86356             var allFileNames = ts.createMap();
86357             var importedFileFromNodeModules = false;
86358             forEachFileNameOfModule(importingFileName, importedFileName, host, true, function (path) {
86359                 allFileNames.set(path, getCanonicalFileName(path));
86360                 importedFileFromNodeModules = importedFileFromNodeModules || ts.pathContainsNodeModules(path);
86361             });
86362             var sortedPaths = [];
86363             var _loop_20 = function (directory) {
86364                 var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
86365                 var pathsInDirectory;
86366                 allFileNames.forEach(function (canonicalFileName, fileName) {
86367                     if (ts.startsWith(canonicalFileName, directoryStart)) {
86368                         if (!importedFileFromNodeModules || ts.pathContainsNodeModules(fileName)) {
86369                             (pathsInDirectory || (pathsInDirectory = [])).push(fileName);
86370                         }
86371                         allFileNames.delete(fileName);
86372                     }
86373                 });
86374                 if (pathsInDirectory) {
86375                     if (pathsInDirectory.length > 1) {
86376                         pathsInDirectory.sort(comparePathsByNumberOfDirectorySeparators);
86377                     }
86378                     sortedPaths.push.apply(sortedPaths, pathsInDirectory);
86379                 }
86380                 var newDirectory = ts.getDirectoryPath(directory);
86381                 if (newDirectory === directory)
86382                     return out_directory_1 = directory, "break";
86383                 directory = newDirectory;
86384                 out_directory_1 = directory;
86385             };
86386             var out_directory_1;
86387             for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0;) {
86388                 var state_8 = _loop_20(directory);
86389                 directory = out_directory_1;
86390                 if (state_8 === "break")
86391                     break;
86392             }
86393             if (allFileNames.size) {
86394                 var remainingPaths = ts.arrayFrom(allFileNames.values());
86395                 if (remainingPaths.length > 1)
86396                     remainingPaths.sort(comparePathsByNumberOfDirectorySeparators);
86397                 sortedPaths.push.apply(sortedPaths, remainingPaths);
86398             }
86399             return sortedPaths;
86400         }
86401         function tryGetModuleNameFromAmbientModule(moduleSymbol) {
86402             var decl = ts.find(moduleSymbol.declarations, function (d) { return ts.isNonGlobalAmbientModule(d) && (!ts.isExternalModuleAugmentation(d) || !ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(d.name))); });
86403             if (decl) {
86404                 return decl.name.text;
86405             }
86406         }
86407         function tryGetModuleNameFromPaths(relativeToBaseUrlWithIndex, relativeToBaseUrl, paths) {
86408             for (var key in paths) {
86409                 for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
86410                     var patternText_1 = _a[_i];
86411                     var pattern = ts.removeFileExtension(ts.normalizePath(patternText_1));
86412                     var indexOfStar = pattern.indexOf("*");
86413                     if (indexOfStar !== -1) {
86414                         var prefix = pattern.substr(0, indexOfStar);
86415                         var suffix = pattern.substr(indexOfStar + 1);
86416                         if (relativeToBaseUrl.length >= prefix.length + suffix.length &&
86417                             ts.startsWith(relativeToBaseUrl, prefix) &&
86418                             ts.endsWith(relativeToBaseUrl, suffix) ||
86419                             !suffix && relativeToBaseUrl === ts.removeTrailingDirectorySeparator(prefix)) {
86420                             var matchedStar = relativeToBaseUrl.substr(prefix.length, relativeToBaseUrl.length - suffix.length);
86421                             return key.replace("*", matchedStar);
86422                         }
86423                     }
86424                     else if (pattern === relativeToBaseUrl || pattern === relativeToBaseUrlWithIndex) {
86425                         return key;
86426                     }
86427                 }
86428             }
86429         }
86430         function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) {
86431             var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
86432             if (normalizedTargetPath === undefined) {
86433                 return undefined;
86434             }
86435             var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName);
86436             var relativePath = normalizedSourcePath !== undefined ? ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(normalizedSourcePath, normalizedTargetPath, getCanonicalFileName)) : normalizedTargetPath;
86437             return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs
86438                 ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions)
86439                 : ts.removeFileExtension(relativePath);
86440         }
86441         function tryGetModuleNameAsNodeModule(moduleFileName, _a, host, options, packageNameOnly) {
86442             var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory;
86443             if (!host.fileExists || !host.readFile) {
86444                 return undefined;
86445             }
86446             var parts = getNodeModulePathParts(moduleFileName);
86447             if (!parts) {
86448                 return undefined;
86449             }
86450             var moduleSpecifier = moduleFileName;
86451             if (!packageNameOnly) {
86452                 var packageRootIndex = parts.packageRootIndex;
86453                 var moduleFileNameForExtensionless = void 0;
86454                 while (true) {
86455                     var _b = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _b.moduleFileToTry, packageRootPath = _b.packageRootPath;
86456                     if (packageRootPath) {
86457                         moduleSpecifier = packageRootPath;
86458                         break;
86459                     }
86460                     if (!moduleFileNameForExtensionless)
86461                         moduleFileNameForExtensionless = moduleFileToTry;
86462                     packageRootIndex = moduleFileName.indexOf(ts.directorySeparator, packageRootIndex + 1);
86463                     if (packageRootIndex === -1) {
86464                         moduleSpecifier = getExtensionlessFileName(moduleFileNameForExtensionless);
86465                         break;
86466                     }
86467                 }
86468             }
86469             var globalTypingsCacheLocation = host.getGlobalTypingsCacheLocation && host.getGlobalTypingsCacheLocation();
86470             var pathToTopLevelNodeModules = getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex));
86471             if (!(ts.startsWith(sourceDirectory, pathToTopLevelNodeModules) || globalTypingsCacheLocation && ts.startsWith(getCanonicalFileName(globalTypingsCacheLocation), pathToTopLevelNodeModules))) {
86472                 return undefined;
86473             }
86474             var nodeModulesDirectoryName = moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1);
86475             var packageName = ts.getPackageNameFromTypesPackageName(nodeModulesDirectoryName);
86476             return ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs && packageName === nodeModulesDirectoryName ? undefined : packageName;
86477             function tryDirectoryWithPackageJson(packageRootIndex) {
86478                 var packageRootPath = moduleFileName.substring(0, packageRootIndex);
86479                 var packageJsonPath = ts.combinePaths(packageRootPath, "package.json");
86480                 var moduleFileToTry = moduleFileName;
86481                 if (host.fileExists(packageJsonPath)) {
86482                     var packageJsonContent = JSON.parse(host.readFile(packageJsonPath));
86483                     var versionPaths = packageJsonContent.typesVersions
86484                         ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions)
86485                         : undefined;
86486                     if (versionPaths) {
86487                         var subModuleName = moduleFileName.slice(packageRootPath.length + 1);
86488                         var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0, options), versionPaths.paths);
86489                         if (fromPaths !== undefined) {
86490                             moduleFileToTry = ts.combinePaths(packageRootPath, fromPaths);
86491                         }
86492                     }
86493                     var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main;
86494                     if (ts.isString(mainFileRelative)) {
86495                         var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName);
86496                         if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) {
86497                             return { packageRootPath: packageRootPath, moduleFileToTry: moduleFileToTry };
86498                         }
86499                     }
86500                 }
86501                 return { moduleFileToTry: moduleFileToTry };
86502             }
86503             function getExtensionlessFileName(path) {
86504                 var fullModulePathWithoutExtension = ts.removeFileExtension(path);
86505                 if (getCanonicalFileName(fullModulePathWithoutExtension.substring(parts.fileNameIndex)) === "/index" && !tryGetAnyFileFromPath(host, fullModulePathWithoutExtension.substring(0, parts.fileNameIndex))) {
86506                     return fullModulePathWithoutExtension.substring(0, parts.fileNameIndex);
86507                 }
86508                 return fullModulePathWithoutExtension;
86509             }
86510         }
86511         function tryGetAnyFileFromPath(host, path) {
86512             if (!host.fileExists)
86513                 return;
86514             var extensions = ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 }]);
86515             for (var _i = 0, extensions_3 = extensions; _i < extensions_3.length; _i++) {
86516                 var e = extensions_3[_i];
86517                 var fullPath = path + e;
86518                 if (host.fileExists(fullPath)) {
86519                     return fullPath;
86520                 }
86521             }
86522         }
86523         function getNodeModulePathParts(fullPath) {
86524             var topLevelNodeModulesIndex = 0;
86525             var topLevelPackageNameIndex = 0;
86526             var packageRootIndex = 0;
86527             var fileNameIndex = 0;
86528             var partStart = 0;
86529             var partEnd = 0;
86530             var state = 0;
86531             while (partEnd >= 0) {
86532                 partStart = partEnd;
86533                 partEnd = fullPath.indexOf("/", partStart + 1);
86534                 switch (state) {
86535                     case 0:
86536                         if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
86537                             topLevelNodeModulesIndex = partStart;
86538                             topLevelPackageNameIndex = partEnd;
86539                             state = 1;
86540                         }
86541                         break;
86542                     case 1:
86543                     case 2:
86544                         if (state === 1 && fullPath.charAt(partStart + 1) === "@") {
86545                             state = 2;
86546                         }
86547                         else {
86548                             packageRootIndex = partEnd;
86549                             state = 3;
86550                         }
86551                         break;
86552                     case 3:
86553                         if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
86554                             state = 1;
86555                         }
86556                         else {
86557                             state = 3;
86558                         }
86559                         break;
86560                 }
86561             }
86562             fileNameIndex = partStart;
86563             return state > 1 ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined;
86564         }
86565         function getPathRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
86566             return ts.firstDefined(rootDirs, function (rootDir) {
86567                 var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
86568                 return isPathRelativeToParent(relativePath) ? undefined : relativePath;
86569             });
86570         }
86571         function removeExtensionAndIndexPostFix(fileName, ending, options) {
86572             if (ts.fileExtensionIs(fileName, ".json"))
86573                 return fileName;
86574             var noExtension = ts.removeFileExtension(fileName);
86575             switch (ending) {
86576                 case 0:
86577                     return ts.removeSuffix(noExtension, "/index");
86578                 case 1:
86579                     return noExtension;
86580                 case 2:
86581                     return noExtension + getJSExtensionForFile(fileName, options);
86582                 default:
86583                     return ts.Debug.assertNever(ending);
86584             }
86585         }
86586         function getJSExtensionForFile(fileName, options) {
86587             var ext = ts.extensionFromPath(fileName);
86588             switch (ext) {
86589                 case ".ts":
86590                 case ".d.ts":
86591                     return ".js";
86592                 case ".tsx":
86593                     return options.jsx === 1 ? ".jsx" : ".js";
86594                 case ".js":
86595                 case ".jsx":
86596                 case ".json":
86597                     return ext;
86598                 case ".tsbuildinfo":
86599                     return ts.Debug.fail("Extension " + ".tsbuildinfo" + " is unsupported:: FileName:: " + fileName);
86600                 default:
86601                     return ts.Debug.assertNever(ext);
86602             }
86603         }
86604         function getRelativePathIfInDirectory(path, directoryPath, getCanonicalFileName) {
86605             var relativePath = ts.getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, false);
86606             return ts.isRootedDiskPath(relativePath) ? undefined : relativePath;
86607         }
86608         function isPathRelativeToParent(path) {
86609             return ts.startsWith(path, "..");
86610         }
86611     })(moduleSpecifiers = ts.moduleSpecifiers || (ts.moduleSpecifiers = {}));
86612 })(ts || (ts = {}));
86613 var ts;
86614 (function (ts) {
86615     var sysFormatDiagnosticsHost = ts.sys ? {
86616         getCurrentDirectory: function () { return ts.sys.getCurrentDirectory(); },
86617         getNewLine: function () { return ts.sys.newLine; },
86618         getCanonicalFileName: ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)
86619     } : undefined;
86620     function createDiagnosticReporter(system, pretty) {
86621         var host = system === ts.sys ? sysFormatDiagnosticsHost : {
86622             getCurrentDirectory: function () { return system.getCurrentDirectory(); },
86623             getNewLine: function () { return system.newLine; },
86624             getCanonicalFileName: ts.createGetCanonicalFileName(system.useCaseSensitiveFileNames),
86625         };
86626         if (!pretty) {
86627             return function (diagnostic) { return system.write(ts.formatDiagnostic(diagnostic, host)); };
86628         }
86629         var diagnostics = new Array(1);
86630         return function (diagnostic) {
86631             diagnostics[0] = diagnostic;
86632             system.write(ts.formatDiagnosticsWithColorAndContext(diagnostics, host) + host.getNewLine());
86633             diagnostics[0] = undefined;
86634         };
86635     }
86636     ts.createDiagnosticReporter = createDiagnosticReporter;
86637     function clearScreenIfNotWatchingForFileChanges(system, diagnostic, options) {
86638         if (system.clearScreen &&
86639             !options.preserveWatchOutput &&
86640             !options.extendedDiagnostics &&
86641             !options.diagnostics &&
86642             ts.contains(ts.screenStartingMessageCodes, diagnostic.code)) {
86643             system.clearScreen();
86644             return true;
86645         }
86646         return false;
86647     }
86648     ts.screenStartingMessageCodes = [
86649         ts.Diagnostics.Starting_compilation_in_watch_mode.code,
86650         ts.Diagnostics.File_change_detected_Starting_incremental_compilation.code,
86651     ];
86652     function getPlainDiagnosticFollowingNewLines(diagnostic, newLine) {
86653         return ts.contains(ts.screenStartingMessageCodes, diagnostic.code)
86654             ? newLine + newLine
86655             : newLine;
86656     }
86657     function getLocaleTimeString(system) {
86658         return !system.now ?
86659             new Date().toLocaleTimeString() :
86660             system.now().toLocaleTimeString("en-US", { timeZone: "UTC" });
86661     }
86662     ts.getLocaleTimeString = getLocaleTimeString;
86663     function createWatchStatusReporter(system, pretty) {
86664         return pretty ?
86665             function (diagnostic, newLine, options) {
86666                 clearScreenIfNotWatchingForFileChanges(system, diagnostic, options);
86667                 var output = "[" + ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] ";
86668                 output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (newLine + newLine);
86669                 system.write(output);
86670             } :
86671             function (diagnostic, newLine, options) {
86672                 var output = "";
86673                 if (!clearScreenIfNotWatchingForFileChanges(system, diagnostic, options)) {
86674                     output += newLine;
86675                 }
86676                 output += getLocaleTimeString(system) + " - ";
86677                 output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + getPlainDiagnosticFollowingNewLines(diagnostic, newLine);
86678                 system.write(output);
86679             };
86680     }
86681     ts.createWatchStatusReporter = createWatchStatusReporter;
86682     function parseConfigFileWithSystem(configFileName, optionsToExtend, watchOptionsToExtend, system, reportDiagnostic) {
86683         var host = system;
86684         host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, reportDiagnostic, diagnostic); };
86685         var result = ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host, undefined, watchOptionsToExtend);
86686         host.onUnRecoverableConfigFileDiagnostic = undefined;
86687         return result;
86688     }
86689     ts.parseConfigFileWithSystem = parseConfigFileWithSystem;
86690     function getErrorCountForSummary(diagnostics) {
86691         return ts.countWhere(diagnostics, function (diagnostic) { return diagnostic.category === ts.DiagnosticCategory.Error; });
86692     }
86693     ts.getErrorCountForSummary = getErrorCountForSummary;
86694     function getWatchErrorSummaryDiagnosticMessage(errorCount) {
86695         return errorCount === 1 ?
86696             ts.Diagnostics.Found_1_error_Watching_for_file_changes :
86697             ts.Diagnostics.Found_0_errors_Watching_for_file_changes;
86698     }
86699     ts.getWatchErrorSummaryDiagnosticMessage = getWatchErrorSummaryDiagnosticMessage;
86700     function getErrorSummaryText(errorCount, newLine) {
86701         if (errorCount === 0)
86702             return "";
86703         var d = ts.createCompilerDiagnostic(errorCount === 1 ? ts.Diagnostics.Found_1_error : ts.Diagnostics.Found_0_errors, errorCount);
86704         return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine;
86705     }
86706     ts.getErrorSummaryText = getErrorSummaryText;
86707     function listFiles(program, writeFileName) {
86708         if (program.getCompilerOptions().listFiles || program.getCompilerOptions().listFilesOnly) {
86709             ts.forEach(program.getSourceFiles(), function (file) {
86710                 writeFileName(file.fileName);
86711             });
86712         }
86713     }
86714     ts.listFiles = listFiles;
86715     function emitFilesAndReportErrors(program, reportDiagnostic, writeFileName, reportSummary, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
86716         var isListFilesOnly = !!program.getCompilerOptions().listFilesOnly;
86717         var allDiagnostics = program.getConfigFileParsingDiagnostics().slice();
86718         var configFileParsingDiagnosticsLength = allDiagnostics.length;
86719         ts.addRange(allDiagnostics, program.getSyntacticDiagnostics(undefined, cancellationToken));
86720         if (allDiagnostics.length === configFileParsingDiagnosticsLength) {
86721             ts.addRange(allDiagnostics, program.getOptionsDiagnostics(cancellationToken));
86722             if (!isListFilesOnly) {
86723                 ts.addRange(allDiagnostics, program.getGlobalDiagnostics(cancellationToken));
86724                 if (allDiagnostics.length === configFileParsingDiagnosticsLength) {
86725                     ts.addRange(allDiagnostics, program.getSemanticDiagnostics(undefined, cancellationToken));
86726                 }
86727             }
86728         }
86729         var emitResult = isListFilesOnly
86730             ? { emitSkipped: true, diagnostics: ts.emptyArray }
86731             : program.emit(undefined, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers);
86732         var emittedFiles = emitResult.emittedFiles, emitDiagnostics = emitResult.diagnostics;
86733         ts.addRange(allDiagnostics, emitDiagnostics);
86734         var diagnostics = ts.sortAndDeduplicateDiagnostics(allDiagnostics);
86735         diagnostics.forEach(reportDiagnostic);
86736         if (writeFileName) {
86737             var currentDir_1 = program.getCurrentDirectory();
86738             ts.forEach(emittedFiles, function (file) {
86739                 var filepath = ts.getNormalizedAbsolutePath(file, currentDir_1);
86740                 writeFileName("TSFILE: " + filepath);
86741             });
86742             listFiles(program, writeFileName);
86743         }
86744         if (reportSummary) {
86745             reportSummary(getErrorCountForSummary(diagnostics));
86746         }
86747         return {
86748             emitResult: emitResult,
86749             diagnostics: diagnostics,
86750         };
86751     }
86752     ts.emitFilesAndReportErrors = emitFilesAndReportErrors;
86753     function emitFilesAndReportErrorsAndGetExitStatus(program, reportDiagnostic, writeFileName, reportSummary, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
86754         var _a = emitFilesAndReportErrors(program, reportDiagnostic, writeFileName, reportSummary, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers), emitResult = _a.emitResult, diagnostics = _a.diagnostics;
86755         if (emitResult.emitSkipped && diagnostics.length > 0) {
86756             return ts.ExitStatus.DiagnosticsPresent_OutputsSkipped;
86757         }
86758         else if (diagnostics.length > 0) {
86759             return ts.ExitStatus.DiagnosticsPresent_OutputsGenerated;
86760         }
86761         return ts.ExitStatus.Success;
86762     }
86763     ts.emitFilesAndReportErrorsAndGetExitStatus = emitFilesAndReportErrorsAndGetExitStatus;
86764     ts.noopFileWatcher = { close: ts.noop };
86765     function createWatchHost(system, reportWatchStatus) {
86766         if (system === void 0) { system = ts.sys; }
86767         var onWatchStatusChange = reportWatchStatus || createWatchStatusReporter(system);
86768         return {
86769             onWatchStatusChange: onWatchStatusChange,
86770             watchFile: ts.maybeBind(system, system.watchFile) || (function () { return ts.noopFileWatcher; }),
86771             watchDirectory: ts.maybeBind(system, system.watchDirectory) || (function () { return ts.noopFileWatcher; }),
86772             setTimeout: ts.maybeBind(system, system.setTimeout) || ts.noop,
86773             clearTimeout: ts.maybeBind(system, system.clearTimeout) || ts.noop
86774         };
86775     }
86776     ts.createWatchHost = createWatchHost;
86777     ts.WatchType = {
86778         ConfigFile: "Config file",
86779         SourceFile: "Source file",
86780         MissingFile: "Missing file",
86781         WildcardDirectory: "Wild card directory",
86782         FailedLookupLocations: "Failed Lookup Locations",
86783         TypeRoots: "Type roots"
86784     };
86785     function createWatchFactory(host, options) {
86786         var watchLogLevel = host.trace ? options.extendedDiagnostics ? ts.WatchLogLevel.Verbose : options.diagnostics ? ts.WatchLogLevel.TriggerOnly : ts.WatchLogLevel.None : ts.WatchLogLevel.None;
86787         var writeLog = watchLogLevel !== ts.WatchLogLevel.None ? (function (s) { return host.trace(s); }) : ts.noop;
86788         var result = ts.getWatchFactory(watchLogLevel, writeLog);
86789         result.writeLog = writeLog;
86790         return result;
86791     }
86792     ts.createWatchFactory = createWatchFactory;
86793     function createCompilerHostFromProgramHost(host, getCompilerOptions, directoryStructureHost) {
86794         if (directoryStructureHost === void 0) { directoryStructureHost = host; }
86795         var useCaseSensitiveFileNames = host.useCaseSensitiveFileNames();
86796         var hostGetNewLine = ts.memoize(function () { return host.getNewLine(); });
86797         return {
86798             getSourceFile: function (fileName, languageVersion, onError) {
86799                 var text;
86800                 try {
86801                     ts.performance.mark("beforeIORead");
86802                     text = host.readFile(fileName, getCompilerOptions().charset);
86803                     ts.performance.mark("afterIORead");
86804                     ts.performance.measure("I/O Read", "beforeIORead", "afterIORead");
86805                 }
86806                 catch (e) {
86807                     if (onError) {
86808                         onError(e.message);
86809                     }
86810                     text = "";
86811                 }
86812                 return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion) : undefined;
86813             },
86814             getDefaultLibLocation: ts.maybeBind(host, host.getDefaultLibLocation),
86815             getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); },
86816             writeFile: writeFile,
86817             getCurrentDirectory: ts.memoize(function () { return host.getCurrentDirectory(); }),
86818             useCaseSensitiveFileNames: function () { return useCaseSensitiveFileNames; },
86819             getCanonicalFileName: ts.createGetCanonicalFileName(useCaseSensitiveFileNames),
86820             getNewLine: function () { return ts.getNewLineCharacter(getCompilerOptions(), hostGetNewLine); },
86821             fileExists: function (f) { return host.fileExists(f); },
86822             readFile: function (f) { return host.readFile(f); },
86823             trace: ts.maybeBind(host, host.trace),
86824             directoryExists: ts.maybeBind(directoryStructureHost, directoryStructureHost.directoryExists),
86825             getDirectories: ts.maybeBind(directoryStructureHost, directoryStructureHost.getDirectories),
86826             realpath: ts.maybeBind(host, host.realpath),
86827             getEnvironmentVariable: ts.maybeBind(host, host.getEnvironmentVariable) || (function () { return ""; }),
86828             createHash: ts.maybeBind(host, host.createHash),
86829             readDirectory: ts.maybeBind(host, host.readDirectory),
86830         };
86831         function writeFile(fileName, text, writeByteOrderMark, onError) {
86832             try {
86833                 ts.performance.mark("beforeIOWrite");
86834                 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); });
86835                 ts.performance.mark("afterIOWrite");
86836                 ts.performance.measure("I/O Write", "beforeIOWrite", "afterIOWrite");
86837             }
86838             catch (e) {
86839                 if (onError) {
86840                     onError(e.message);
86841                 }
86842             }
86843         }
86844     }
86845     ts.createCompilerHostFromProgramHost = createCompilerHostFromProgramHost;
86846     function setGetSourceFileAsHashVersioned(compilerHost, host) {
86847         var originalGetSourceFile = compilerHost.getSourceFile;
86848         var computeHash = host.createHash || ts.generateDjb2Hash;
86849         compilerHost.getSourceFile = function () {
86850             var args = [];
86851             for (var _i = 0; _i < arguments.length; _i++) {
86852                 args[_i] = arguments[_i];
86853             }
86854             var result = originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args));
86855             if (result) {
86856                 result.version = computeHash.call(host, result.text);
86857             }
86858             return result;
86859         };
86860     }
86861     ts.setGetSourceFileAsHashVersioned = setGetSourceFileAsHashVersioned;
86862     function createProgramHost(system, createProgram) {
86863         var getDefaultLibLocation = ts.memoize(function () { return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath())); });
86864         return {
86865             useCaseSensitiveFileNames: function () { return system.useCaseSensitiveFileNames; },
86866             getNewLine: function () { return system.newLine; },
86867             getCurrentDirectory: ts.memoize(function () { return system.getCurrentDirectory(); }),
86868             getDefaultLibLocation: getDefaultLibLocation,
86869             getDefaultLibFileName: function (options) { return ts.combinePaths(getDefaultLibLocation(), ts.getDefaultLibFileName(options)); },
86870             fileExists: function (path) { return system.fileExists(path); },
86871             readFile: function (path, encoding) { return system.readFile(path, encoding); },
86872             directoryExists: function (path) { return system.directoryExists(path); },
86873             getDirectories: function (path) { return system.getDirectories(path); },
86874             readDirectory: function (path, extensions, exclude, include, depth) { return system.readDirectory(path, extensions, exclude, include, depth); },
86875             realpath: ts.maybeBind(system, system.realpath),
86876             getEnvironmentVariable: ts.maybeBind(system, system.getEnvironmentVariable),
86877             trace: function (s) { return system.write(s + system.newLine); },
86878             createDirectory: function (path) { return system.createDirectory(path); },
86879             writeFile: function (path, data, writeByteOrderMark) { return system.writeFile(path, data, writeByteOrderMark); },
86880             createHash: ts.maybeBind(system, system.createHash),
86881             createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram
86882         };
86883     }
86884     ts.createProgramHost = createProgramHost;
86885     function createWatchCompilerHost(system, createProgram, reportDiagnostic, reportWatchStatus) {
86886         if (system === void 0) { system = ts.sys; }
86887         var writeFileName = function (s) { return system.write(s + system.newLine); };
86888         var result = createProgramHost(system, createProgram);
86889         ts.copyProperties(result, createWatchHost(system, reportWatchStatus));
86890         result.afterProgramCreate = function (builderProgram) {
86891             var compilerOptions = builderProgram.getCompilerOptions();
86892             var newLine = ts.getNewLineCharacter(compilerOptions, function () { return system.newLine; });
86893             emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions, errorCount); });
86894         };
86895         return result;
86896     }
86897     function reportUnrecoverableDiagnostic(system, reportDiagnostic, diagnostic) {
86898         reportDiagnostic(diagnostic);
86899         system.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
86900     }
86901     function createWatchCompilerHostOfConfigFile(_a) {
86902         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;
86903         var diagnosticReporter = reportDiagnostic || createDiagnosticReporter(system);
86904         var host = createWatchCompilerHost(system, createProgram, diagnosticReporter, reportWatchStatus);
86905         host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, diagnosticReporter, diagnostic); };
86906         host.configFileName = configFileName;
86907         host.optionsToExtend = optionsToExtend;
86908         host.watchOptionsToExtend = watchOptionsToExtend;
86909         host.extraFileExtensions = extraFileExtensions;
86910         return host;
86911     }
86912     ts.createWatchCompilerHostOfConfigFile = createWatchCompilerHostOfConfigFile;
86913     function createWatchCompilerHostOfFilesAndCompilerOptions(_a) {
86914         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;
86915         var host = createWatchCompilerHost(system, createProgram, reportDiagnostic || createDiagnosticReporter(system), reportWatchStatus);
86916         host.rootFiles = rootFiles;
86917         host.options = options;
86918         host.watchOptions = watchOptions;
86919         host.projectReferences = projectReferences;
86920         return host;
86921     }
86922     ts.createWatchCompilerHostOfFilesAndCompilerOptions = createWatchCompilerHostOfFilesAndCompilerOptions;
86923     function performIncrementalCompilation(input) {
86924         var system = input.system || ts.sys;
86925         var host = input.host || (input.host = ts.createIncrementalCompilerHost(input.options, system));
86926         var builderProgram = ts.createIncrementalProgram(input);
86927         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);
86928         if (input.afterProgramEmitAndDiagnostics)
86929             input.afterProgramEmitAndDiagnostics(builderProgram);
86930         return exitStatus;
86931     }
86932     ts.performIncrementalCompilation = performIncrementalCompilation;
86933 })(ts || (ts = {}));
86934 var ts;
86935 (function (ts) {
86936     function readBuilderProgram(compilerOptions, host) {
86937         if (compilerOptions.out || compilerOptions.outFile)
86938             return undefined;
86939         var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions);
86940         if (!buildInfoPath)
86941             return undefined;
86942         var content = host.readFile(buildInfoPath);
86943         if (!content)
86944             return undefined;
86945         var buildInfo = ts.getBuildInfo(content);
86946         if (buildInfo.version !== ts.version)
86947             return undefined;
86948         if (!buildInfo.program)
86949             return undefined;
86950         return ts.createBuildProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
86951     }
86952     ts.readBuilderProgram = readBuilderProgram;
86953     function createIncrementalCompilerHost(options, system) {
86954         if (system === void 0) { system = ts.sys; }
86955         var host = ts.createCompilerHostWorker(options, undefined, system);
86956         host.createHash = ts.maybeBind(system, system.createHash);
86957         ts.setGetSourceFileAsHashVersioned(host, system);
86958         ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); });
86959         return host;
86960     }
86961     ts.createIncrementalCompilerHost = createIncrementalCompilerHost;
86962     function createIncrementalProgram(_a) {
86963         var rootNames = _a.rootNames, options = _a.options, configFileParsingDiagnostics = _a.configFileParsingDiagnostics, projectReferences = _a.projectReferences, host = _a.host, createProgram = _a.createProgram;
86964         host = host || createIncrementalCompilerHost(options);
86965         createProgram = createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram;
86966         var oldProgram = readBuilderProgram(options, host);
86967         return createProgram(rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences);
86968     }
86969     ts.createIncrementalProgram = createIncrementalProgram;
86970     function createWatchCompilerHost(rootFilesOrConfigFileName, options, system, createProgram, reportDiagnostic, reportWatchStatus, projectReferencesOrWatchOptionsToExtend, watchOptionsOrExtraFileExtensions) {
86971         if (ts.isArray(rootFilesOrConfigFileName)) {
86972             return ts.createWatchCompilerHostOfFilesAndCompilerOptions({
86973                 rootFiles: rootFilesOrConfigFileName,
86974                 options: options,
86975                 watchOptions: watchOptionsOrExtraFileExtensions,
86976                 projectReferences: projectReferencesOrWatchOptionsToExtend,
86977                 system: system,
86978                 createProgram: createProgram,
86979                 reportDiagnostic: reportDiagnostic,
86980                 reportWatchStatus: reportWatchStatus,
86981             });
86982         }
86983         else {
86984             return ts.createWatchCompilerHostOfConfigFile({
86985                 configFileName: rootFilesOrConfigFileName,
86986                 optionsToExtend: options,
86987                 watchOptionsToExtend: projectReferencesOrWatchOptionsToExtend,
86988                 extraFileExtensions: watchOptionsOrExtraFileExtensions,
86989                 system: system,
86990                 createProgram: createProgram,
86991                 reportDiagnostic: reportDiagnostic,
86992                 reportWatchStatus: reportWatchStatus,
86993             });
86994         }
86995     }
86996     ts.createWatchCompilerHost = createWatchCompilerHost;
86997     function createWatchProgram(host) {
86998         var builderProgram;
86999         var reloadLevel;
87000         var missingFilesMap;
87001         var watchedWildcardDirectories;
87002         var timerToUpdateProgram;
87003         var sourceFilesCache = ts.createMap();
87004         var missingFilePathsRequestedForRelease;
87005         var hasChangedCompilerOptions = false;
87006         var hasChangedAutomaticTypeDirectiveNames = false;
87007         var useCaseSensitiveFileNames = host.useCaseSensitiveFileNames();
87008         var currentDirectory = host.getCurrentDirectory();
87009         var configFileName = host.configFileName, _a = host.optionsToExtend, optionsToExtendForConfigFile = _a === void 0 ? {} : _a, watchOptionsToExtend = host.watchOptionsToExtend, extraFileExtensions = host.extraFileExtensions, createProgram = host.createProgram;
87010         var rootFileNames = host.rootFiles, compilerOptions = host.options, watchOptions = host.watchOptions, projectReferences = host.projectReferences;
87011         var configFileSpecs;
87012         var configFileParsingDiagnostics;
87013         var canConfigFileJsonReportNoInputFiles = false;
87014         var hasChangedConfigFileParsingErrors = false;
87015         var cachedDirectoryStructureHost = configFileName === undefined ? undefined : ts.createCachedDirectoryStructureHost(host, currentDirectory, useCaseSensitiveFileNames);
87016         var directoryStructureHost = cachedDirectoryStructureHost || host;
87017         var parseConfigFileHost = ts.parseConfigHostFromCompilerHostLike(host, directoryStructureHost);
87018         var newLine = updateNewLine();
87019         if (configFileName && host.configFileParsingResult) {
87020             setConfigFileParsingResult(host.configFileParsingResult);
87021             newLine = updateNewLine();
87022         }
87023         reportWatchDiagnostic(ts.Diagnostics.Starting_compilation_in_watch_mode);
87024         if (configFileName && !host.configFileParsingResult) {
87025             newLine = ts.getNewLineCharacter(optionsToExtendForConfigFile, function () { return host.getNewLine(); });
87026             ts.Debug.assert(!rootFileNames);
87027             parseConfigFile();
87028             newLine = updateNewLine();
87029         }
87030         var _b = ts.createWatchFactory(host, compilerOptions), watchFile = _b.watchFile, watchFilePath = _b.watchFilePath, watchDirectory = _b.watchDirectory, writeLog = _b.writeLog;
87031         var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
87032         writeLog("Current directory: " + currentDirectory + " CaseSensitiveFileNames: " + useCaseSensitiveFileNames);
87033         var configFileWatcher;
87034         if (configFileName) {
87035             configFileWatcher = watchFile(host, configFileName, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ConfigFile);
87036         }
87037         var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return compilerOptions; }, directoryStructureHost);
87038         ts.setGetSourceFileAsHashVersioned(compilerHost, host);
87039         var getNewSourceFile = compilerHost.getSourceFile;
87040         compilerHost.getSourceFile = function (fileName) {
87041             var args = [];
87042             for (var _i = 1; _i < arguments.length; _i++) {
87043                 args[_i - 1] = arguments[_i];
87044             }
87045             return getVersionedSourceFileByPath.apply(void 0, __spreadArrays([fileName, toPath(fileName)], args));
87046         };
87047         compilerHost.getSourceFileByPath = getVersionedSourceFileByPath;
87048         compilerHost.getNewLine = function () { return newLine; };
87049         compilerHost.fileExists = fileExists;
87050         compilerHost.onReleaseOldSourceFile = onReleaseOldSourceFile;
87051         compilerHost.toPath = toPath;
87052         compilerHost.getCompilationSettings = function () { return compilerOptions; };
87053         compilerHost.useSourceOfProjectReferenceRedirect = ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect);
87054         compilerHost.watchDirectoryOfFailedLookupLocation = function (dir, cb, flags) { return watchDirectory(host, dir, cb, flags, watchOptions, ts.WatchType.FailedLookupLocations); };
87055         compilerHost.watchTypeRootsDirectory = function (dir, cb, flags) { return watchDirectory(host, dir, cb, flags, watchOptions, ts.WatchType.TypeRoots); };
87056         compilerHost.getCachedDirectoryStructureHost = function () { return cachedDirectoryStructureHost; };
87057         compilerHost.onInvalidatedResolution = scheduleProgramUpdate;
87058         compilerHost.onChangedAutomaticTypeDirectiveNames = function () {
87059             hasChangedAutomaticTypeDirectiveNames = true;
87060             scheduleProgramUpdate();
87061         };
87062         compilerHost.fileIsOpen = ts.returnFalse;
87063         compilerHost.getCurrentProgram = getCurrentProgram;
87064         compilerHost.writeLog = writeLog;
87065         var resolutionCache = ts.createResolutionCache(compilerHost, configFileName ?
87066             ts.getDirectoryPath(ts.getNormalizedAbsolutePath(configFileName, currentDirectory)) :
87067             currentDirectory, false);
87068         compilerHost.resolveModuleNames = host.resolveModuleNames ?
87069             (function () {
87070                 var args = [];
87071                 for (var _i = 0; _i < arguments.length; _i++) {
87072                     args[_i] = arguments[_i];
87073                 }
87074                 return host.resolveModuleNames.apply(host, args);
87075             }) :
87076             (function (moduleNames, containingFile, reusedNames, redirectedReference) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); });
87077         compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ?
87078             (function () {
87079                 var args = [];
87080                 for (var _i = 0; _i < arguments.length; _i++) {
87081                     args[_i] = arguments[_i];
87082                 }
87083                 return host.resolveTypeReferenceDirectives.apply(host, args);
87084             }) :
87085             (function (typeDirectiveNames, containingFile, redirectedReference) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); });
87086         var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
87087         builderProgram = readBuilderProgram(compilerOptions, compilerHost);
87088         synchronizeProgram();
87089         watchConfigFileWildCardDirectories();
87090         return configFileName ?
87091             { getCurrentProgram: getCurrentBuilderProgram, getProgram: updateProgram, close: close } :
87092             { getCurrentProgram: getCurrentBuilderProgram, getProgram: updateProgram, updateRootFileNames: updateRootFileNames, close: close };
87093         function close() {
87094             resolutionCache.clear();
87095             ts.clearMap(sourceFilesCache, function (value) {
87096                 if (value && value.fileWatcher) {
87097                     value.fileWatcher.close();
87098                     value.fileWatcher = undefined;
87099                 }
87100             });
87101             if (configFileWatcher) {
87102                 configFileWatcher.close();
87103                 configFileWatcher = undefined;
87104             }
87105             if (watchedWildcardDirectories) {
87106                 ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcherOf);
87107                 watchedWildcardDirectories = undefined;
87108             }
87109             if (missingFilesMap) {
87110                 ts.clearMap(missingFilesMap, ts.closeFileWatcher);
87111                 missingFilesMap = undefined;
87112             }
87113         }
87114         function getCurrentBuilderProgram() {
87115             return builderProgram;
87116         }
87117         function getCurrentProgram() {
87118             return builderProgram && builderProgram.getProgramOrUndefined();
87119         }
87120         function synchronizeProgram() {
87121             writeLog("Synchronizing program");
87122             var program = getCurrentBuilderProgram();
87123             if (hasChangedCompilerOptions) {
87124                 newLine = updateNewLine();
87125                 if (program && ts.changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions)) {
87126                     resolutionCache.clear();
87127                 }
87128             }
87129             var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution);
87130             if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, projectReferences)) {
87131                 if (hasChangedConfigFileParsingErrors) {
87132                     builderProgram = createProgram(undefined, undefined, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
87133                     hasChangedConfigFileParsingErrors = false;
87134                 }
87135             }
87136             else {
87137                 createNewProgram(hasInvalidatedResolution);
87138             }
87139             if (host.afterProgramCreate && program !== builderProgram) {
87140                 host.afterProgramCreate(builderProgram);
87141             }
87142             return builderProgram;
87143         }
87144         function createNewProgram(hasInvalidatedResolution) {
87145             writeLog("CreatingProgramWith::");
87146             writeLog("  roots: " + JSON.stringify(rootFileNames));
87147             writeLog("  options: " + JSON.stringify(compilerOptions));
87148             var needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !getCurrentProgram();
87149             hasChangedCompilerOptions = false;
87150             hasChangedConfigFileParsingErrors = false;
87151             resolutionCache.startCachingPerDirectoryResolution();
87152             compilerHost.hasInvalidatedResolution = hasInvalidatedResolution;
87153             compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
87154             hasChangedAutomaticTypeDirectiveNames = false;
87155             builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
87156             resolutionCache.finishCachingPerDirectoryResolution();
87157             ts.updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = ts.createMap()), watchMissingFilePath);
87158             if (needsUpdateInTypeRootWatch) {
87159                 resolutionCache.updateTypeRootsWatch();
87160             }
87161             if (missingFilePathsRequestedForRelease) {
87162                 for (var _i = 0, missingFilePathsRequestedForRelease_1 = missingFilePathsRequestedForRelease; _i < missingFilePathsRequestedForRelease_1.length; _i++) {
87163                     var missingFilePath = missingFilePathsRequestedForRelease_1[_i];
87164                     if (!missingFilesMap.has(missingFilePath)) {
87165                         sourceFilesCache.delete(missingFilePath);
87166                     }
87167                 }
87168                 missingFilePathsRequestedForRelease = undefined;
87169             }
87170         }
87171         function updateRootFileNames(files) {
87172             ts.Debug.assert(!configFileName, "Cannot update root file names with config file watch mode");
87173             rootFileNames = files;
87174             scheduleProgramUpdate();
87175         }
87176         function updateNewLine() {
87177             return ts.getNewLineCharacter(compilerOptions || optionsToExtendForConfigFile, function () { return host.getNewLine(); });
87178         }
87179         function toPath(fileName) {
87180             return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
87181         }
87182         function isFileMissingOnHost(hostSourceFile) {
87183             return typeof hostSourceFile === "boolean";
87184         }
87185         function isFilePresenceUnknownOnHost(hostSourceFile) {
87186             return typeof hostSourceFile.version === "boolean";
87187         }
87188         function fileExists(fileName) {
87189             var path = toPath(fileName);
87190             if (isFileMissingOnHost(sourceFilesCache.get(path))) {
87191                 return false;
87192             }
87193             return directoryStructureHost.fileExists(fileName);
87194         }
87195         function getVersionedSourceFileByPath(fileName, path, languageVersion, onError, shouldCreateNewSourceFile) {
87196             var hostSourceFile = sourceFilesCache.get(path);
87197             if (isFileMissingOnHost(hostSourceFile)) {
87198                 return undefined;
87199             }
87200             if (hostSourceFile === undefined || shouldCreateNewSourceFile || isFilePresenceUnknownOnHost(hostSourceFile)) {
87201                 var sourceFile = getNewSourceFile(fileName, languageVersion, onError);
87202                 if (hostSourceFile) {
87203                     if (sourceFile) {
87204                         hostSourceFile.sourceFile = sourceFile;
87205                         hostSourceFile.version = sourceFile.version;
87206                         if (!hostSourceFile.fileWatcher) {
87207                             hostSourceFile.fileWatcher = watchFilePath(host, fileName, onSourceFileChange, ts.PollingInterval.Low, watchOptions, path, ts.WatchType.SourceFile);
87208                         }
87209                     }
87210                     else {
87211                         if (hostSourceFile.fileWatcher) {
87212                             hostSourceFile.fileWatcher.close();
87213                         }
87214                         sourceFilesCache.set(path, false);
87215                     }
87216                 }
87217                 else {
87218                     if (sourceFile) {
87219                         var fileWatcher = watchFilePath(host, fileName, onSourceFileChange, ts.PollingInterval.Low, watchOptions, path, ts.WatchType.SourceFile);
87220                         sourceFilesCache.set(path, { sourceFile: sourceFile, version: sourceFile.version, fileWatcher: fileWatcher });
87221                     }
87222                     else {
87223                         sourceFilesCache.set(path, false);
87224                     }
87225                 }
87226                 return sourceFile;
87227             }
87228             return hostSourceFile.sourceFile;
87229         }
87230         function nextSourceFileVersion(path) {
87231             var hostSourceFile = sourceFilesCache.get(path);
87232             if (hostSourceFile !== undefined) {
87233                 if (isFileMissingOnHost(hostSourceFile)) {
87234                     sourceFilesCache.set(path, { version: false });
87235                 }
87236                 else {
87237                     hostSourceFile.version = false;
87238                 }
87239             }
87240         }
87241         function getSourceVersion(path) {
87242             var hostSourceFile = sourceFilesCache.get(path);
87243             return !hostSourceFile || !hostSourceFile.version ? undefined : hostSourceFile.version;
87244         }
87245         function onReleaseOldSourceFile(oldSourceFile, _oldOptions, hasSourceFileByPath) {
87246             var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.resolvedPath);
87247             if (hostSourceFileInfo !== undefined) {
87248                 if (isFileMissingOnHost(hostSourceFileInfo)) {
87249                     (missingFilePathsRequestedForRelease || (missingFilePathsRequestedForRelease = [])).push(oldSourceFile.path);
87250                 }
87251                 else if (hostSourceFileInfo.sourceFile === oldSourceFile) {
87252                     if (hostSourceFileInfo.fileWatcher) {
87253                         hostSourceFileInfo.fileWatcher.close();
87254                     }
87255                     sourceFilesCache.delete(oldSourceFile.resolvedPath);
87256                     if (!hasSourceFileByPath) {
87257                         resolutionCache.removeResolutionsOfFile(oldSourceFile.path);
87258                     }
87259                 }
87260             }
87261         }
87262         function reportWatchDiagnostic(message) {
87263             if (host.onWatchStatusChange) {
87264                 host.onWatchStatusChange(ts.createCompilerDiagnostic(message), newLine, compilerOptions || optionsToExtendForConfigFile);
87265             }
87266         }
87267         function scheduleProgramUpdate() {
87268             if (!host.setTimeout || !host.clearTimeout) {
87269                 return;
87270             }
87271             if (timerToUpdateProgram) {
87272                 host.clearTimeout(timerToUpdateProgram);
87273             }
87274             writeLog("Scheduling update");
87275             timerToUpdateProgram = host.setTimeout(updateProgramWithWatchStatus, 250);
87276         }
87277         function scheduleProgramReload() {
87278             ts.Debug.assert(!!configFileName);
87279             reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
87280             scheduleProgramUpdate();
87281         }
87282         function updateProgramWithWatchStatus() {
87283             timerToUpdateProgram = undefined;
87284             reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
87285             updateProgram();
87286         }
87287         function updateProgram() {
87288             switch (reloadLevel) {
87289                 case ts.ConfigFileProgramReloadLevel.Partial:
87290                     ts.perfLogger.logStartUpdateProgram("PartialConfigReload");
87291                     reloadFileNamesFromConfigFile();
87292                     break;
87293                 case ts.ConfigFileProgramReloadLevel.Full:
87294                     ts.perfLogger.logStartUpdateProgram("FullConfigReload");
87295                     reloadConfigFile();
87296                     break;
87297                 default:
87298                     ts.perfLogger.logStartUpdateProgram("SynchronizeProgram");
87299                     synchronizeProgram();
87300                     break;
87301             }
87302             ts.perfLogger.logStopUpdateProgram("Done");
87303             return getCurrentBuilderProgram();
87304         }
87305         function reloadFileNamesFromConfigFile() {
87306             writeLog("Reloading new file names and options");
87307             var result = ts.getFileNamesFromConfigSpecs(configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost);
87308             if (ts.updateErrorForNoInputFiles(result, ts.getNormalizedAbsolutePath(configFileName, currentDirectory), configFileSpecs, configFileParsingDiagnostics, canConfigFileJsonReportNoInputFiles)) {
87309                 hasChangedConfigFileParsingErrors = true;
87310             }
87311             rootFileNames = result.fileNames;
87312             synchronizeProgram();
87313         }
87314         function reloadConfigFile() {
87315             writeLog("Reloading config file: " + configFileName);
87316             reloadLevel = ts.ConfigFileProgramReloadLevel.None;
87317             if (cachedDirectoryStructureHost) {
87318                 cachedDirectoryStructureHost.clearCache();
87319             }
87320             parseConfigFile();
87321             hasChangedCompilerOptions = true;
87322             synchronizeProgram();
87323             watchConfigFileWildCardDirectories();
87324         }
87325         function parseConfigFile() {
87326             setConfigFileParsingResult(ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtendForConfigFile, parseConfigFileHost, undefined, watchOptionsToExtend, extraFileExtensions));
87327         }
87328         function setConfigFileParsingResult(configFileParseResult) {
87329             rootFileNames = configFileParseResult.fileNames;
87330             compilerOptions = configFileParseResult.options;
87331             watchOptions = configFileParseResult.watchOptions;
87332             configFileSpecs = configFileParseResult.configFileSpecs;
87333             projectReferences = configFileParseResult.projectReferences;
87334             configFileParsingDiagnostics = ts.getConfigFileParsingDiagnostics(configFileParseResult).slice();
87335             canConfigFileJsonReportNoInputFiles = ts.canJsonReportNoInutFiles(configFileParseResult.raw);
87336             hasChangedConfigFileParsingErrors = true;
87337         }
87338         function onSourceFileChange(fileName, eventKind, path) {
87339             updateCachedSystemWithFile(fileName, path, eventKind);
87340             if (eventKind === ts.FileWatcherEventKind.Deleted && sourceFilesCache.has(path)) {
87341                 resolutionCache.invalidateResolutionOfFile(path);
87342             }
87343             resolutionCache.removeResolutionsFromProjectReferenceRedirects(path);
87344             nextSourceFileVersion(path);
87345             scheduleProgramUpdate();
87346         }
87347         function updateCachedSystemWithFile(fileName, path, eventKind) {
87348             if (cachedDirectoryStructureHost) {
87349                 cachedDirectoryStructureHost.addOrDeleteFile(fileName, path, eventKind);
87350             }
87351         }
87352         function watchMissingFilePath(missingFilePath) {
87353             return watchFilePath(host, missingFilePath, onMissingFileChange, ts.PollingInterval.Medium, watchOptions, missingFilePath, ts.WatchType.MissingFile);
87354         }
87355         function onMissingFileChange(fileName, eventKind, missingFilePath) {
87356             updateCachedSystemWithFile(fileName, missingFilePath, eventKind);
87357             if (eventKind === ts.FileWatcherEventKind.Created && missingFilesMap.has(missingFilePath)) {
87358                 missingFilesMap.get(missingFilePath).close();
87359                 missingFilesMap.delete(missingFilePath);
87360                 nextSourceFileVersion(missingFilePath);
87361                 scheduleProgramUpdate();
87362             }
87363         }
87364         function watchConfigFileWildCardDirectories() {
87365             if (configFileSpecs) {
87366                 ts.updateWatchingWildcardDirectories(watchedWildcardDirectories || (watchedWildcardDirectories = ts.createMap()), ts.createMapFromTemplate(configFileSpecs.wildcardDirectories), watchWildcardDirectory);
87367             }
87368             else if (watchedWildcardDirectories) {
87369                 ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcherOf);
87370             }
87371         }
87372         function watchWildcardDirectory(directory, flags) {
87373             return watchDirectory(host, directory, function (fileOrDirectory) {
87374                 ts.Debug.assert(!!configFileName);
87375                 var fileOrDirectoryPath = toPath(fileOrDirectory);
87376                 if (cachedDirectoryStructureHost) {
87377                     cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
87378                 }
87379                 nextSourceFileVersion(fileOrDirectoryPath);
87380                 fileOrDirectoryPath = ts.removeIgnoredPath(fileOrDirectoryPath);
87381                 if (!fileOrDirectoryPath)
87382                     return;
87383                 if (fileOrDirectoryPath !== directory && ts.hasExtension(fileOrDirectoryPath) && !ts.isSupportedSourceFileName(fileOrDirectory, compilerOptions)) {
87384                     writeLog("Project: " + configFileName + " Detected file add/remove of non supported extension: " + fileOrDirectory);
87385                     return;
87386                 }
87387                 if (reloadLevel !== ts.ConfigFileProgramReloadLevel.Full) {
87388                     reloadLevel = ts.ConfigFileProgramReloadLevel.Partial;
87389                     scheduleProgramUpdate();
87390                 }
87391             }, flags, watchOptions, ts.WatchType.WildcardDirectory);
87392         }
87393     }
87394     ts.createWatchProgram = createWatchProgram;
87395 })(ts || (ts = {}));
87396 var ts;
87397 (function (ts) {
87398     var UpToDateStatusType;
87399     (function (UpToDateStatusType) {
87400         UpToDateStatusType[UpToDateStatusType["Unbuildable"] = 0] = "Unbuildable";
87401         UpToDateStatusType[UpToDateStatusType["UpToDate"] = 1] = "UpToDate";
87402         UpToDateStatusType[UpToDateStatusType["UpToDateWithUpstreamTypes"] = 2] = "UpToDateWithUpstreamTypes";
87403         UpToDateStatusType[UpToDateStatusType["OutOfDateWithPrepend"] = 3] = "OutOfDateWithPrepend";
87404         UpToDateStatusType[UpToDateStatusType["OutputMissing"] = 4] = "OutputMissing";
87405         UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 5] = "OutOfDateWithSelf";
87406         UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 6] = "OutOfDateWithUpstream";
87407         UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 7] = "UpstreamOutOfDate";
87408         UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 8] = "UpstreamBlocked";
87409         UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 9] = "ComputingUpstream";
87410         UpToDateStatusType[UpToDateStatusType["TsVersionOutputOfDate"] = 10] = "TsVersionOutputOfDate";
87411         UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 11] = "ContainerOnly";
87412     })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {}));
87413     function resolveConfigFileProjectName(project) {
87414         if (ts.fileExtensionIs(project, ".json")) {
87415             return project;
87416         }
87417         return ts.combinePaths(project, "tsconfig.json");
87418     }
87419     ts.resolveConfigFileProjectName = resolveConfigFileProjectName;
87420 })(ts || (ts = {}));
87421 var ts;
87422 (function (ts) {
87423     var minimumDate = new Date(-8640000000000000);
87424     var maximumDate = new Date(8640000000000000);
87425     var BuildResultFlags;
87426     (function (BuildResultFlags) {
87427         BuildResultFlags[BuildResultFlags["None"] = 0] = "None";
87428         BuildResultFlags[BuildResultFlags["Success"] = 1] = "Success";
87429         BuildResultFlags[BuildResultFlags["DeclarationOutputUnchanged"] = 2] = "DeclarationOutputUnchanged";
87430         BuildResultFlags[BuildResultFlags["ConfigFileErrors"] = 4] = "ConfigFileErrors";
87431         BuildResultFlags[BuildResultFlags["SyntaxErrors"] = 8] = "SyntaxErrors";
87432         BuildResultFlags[BuildResultFlags["TypeErrors"] = 16] = "TypeErrors";
87433         BuildResultFlags[BuildResultFlags["DeclarationEmitErrors"] = 32] = "DeclarationEmitErrors";
87434         BuildResultFlags[BuildResultFlags["EmitErrors"] = 64] = "EmitErrors";
87435         BuildResultFlags[BuildResultFlags["AnyErrors"] = 124] = "AnyErrors";
87436     })(BuildResultFlags || (BuildResultFlags = {}));
87437     function createConfigFileMap() {
87438         return ts.createMap();
87439     }
87440     function getOrCreateValueFromConfigFileMap(configFileMap, resolved, createT) {
87441         var existingValue = configFileMap.get(resolved);
87442         var newValue;
87443         if (!existingValue) {
87444             newValue = createT();
87445             configFileMap.set(resolved, newValue);
87446         }
87447         return existingValue || newValue;
87448     }
87449     function getOrCreateValueMapFromConfigFileMap(configFileMap, resolved) {
87450         return getOrCreateValueFromConfigFileMap(configFileMap, resolved, ts.createMap);
87451     }
87452     function newer(date1, date2) {
87453         return date2 > date1 ? date2 : date1;
87454     }
87455     function isDeclarationFile(fileName) {
87456         return ts.fileExtensionIs(fileName, ".d.ts");
87457     }
87458     function isCircularBuildOrder(buildOrder) {
87459         return !!buildOrder && !!buildOrder.buildOrder;
87460     }
87461     ts.isCircularBuildOrder = isCircularBuildOrder;
87462     function getBuildOrderFromAnyBuildOrder(anyBuildOrder) {
87463         return isCircularBuildOrder(anyBuildOrder) ? anyBuildOrder.buildOrder : anyBuildOrder;
87464     }
87465     ts.getBuildOrderFromAnyBuildOrder = getBuildOrderFromAnyBuildOrder;
87466     function createBuilderStatusReporter(system, pretty) {
87467         return function (diagnostic) {
87468             var output = pretty ? "[" + ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] " : ts.getLocaleTimeString(system) + " - ";
87469             output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (system.newLine + system.newLine);
87470             system.write(output);
87471         };
87472     }
87473     ts.createBuilderStatusReporter = createBuilderStatusReporter;
87474     function createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus) {
87475         var host = ts.createProgramHost(system, createProgram);
87476         host.getModifiedTime = system.getModifiedTime ? function (path) { return system.getModifiedTime(path); } : ts.returnUndefined;
87477         host.setModifiedTime = system.setModifiedTime ? function (path, date) { return system.setModifiedTime(path, date); } : ts.noop;
87478         host.deleteFile = system.deleteFile ? function (path) { return system.deleteFile(path); } : ts.noop;
87479         host.reportDiagnostic = reportDiagnostic || ts.createDiagnosticReporter(system);
87480         host.reportSolutionBuilderStatus = reportSolutionBuilderStatus || createBuilderStatusReporter(system);
87481         host.now = ts.maybeBind(system, system.now);
87482         return host;
87483     }
87484     function createSolutionBuilderHost(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus, reportErrorSummary) {
87485         if (system === void 0) { system = ts.sys; }
87486         var host = createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus);
87487         host.reportErrorSummary = reportErrorSummary;
87488         return host;
87489     }
87490     ts.createSolutionBuilderHost = createSolutionBuilderHost;
87491     function createSolutionBuilderWithWatchHost(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus, reportWatchStatus) {
87492         if (system === void 0) { system = ts.sys; }
87493         var host = createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus);
87494         var watchHost = ts.createWatchHost(system, reportWatchStatus);
87495         ts.copyProperties(host, watchHost);
87496         return host;
87497     }
87498     ts.createSolutionBuilderWithWatchHost = createSolutionBuilderWithWatchHost;
87499     function getCompilerOptionsOfBuildOptions(buildOptions) {
87500         var result = {};
87501         ts.commonOptionsWithBuild.forEach(function (option) {
87502             if (ts.hasProperty(buildOptions, option.name))
87503                 result[option.name] = buildOptions[option.name];
87504         });
87505         return result;
87506     }
87507     function createSolutionBuilder(host, rootNames, defaultOptions) {
87508         return createSolutionBuilderWorker(false, host, rootNames, defaultOptions);
87509     }
87510     ts.createSolutionBuilder = createSolutionBuilder;
87511     function createSolutionBuilderWithWatch(host, rootNames, defaultOptions, baseWatchOptions) {
87512         return createSolutionBuilderWorker(true, host, rootNames, defaultOptions, baseWatchOptions);
87513     }
87514     ts.createSolutionBuilderWithWatch = createSolutionBuilderWithWatch;
87515     function createSolutionBuilderState(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions) {
87516         var host = hostOrHostWithWatch;
87517         var hostWithWatch = hostOrHostWithWatch;
87518         var currentDirectory = host.getCurrentDirectory();
87519         var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
87520         var baseCompilerOptions = getCompilerOptionsOfBuildOptions(options);
87521         var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return state.projectCompilerOptions; });
87522         ts.setGetSourceFileAsHashVersioned(compilerHost, host);
87523         compilerHost.getParsedCommandLine = function (fileName) { return parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName)); };
87524         compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames);
87525         compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives);
87526         var moduleResolutionCache = !compilerHost.resolveModuleNames ? ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined;
87527         if (!compilerHost.resolveModuleNames) {
87528             var loader_3 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference).resolvedModule; };
87529             compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference) {
87530                 return ts.loadWithLocalCache(ts.Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader_3);
87531             };
87532         }
87533         var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchFilePath = _a.watchFilePath, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;
87534         var state = {
87535             host: host,
87536             hostWithWatch: hostWithWatch,
87537             currentDirectory: currentDirectory,
87538             getCanonicalFileName: getCanonicalFileName,
87539             parseConfigFileHost: ts.parseConfigHostFromCompilerHostLike(host),
87540             writeFileName: host.trace ? function (s) { return host.trace(s); } : undefined,
87541             options: options,
87542             baseCompilerOptions: baseCompilerOptions,
87543             rootNames: rootNames,
87544             baseWatchOptions: baseWatchOptions,
87545             resolvedConfigFilePaths: ts.createMap(),
87546             configFileCache: createConfigFileMap(),
87547             projectStatus: createConfigFileMap(),
87548             buildInfoChecked: createConfigFileMap(),
87549             extendedConfigCache: ts.createMap(),
87550             builderPrograms: createConfigFileMap(),
87551             diagnostics: createConfigFileMap(),
87552             projectPendingBuild: createConfigFileMap(),
87553             projectErrorsReported: createConfigFileMap(),
87554             compilerHost: compilerHost,
87555             moduleResolutionCache: moduleResolutionCache,
87556             buildOrder: undefined,
87557             readFileWithCache: function (f) { return host.readFile(f); },
87558             projectCompilerOptions: baseCompilerOptions,
87559             cache: undefined,
87560             allProjectBuildPending: true,
87561             needsSummary: true,
87562             watchAllProjectsPending: watch,
87563             currentInvalidatedProject: undefined,
87564             watch: watch,
87565             allWatchedWildcardDirectories: createConfigFileMap(),
87566             allWatchedInputFiles: createConfigFileMap(),
87567             allWatchedConfigFiles: createConfigFileMap(),
87568             timerToBuildInvalidatedProject: undefined,
87569             reportFileChangeDetected: false,
87570             watchFile: watchFile,
87571             watchFilePath: watchFilePath,
87572             watchDirectory: watchDirectory,
87573             writeLog: writeLog,
87574         };
87575         return state;
87576     }
87577     function toPath(state, fileName) {
87578         return ts.toPath(fileName, state.currentDirectory, state.getCanonicalFileName);
87579     }
87580     function toResolvedConfigFilePath(state, fileName) {
87581         var resolvedConfigFilePaths = state.resolvedConfigFilePaths;
87582         var path = resolvedConfigFilePaths.get(fileName);
87583         if (path !== undefined)
87584             return path;
87585         var resolvedPath = toPath(state, fileName);
87586         resolvedConfigFilePaths.set(fileName, resolvedPath);
87587         return resolvedPath;
87588     }
87589     function isParsedCommandLine(entry) {
87590         return !!entry.options;
87591     }
87592     function parseConfigFile(state, configFileName, configFilePath) {
87593         var configFileCache = state.configFileCache;
87594         var value = configFileCache.get(configFilePath);
87595         if (value) {
87596             return isParsedCommandLine(value) ? value : undefined;
87597         }
87598         var diagnostic;
87599         var parseConfigFileHost = state.parseConfigFileHost, baseCompilerOptions = state.baseCompilerOptions, baseWatchOptions = state.baseWatchOptions, extendedConfigCache = state.extendedConfigCache, host = state.host;
87600         var parsed;
87601         if (host.getParsedCommandLine) {
87602             parsed = host.getParsedCommandLine(configFileName);
87603             if (!parsed)
87604                 diagnostic = ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, configFileName);
87605         }
87606         else {
87607             parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = function (d) { return diagnostic = d; };
87608             parsed = ts.getParsedCommandLineOfConfigFile(configFileName, baseCompilerOptions, parseConfigFileHost, extendedConfigCache, baseWatchOptions);
87609             parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = ts.noop;
87610         }
87611         configFileCache.set(configFilePath, parsed || diagnostic);
87612         return parsed;
87613     }
87614     function resolveProjectName(state, name) {
87615         return ts.resolveConfigFileProjectName(ts.resolvePath(state.currentDirectory, name));
87616     }
87617     function createBuildOrder(state, roots) {
87618         var temporaryMarks = ts.createMap();
87619         var permanentMarks = ts.createMap();
87620         var circularityReportStack = [];
87621         var buildOrder;
87622         var circularDiagnostics;
87623         for (var _i = 0, roots_1 = roots; _i < roots_1.length; _i++) {
87624             var root = roots_1[_i];
87625             visit(root);
87626         }
87627         return circularDiagnostics ?
87628             { buildOrder: buildOrder || ts.emptyArray, circularDiagnostics: circularDiagnostics } :
87629             buildOrder || ts.emptyArray;
87630         function visit(configFileName, inCircularContext) {
87631             var projPath = toResolvedConfigFilePath(state, configFileName);
87632             if (permanentMarks.has(projPath))
87633                 return;
87634             if (temporaryMarks.has(projPath)) {
87635                 if (!inCircularContext) {
87636                     (circularDiagnostics || (circularDiagnostics = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n")));
87637                 }
87638                 return;
87639             }
87640             temporaryMarks.set(projPath, true);
87641             circularityReportStack.push(configFileName);
87642             var parsed = parseConfigFile(state, configFileName, projPath);
87643             if (parsed && parsed.projectReferences) {
87644                 for (var _i = 0, _a = parsed.projectReferences; _i < _a.length; _i++) {
87645                     var ref = _a[_i];
87646                     var resolvedRefPath = resolveProjectName(state, ref.path);
87647                     visit(resolvedRefPath, inCircularContext || ref.circular);
87648                 }
87649             }
87650             circularityReportStack.pop();
87651             permanentMarks.set(projPath, true);
87652             (buildOrder || (buildOrder = [])).push(configFileName);
87653         }
87654     }
87655     function getBuildOrder(state) {
87656         return state.buildOrder || createStateBuildOrder(state);
87657     }
87658     function createStateBuildOrder(state) {
87659         var buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); }));
87660         state.resolvedConfigFilePaths.clear();
87661         var currentProjects = ts.arrayToSet(getBuildOrderFromAnyBuildOrder(buildOrder), function (resolved) { return toResolvedConfigFilePath(state, resolved); });
87662         var noopOnDelete = { onDeleteValue: ts.noop };
87663         ts.mutateMapSkippingNewValues(state.configFileCache, currentProjects, noopOnDelete);
87664         ts.mutateMapSkippingNewValues(state.projectStatus, currentProjects, noopOnDelete);
87665         ts.mutateMapSkippingNewValues(state.buildInfoChecked, currentProjects, noopOnDelete);
87666         ts.mutateMapSkippingNewValues(state.builderPrograms, currentProjects, noopOnDelete);
87667         ts.mutateMapSkippingNewValues(state.diagnostics, currentProjects, noopOnDelete);
87668         ts.mutateMapSkippingNewValues(state.projectPendingBuild, currentProjects, noopOnDelete);
87669         ts.mutateMapSkippingNewValues(state.projectErrorsReported, currentProjects, noopOnDelete);
87670         if (state.watch) {
87671             ts.mutateMapSkippingNewValues(state.allWatchedConfigFiles, currentProjects, { onDeleteValue: ts.closeFileWatcher });
87672             ts.mutateMapSkippingNewValues(state.allWatchedWildcardDirectories, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcherOf); } });
87673             ts.mutateMapSkippingNewValues(state.allWatchedInputFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } });
87674         }
87675         return state.buildOrder = buildOrder;
87676     }
87677     function getBuildOrderFor(state, project, onlyReferences) {
87678         var resolvedProject = project && resolveProjectName(state, project);
87679         var buildOrderFromState = getBuildOrder(state);
87680         if (isCircularBuildOrder(buildOrderFromState))
87681             return buildOrderFromState;
87682         if (resolvedProject) {
87683             var projectPath_1 = toResolvedConfigFilePath(state, resolvedProject);
87684             var projectIndex = ts.findIndex(buildOrderFromState, function (configFileName) { return toResolvedConfigFilePath(state, configFileName) === projectPath_1; });
87685             if (projectIndex === -1)
87686                 return undefined;
87687         }
87688         var buildOrder = resolvedProject ? createBuildOrder(state, [resolvedProject]) : buildOrderFromState;
87689         ts.Debug.assert(!isCircularBuildOrder(buildOrder));
87690         ts.Debug.assert(!onlyReferences || resolvedProject !== undefined);
87691         ts.Debug.assert(!onlyReferences || buildOrder[buildOrder.length - 1] === resolvedProject);
87692         return onlyReferences ? buildOrder.slice(0, buildOrder.length - 1) : buildOrder;
87693     }
87694     function enableCache(state) {
87695         if (state.cache) {
87696             disableCache(state);
87697         }
87698         var compilerHost = state.compilerHost, host = state.host;
87699         var originalReadFileWithCache = state.readFileWithCache;
87700         var originalGetSourceFile = compilerHost.getSourceFile;
87701         var _a = ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return toPath(state, fileName); }, function () {
87702             var args = [];
87703             for (var _i = 0; _i < arguments.length; _i++) {
87704                 args[_i] = arguments[_i];
87705             }
87706             return originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args));
87707         }), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile, getSourceFileWithCache = _a.getSourceFileWithCache, readFileWithCache = _a.readFileWithCache;
87708         state.readFileWithCache = readFileWithCache;
87709         compilerHost.getSourceFile = getSourceFileWithCache;
87710         state.cache = {
87711             originalReadFile: originalReadFile,
87712             originalFileExists: originalFileExists,
87713             originalDirectoryExists: originalDirectoryExists,
87714             originalCreateDirectory: originalCreateDirectory,
87715             originalWriteFile: originalWriteFile,
87716             originalReadFileWithCache: originalReadFileWithCache,
87717             originalGetSourceFile: originalGetSourceFile,
87718         };
87719     }
87720     function disableCache(state) {
87721         if (!state.cache)
87722             return;
87723         var cache = state.cache, host = state.host, compilerHost = state.compilerHost, extendedConfigCache = state.extendedConfigCache, moduleResolutionCache = state.moduleResolutionCache;
87724         host.readFile = cache.originalReadFile;
87725         host.fileExists = cache.originalFileExists;
87726         host.directoryExists = cache.originalDirectoryExists;
87727         host.createDirectory = cache.originalCreateDirectory;
87728         host.writeFile = cache.originalWriteFile;
87729         compilerHost.getSourceFile = cache.originalGetSourceFile;
87730         state.readFileWithCache = cache.originalReadFileWithCache;
87731         extendedConfigCache.clear();
87732         if (moduleResolutionCache) {
87733             moduleResolutionCache.directoryToModuleNameMap.clear();
87734             moduleResolutionCache.moduleNameToDirectoryMap.clear();
87735         }
87736         state.cache = undefined;
87737     }
87738     function clearProjectStatus(state, resolved) {
87739         state.projectStatus.delete(resolved);
87740         state.diagnostics.delete(resolved);
87741     }
87742     function addProjToQueue(_a, proj, reloadLevel) {
87743         var projectPendingBuild = _a.projectPendingBuild;
87744         var value = projectPendingBuild.get(proj);
87745         if (value === undefined) {
87746             projectPendingBuild.set(proj, reloadLevel);
87747         }
87748         else if (value < reloadLevel) {
87749             projectPendingBuild.set(proj, reloadLevel);
87750         }
87751     }
87752     function setupInitialBuild(state, cancellationToken) {
87753         if (!state.allProjectBuildPending)
87754             return;
87755         state.allProjectBuildPending = false;
87756         if (state.options.watch) {
87757             reportWatchStatus(state, ts.Diagnostics.Starting_compilation_in_watch_mode);
87758         }
87759         enableCache(state);
87760         var buildOrder = getBuildOrderFromAnyBuildOrder(getBuildOrder(state));
87761         buildOrder.forEach(function (configFileName) {
87762             return state.projectPendingBuild.set(toResolvedConfigFilePath(state, configFileName), ts.ConfigFileProgramReloadLevel.None);
87763         });
87764         if (cancellationToken) {
87765             cancellationToken.throwIfCancellationRequested();
87766         }
87767     }
87768     var InvalidatedProjectKind;
87769     (function (InvalidatedProjectKind) {
87770         InvalidatedProjectKind[InvalidatedProjectKind["Build"] = 0] = "Build";
87771         InvalidatedProjectKind[InvalidatedProjectKind["UpdateBundle"] = 1] = "UpdateBundle";
87772         InvalidatedProjectKind[InvalidatedProjectKind["UpdateOutputFileStamps"] = 2] = "UpdateOutputFileStamps";
87773     })(InvalidatedProjectKind = ts.InvalidatedProjectKind || (ts.InvalidatedProjectKind = {}));
87774     function doneInvalidatedProject(state, projectPath) {
87775         state.projectPendingBuild.delete(projectPath);
87776         state.currentInvalidatedProject = undefined;
87777         return state.diagnostics.has(projectPath) ?
87778             ts.ExitStatus.DiagnosticsPresent_OutputsSkipped :
87779             ts.ExitStatus.Success;
87780     }
87781     function createUpdateOutputFileStampsProject(state, project, projectPath, config, buildOrder) {
87782         var updateOutputFileStampsPending = true;
87783         return {
87784             kind: InvalidatedProjectKind.UpdateOutputFileStamps,
87785             project: project,
87786             projectPath: projectPath,
87787             buildOrder: buildOrder,
87788             getCompilerOptions: function () { return config.options; },
87789             getCurrentDirectory: function () { return state.currentDirectory; },
87790             updateOutputFileStatmps: function () {
87791                 updateOutputTimestamps(state, config, projectPath);
87792                 updateOutputFileStampsPending = false;
87793             },
87794             done: function () {
87795                 if (updateOutputFileStampsPending) {
87796                     updateOutputTimestamps(state, config, projectPath);
87797                 }
87798                 return doneInvalidatedProject(state, projectPath);
87799             }
87800         };
87801     }
87802     function createBuildOrUpdateInvalidedProject(kind, state, project, projectPath, projectIndex, config, buildOrder) {
87803         var Step;
87804         (function (Step) {
87805             Step[Step["CreateProgram"] = 0] = "CreateProgram";
87806             Step[Step["SyntaxDiagnostics"] = 1] = "SyntaxDiagnostics";
87807             Step[Step["SemanticDiagnostics"] = 2] = "SemanticDiagnostics";
87808             Step[Step["Emit"] = 3] = "Emit";
87809             Step[Step["EmitBundle"] = 4] = "EmitBundle";
87810             Step[Step["BuildInvalidatedProjectOfBundle"] = 5] = "BuildInvalidatedProjectOfBundle";
87811             Step[Step["QueueReferencingProjects"] = 6] = "QueueReferencingProjects";
87812             Step[Step["Done"] = 7] = "Done";
87813         })(Step || (Step = {}));
87814         var step = kind === InvalidatedProjectKind.Build ? Step.CreateProgram : Step.EmitBundle;
87815         var program;
87816         var buildResult;
87817         var invalidatedProjectOfBundle;
87818         return kind === InvalidatedProjectKind.Build ?
87819             {
87820                 kind: kind,
87821                 project: project,
87822                 projectPath: projectPath,
87823                 buildOrder: buildOrder,
87824                 getCompilerOptions: function () { return config.options; },
87825                 getCurrentDirectory: function () { return state.currentDirectory; },
87826                 getBuilderProgram: function () { return withProgramOrUndefined(ts.identity); },
87827                 getProgram: function () {
87828                     return withProgramOrUndefined(function (program) { return program.getProgramOrUndefined(); });
87829                 },
87830                 getSourceFile: function (fileName) {
87831                     return withProgramOrUndefined(function (program) { return program.getSourceFile(fileName); });
87832                 },
87833                 getSourceFiles: function () {
87834                     return withProgramOrEmptyArray(function (program) { return program.getSourceFiles(); });
87835                 },
87836                 getOptionsDiagnostics: function (cancellationToken) {
87837                     return withProgramOrEmptyArray(function (program) { return program.getOptionsDiagnostics(cancellationToken); });
87838                 },
87839                 getGlobalDiagnostics: function (cancellationToken) {
87840                     return withProgramOrEmptyArray(function (program) { return program.getGlobalDiagnostics(cancellationToken); });
87841                 },
87842                 getConfigFileParsingDiagnostics: function () {
87843                     return withProgramOrEmptyArray(function (program) { return program.getConfigFileParsingDiagnostics(); });
87844                 },
87845                 getSyntacticDiagnostics: function (sourceFile, cancellationToken) {
87846                     return withProgramOrEmptyArray(function (program) { return program.getSyntacticDiagnostics(sourceFile, cancellationToken); });
87847                 },
87848                 getAllDependencies: function (sourceFile) {
87849                     return withProgramOrEmptyArray(function (program) { return program.getAllDependencies(sourceFile); });
87850                 },
87851                 getSemanticDiagnostics: function (sourceFile, cancellationToken) {
87852                     return withProgramOrEmptyArray(function (program) { return program.getSemanticDiagnostics(sourceFile, cancellationToken); });
87853                 },
87854                 getSemanticDiagnosticsOfNextAffectedFile: function (cancellationToken, ignoreSourceFile) {
87855                     return withProgramOrUndefined(function (program) {
87856                         return (program.getSemanticDiagnosticsOfNextAffectedFile) &&
87857                             program.getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile);
87858                     });
87859                 },
87860                 emit: function (targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
87861                     if (targetSourceFile || emitOnlyDtsFiles) {
87862                         return withProgramOrUndefined(function (program) { return program.emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); });
87863                     }
87864                     executeSteps(Step.SemanticDiagnostics, cancellationToken);
87865                     if (step !== Step.Emit)
87866                         return undefined;
87867                     return emit(writeFile, cancellationToken, customTransformers);
87868                 },
87869                 done: done
87870             } :
87871             {
87872                 kind: kind,
87873                 project: project,
87874                 projectPath: projectPath,
87875                 buildOrder: buildOrder,
87876                 getCompilerOptions: function () { return config.options; },
87877                 getCurrentDirectory: function () { return state.currentDirectory; },
87878                 emit: function (writeFile, customTransformers) {
87879                     if (step !== Step.EmitBundle)
87880                         return invalidatedProjectOfBundle;
87881                     return emitBundle(writeFile, customTransformers);
87882                 },
87883                 done: done,
87884             };
87885         function done(cancellationToken, writeFile, customTransformers) {
87886             executeSteps(Step.Done, cancellationToken, writeFile, customTransformers);
87887             return doneInvalidatedProject(state, projectPath);
87888         }
87889         function withProgramOrUndefined(action) {
87890             executeSteps(Step.CreateProgram);
87891             return program && action(program);
87892         }
87893         function withProgramOrEmptyArray(action) {
87894             return withProgramOrUndefined(action) || ts.emptyArray;
87895         }
87896         function createProgram() {
87897             ts.Debug.assert(program === undefined);
87898             if (state.options.dry) {
87899                 reportStatus(state, ts.Diagnostics.A_non_dry_build_would_build_project_0, project);
87900                 buildResult = BuildResultFlags.Success;
87901                 step = Step.QueueReferencingProjects;
87902                 return;
87903             }
87904             if (state.options.verbose)
87905                 reportStatus(state, ts.Diagnostics.Building_project_0, project);
87906             if (config.fileNames.length === 0) {
87907                 reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
87908                 buildResult = BuildResultFlags.None;
87909                 step = Step.QueueReferencingProjects;
87910                 return;
87911             }
87912             var host = state.host, compilerHost = state.compilerHost;
87913             state.projectCompilerOptions = config.options;
87914             updateModuleResolutionCache(state, project, config);
87915             program = host.createProgram(config.fileNames, config.options, compilerHost, getOldProgram(state, projectPath, config), ts.getConfigFileParsingDiagnostics(config), config.projectReferences);
87916             step++;
87917         }
87918         function handleDiagnostics(diagnostics, errorFlags, errorType) {
87919             if (diagnostics.length) {
87920                 buildResult = buildErrors(state, projectPath, program, config, diagnostics, errorFlags, errorType);
87921                 step = Step.QueueReferencingProjects;
87922             }
87923             else {
87924                 step++;
87925             }
87926         }
87927         function getSyntaxDiagnostics(cancellationToken) {
87928             ts.Debug.assertIsDefined(program);
87929             handleDiagnostics(__spreadArrays(program.getConfigFileParsingDiagnostics(), program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSyntacticDiagnostics(undefined, cancellationToken)), BuildResultFlags.SyntaxErrors, "Syntactic");
87930         }
87931         function getSemanticDiagnostics(cancellationToken) {
87932             handleDiagnostics(ts.Debug.checkDefined(program).getSemanticDiagnostics(undefined, cancellationToken), BuildResultFlags.TypeErrors, "Semantic");
87933         }
87934         function emit(writeFileCallback, cancellationToken, customTransformers) {
87935             ts.Debug.assertIsDefined(program);
87936             ts.Debug.assert(step === Step.Emit);
87937             program.backupState();
87938             var declDiagnostics;
87939             var reportDeclarationDiagnostics = function (d) { return (declDiagnostics || (declDiagnostics = [])).push(d); };
87940             var outputFiles = [];
87941             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;
87942             if (declDiagnostics) {
87943                 program.restoreState();
87944                 buildResult = buildErrors(state, projectPath, program, config, declDiagnostics, BuildResultFlags.DeclarationEmitErrors, "Declaration file");
87945                 step = Step.QueueReferencingProjects;
87946                 return {
87947                     emitSkipped: true,
87948                     diagnostics: emitResult.diagnostics
87949                 };
87950             }
87951             var host = state.host, compilerHost = state.compilerHost;
87952             var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
87953             var newestDeclarationFileContentChangedTime = minimumDate;
87954             var anyDtsChanged = false;
87955             var emitterDiagnostics = ts.createDiagnosticCollection();
87956             var emittedOutputs = ts.createMap();
87957             outputFiles.forEach(function (_a) {
87958                 var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
87959                 var priorChangeTime;
87960                 if (!anyDtsChanged && isDeclarationFile(name)) {
87961                     if (host.fileExists(name) && state.readFileWithCache(name) === text) {
87962                         priorChangeTime = host.getModifiedTime(name);
87963                     }
87964                     else {
87965                         resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
87966                         anyDtsChanged = true;
87967                     }
87968                 }
87969                 emittedOutputs.set(toPath(state, name), name);
87970                 ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
87971                 if (priorChangeTime !== undefined) {
87972                     newestDeclarationFileContentChangedTime = newer(priorChangeTime, newestDeclarationFileContentChangedTime);
87973                 }
87974             });
87975             finishEmit(emitterDiagnostics, emittedOutputs, newestDeclarationFileContentChangedTime, anyDtsChanged, outputFiles.length ? outputFiles[0].name : ts.getFirstProjectOutput(config, !host.useCaseSensitiveFileNames()), resultFlags);
87976             return emitResult;
87977         }
87978         function finishEmit(emitterDiagnostics, emittedOutputs, priorNewestUpdateTime, newestDeclarationFileContentChangedTimeIsMaximumDate, oldestOutputFileName, resultFlags) {
87979             var emitDiagnostics = emitterDiagnostics.getDiagnostics();
87980             if (emitDiagnostics.length) {
87981                 buildResult = buildErrors(state, projectPath, program, config, emitDiagnostics, BuildResultFlags.EmitErrors, "Emit");
87982                 step = Step.QueueReferencingProjects;
87983                 return emitDiagnostics;
87984             }
87985             if (state.writeFileName) {
87986                 emittedOutputs.forEach(function (name) { return listEmittedFile(state, config, name); });
87987                 if (program)
87988                     ts.listFiles(program, state.writeFileName);
87989             }
87990             var newestDeclarationFileContentChangedTime = updateOutputTimestampsWorker(state, config, priorNewestUpdateTime, ts.Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs);
87991             state.diagnostics.delete(projectPath);
87992             state.projectStatus.set(projectPath, {
87993                 type: ts.UpToDateStatusType.UpToDate,
87994                 newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTimeIsMaximumDate ?
87995                     maximumDate :
87996                     newestDeclarationFileContentChangedTime,
87997                 oldestOutputFileName: oldestOutputFileName
87998             });
87999             afterProgramDone(state, projectPath, program, config);
88000             state.projectCompilerOptions = state.baseCompilerOptions;
88001             step = Step.QueueReferencingProjects;
88002             buildResult = resultFlags;
88003             return emitDiagnostics;
88004         }
88005         function emitBundle(writeFileCallback, customTransformers) {
88006             ts.Debug.assert(kind === InvalidatedProjectKind.UpdateBundle);
88007             if (state.options.dry) {
88008                 reportStatus(state, ts.Diagnostics.A_non_dry_build_would_update_output_of_project_0, project);
88009                 buildResult = BuildResultFlags.Success;
88010                 step = Step.QueueReferencingProjects;
88011                 return undefined;
88012             }
88013             if (state.options.verbose)
88014                 reportStatus(state, ts.Diagnostics.Updating_output_of_project_0, project);
88015             var compilerHost = state.compilerHost;
88016             state.projectCompilerOptions = config.options;
88017             var outputFiles = ts.emitUsingBuildInfo(config, compilerHost, function (ref) {
88018                 var refName = resolveProjectName(state, ref.path);
88019                 return parseConfigFile(state, refName, toResolvedConfigFilePath(state, refName));
88020             }, customTransformers);
88021             if (ts.isString(outputFiles)) {
88022                 reportStatus(state, ts.Diagnostics.Cannot_update_output_of_project_0_because_there_was_error_reading_file_1, project, relName(state, outputFiles));
88023                 step = Step.BuildInvalidatedProjectOfBundle;
88024                 return invalidatedProjectOfBundle = createBuildOrUpdateInvalidedProject(InvalidatedProjectKind.Build, state, project, projectPath, projectIndex, config, buildOrder);
88025             }
88026             ts.Debug.assert(!!outputFiles.length);
88027             var emitterDiagnostics = ts.createDiagnosticCollection();
88028             var emittedOutputs = ts.createMap();
88029             outputFiles.forEach(function (_a) {
88030                 var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
88031                 emittedOutputs.set(toPath(state, name), name);
88032                 ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
88033             });
88034             var emitDiagnostics = finishEmit(emitterDiagnostics, emittedOutputs, minimumDate, false, outputFiles[0].name, BuildResultFlags.DeclarationOutputUnchanged);
88035             return { emitSkipped: false, diagnostics: emitDiagnostics };
88036         }
88037         function executeSteps(till, cancellationToken, writeFile, customTransformers) {
88038             while (step <= till && step < Step.Done) {
88039                 var currentStep = step;
88040                 switch (step) {
88041                     case Step.CreateProgram:
88042                         createProgram();
88043                         break;
88044                     case Step.SyntaxDiagnostics:
88045                         getSyntaxDiagnostics(cancellationToken);
88046                         break;
88047                     case Step.SemanticDiagnostics:
88048                         getSemanticDiagnostics(cancellationToken);
88049                         break;
88050                     case Step.Emit:
88051                         emit(writeFile, cancellationToken, customTransformers);
88052                         break;
88053                     case Step.EmitBundle:
88054                         emitBundle(writeFile, customTransformers);
88055                         break;
88056                     case Step.BuildInvalidatedProjectOfBundle:
88057                         ts.Debug.checkDefined(invalidatedProjectOfBundle).done(cancellationToken);
88058                         step = Step.Done;
88059                         break;
88060                     case Step.QueueReferencingProjects:
88061                         queueReferencingProjects(state, project, projectPath, projectIndex, config, buildOrder, ts.Debug.checkDefined(buildResult));
88062                         step++;
88063                         break;
88064                     case Step.Done:
88065                     default:
88066                         ts.assertType(step);
88067                 }
88068                 ts.Debug.assert(step > currentStep);
88069             }
88070         }
88071     }
88072     function needsBuild(_a, status, config) {
88073         var options = _a.options;
88074         if (status.type !== ts.UpToDateStatusType.OutOfDateWithPrepend || options.force)
88075             return true;
88076         return config.fileNames.length === 0 ||
88077             !!ts.getConfigFileParsingDiagnostics(config).length ||
88078             !ts.isIncrementalCompilation(config.options);
88079     }
88080     function getNextInvalidatedProject(state, buildOrder, reportQueue) {
88081         if (!state.projectPendingBuild.size)
88082             return undefined;
88083         if (isCircularBuildOrder(buildOrder))
88084             return undefined;
88085         if (state.currentInvalidatedProject) {
88086             return ts.arrayIsEqualTo(state.currentInvalidatedProject.buildOrder, buildOrder) ?
88087                 state.currentInvalidatedProject :
88088                 undefined;
88089         }
88090         var options = state.options, projectPendingBuild = state.projectPendingBuild;
88091         for (var projectIndex = 0; projectIndex < buildOrder.length; projectIndex++) {
88092             var project = buildOrder[projectIndex];
88093             var projectPath = toResolvedConfigFilePath(state, project);
88094             var reloadLevel = state.projectPendingBuild.get(projectPath);
88095             if (reloadLevel === undefined)
88096                 continue;
88097             if (reportQueue) {
88098                 reportQueue = false;
88099                 reportBuildQueue(state, buildOrder);
88100             }
88101             var config = parseConfigFile(state, project, projectPath);
88102             if (!config) {
88103                 reportParseConfigFileDiagnostic(state, projectPath);
88104                 projectPendingBuild.delete(projectPath);
88105                 continue;
88106             }
88107             if (reloadLevel === ts.ConfigFileProgramReloadLevel.Full) {
88108                 watchConfigFile(state, project, projectPath, config);
88109                 watchWildCardDirectories(state, project, projectPath, config);
88110                 watchInputFiles(state, project, projectPath, config);
88111             }
88112             else if (reloadLevel === ts.ConfigFileProgramReloadLevel.Partial) {
88113                 var result = ts.getFileNamesFromConfigSpecs(config.configFileSpecs, ts.getDirectoryPath(project), config.options, state.parseConfigFileHost);
88114                 ts.updateErrorForNoInputFiles(result, project, config.configFileSpecs, config.errors, ts.canJsonReportNoInutFiles(config.raw));
88115                 config.fileNames = result.fileNames;
88116                 watchInputFiles(state, project, projectPath, config);
88117             }
88118             var status = getUpToDateStatus(state, config, projectPath);
88119             verboseReportProjectStatus(state, project, status);
88120             if (!options.force) {
88121                 if (status.type === ts.UpToDateStatusType.UpToDate) {
88122                     reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
88123                     projectPendingBuild.delete(projectPath);
88124                     if (options.dry) {
88125                         reportStatus(state, ts.Diagnostics.Project_0_is_up_to_date, project);
88126                     }
88127                     continue;
88128                 }
88129                 if (status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes) {
88130                     reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
88131                     return createUpdateOutputFileStampsProject(state, project, projectPath, config, buildOrder);
88132                 }
88133             }
88134             if (status.type === ts.UpToDateStatusType.UpstreamBlocked) {
88135                 reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
88136                 projectPendingBuild.delete(projectPath);
88137                 if (options.verbose) {
88138                     reportStatus(state, status.upstreamProjectBlocked ?
88139                         ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_was_not_built :
88140                         ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName);
88141                 }
88142                 continue;
88143             }
88144             if (status.type === ts.UpToDateStatusType.ContainerOnly) {
88145                 reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
88146                 projectPendingBuild.delete(projectPath);
88147                 continue;
88148             }
88149             return createBuildOrUpdateInvalidedProject(needsBuild(state, status, config) ?
88150                 InvalidatedProjectKind.Build :
88151                 InvalidatedProjectKind.UpdateBundle, state, project, projectPath, projectIndex, config, buildOrder);
88152         }
88153         return undefined;
88154     }
88155     function listEmittedFile(_a, proj, file) {
88156         var writeFileName = _a.writeFileName;
88157         if (writeFileName && proj.options.listEmittedFiles) {
88158             writeFileName("TSFILE: " + file);
88159         }
88160     }
88161     function getOldProgram(_a, proj, parsed) {
88162         var options = _a.options, builderPrograms = _a.builderPrograms, compilerHost = _a.compilerHost;
88163         if (options.force)
88164             return undefined;
88165         var value = builderPrograms.get(proj);
88166         if (value)
88167             return value;
88168         return ts.readBuilderProgram(parsed.options, compilerHost);
88169     }
88170     function afterProgramDone(_a, proj, program, config) {
88171         var host = _a.host, watch = _a.watch, builderPrograms = _a.builderPrograms;
88172         if (program) {
88173             if (host.afterProgramEmitAndDiagnostics) {
88174                 host.afterProgramEmitAndDiagnostics(program);
88175             }
88176             if (watch) {
88177                 program.releaseProgram();
88178                 builderPrograms.set(proj, program);
88179             }
88180         }
88181         else if (host.afterEmitBundle) {
88182             host.afterEmitBundle(config);
88183         }
88184     }
88185     function buildErrors(state, resolvedPath, program, config, diagnostics, errorFlags, errorType) {
88186         reportAndStoreErrors(state, resolvedPath, diagnostics);
88187         if (program && state.writeFileName)
88188             ts.listFiles(program, state.writeFileName);
88189         state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: errorType + " errors" });
88190         afterProgramDone(state, resolvedPath, program, config);
88191         state.projectCompilerOptions = state.baseCompilerOptions;
88192         return errorFlags;
88193     }
88194     function updateModuleResolutionCache(state, proj, config) {
88195         if (!state.moduleResolutionCache)
88196             return;
88197         var moduleResolutionCache = state.moduleResolutionCache;
88198         var projPath = toPath(state, proj);
88199         if (moduleResolutionCache.directoryToModuleNameMap.redirectsMap.size === 0) {
88200             ts.Debug.assert(moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.size === 0);
88201             moduleResolutionCache.directoryToModuleNameMap.redirectsMap.set(projPath, moduleResolutionCache.directoryToModuleNameMap.ownMap);
88202             moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.set(projPath, moduleResolutionCache.moduleNameToDirectoryMap.ownMap);
88203         }
88204         else {
88205             ts.Debug.assert(moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.size > 0);
88206             var ref = {
88207                 sourceFile: config.options.configFile,
88208                 commandLine: config
88209             };
88210             moduleResolutionCache.directoryToModuleNameMap.setOwnMap(moduleResolutionCache.directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref));
88211             moduleResolutionCache.moduleNameToDirectoryMap.setOwnMap(moduleResolutionCache.moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref));
88212         }
88213         moduleResolutionCache.directoryToModuleNameMap.setOwnOptions(config.options);
88214         moduleResolutionCache.moduleNameToDirectoryMap.setOwnOptions(config.options);
88215     }
88216     function checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName) {
88217         var tsconfigTime = state.host.getModifiedTime(configFile) || ts.missingFileModifiedTime;
88218         if (oldestOutputFileTime < tsconfigTime) {
88219             return {
88220                 type: ts.UpToDateStatusType.OutOfDateWithSelf,
88221                 outOfDateOutputFileName: oldestOutputFileName,
88222                 newerInputFileName: configFile
88223             };
88224         }
88225     }
88226     function getUpToDateStatusWorker(state, project, resolvedPath) {
88227         var newestInputFileName = undefined;
88228         var newestInputFileTime = minimumDate;
88229         var host = state.host;
88230         for (var _i = 0, _a = project.fileNames; _i < _a.length; _i++) {
88231             var inputFile = _a[_i];
88232             if (!host.fileExists(inputFile)) {
88233                 return {
88234                     type: ts.UpToDateStatusType.Unbuildable,
88235                     reason: inputFile + " does not exist"
88236                 };
88237             }
88238             var inputTime = host.getModifiedTime(inputFile) || ts.missingFileModifiedTime;
88239             if (inputTime > newestInputFileTime) {
88240                 newestInputFileName = inputFile;
88241                 newestInputFileTime = inputTime;
88242             }
88243         }
88244         if (!project.fileNames.length && !ts.canJsonReportNoInutFiles(project.raw)) {
88245             return {
88246                 type: ts.UpToDateStatusType.ContainerOnly
88247             };
88248         }
88249         var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames());
88250         var oldestOutputFileName = "(none)";
88251         var oldestOutputFileTime = maximumDate;
88252         var newestOutputFileName = "(none)";
88253         var newestOutputFileTime = minimumDate;
88254         var missingOutputFileName;
88255         var newestDeclarationFileContentChangedTime = minimumDate;
88256         var isOutOfDateWithInputs = false;
88257         for (var _b = 0, outputs_1 = outputs; _b < outputs_1.length; _b++) {
88258             var output = outputs_1[_b];
88259             if (!host.fileExists(output)) {
88260                 missingOutputFileName = output;
88261                 break;
88262             }
88263             var outputTime = host.getModifiedTime(output) || ts.missingFileModifiedTime;
88264             if (outputTime < oldestOutputFileTime) {
88265                 oldestOutputFileTime = outputTime;
88266                 oldestOutputFileName = output;
88267             }
88268             if (outputTime < newestInputFileTime) {
88269                 isOutOfDateWithInputs = true;
88270                 break;
88271             }
88272             if (outputTime > newestOutputFileTime) {
88273                 newestOutputFileTime = outputTime;
88274                 newestOutputFileName = output;
88275             }
88276             if (isDeclarationFile(output)) {
88277                 var outputModifiedTime = host.getModifiedTime(output) || ts.missingFileModifiedTime;
88278                 newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime);
88279             }
88280         }
88281         var pseudoUpToDate = false;
88282         var usesPrepend = false;
88283         var upstreamChangedProject;
88284         if (project.projectReferences) {
88285             state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.ComputingUpstream });
88286             for (var _c = 0, _d = project.projectReferences; _c < _d.length; _c++) {
88287                 var ref = _d[_c];
88288                 usesPrepend = usesPrepend || !!(ref.prepend);
88289                 var resolvedRef = ts.resolveProjectReferencePath(ref);
88290                 var resolvedRefPath = toResolvedConfigFilePath(state, resolvedRef);
88291                 var refStatus = getUpToDateStatus(state, parseConfigFile(state, resolvedRef, resolvedRefPath), resolvedRefPath);
88292                 if (refStatus.type === ts.UpToDateStatusType.ComputingUpstream ||
88293                     refStatus.type === ts.UpToDateStatusType.ContainerOnly) {
88294                     continue;
88295                 }
88296                 if (refStatus.type === ts.UpToDateStatusType.Unbuildable ||
88297                     refStatus.type === ts.UpToDateStatusType.UpstreamBlocked) {
88298                     return {
88299                         type: ts.UpToDateStatusType.UpstreamBlocked,
88300                         upstreamProjectName: ref.path,
88301                         upstreamProjectBlocked: refStatus.type === ts.UpToDateStatusType.UpstreamBlocked
88302                     };
88303                 }
88304                 if (refStatus.type !== ts.UpToDateStatusType.UpToDate) {
88305                     return {
88306                         type: ts.UpToDateStatusType.UpstreamOutOfDate,
88307                         upstreamProjectName: ref.path
88308                     };
88309                 }
88310                 if (!missingOutputFileName) {
88311                     if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) {
88312                         continue;
88313                     }
88314                     if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
88315                         pseudoUpToDate = true;
88316                         upstreamChangedProject = ref.path;
88317                         continue;
88318                     }
88319                     ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here");
88320                     return {
88321                         type: ts.UpToDateStatusType.OutOfDateWithUpstream,
88322                         outOfDateOutputFileName: oldestOutputFileName,
88323                         newerProjectName: ref.path
88324                     };
88325                 }
88326             }
88327         }
88328         if (missingOutputFileName !== undefined) {
88329             return {
88330                 type: ts.UpToDateStatusType.OutputMissing,
88331                 missingOutputFileName: missingOutputFileName
88332             };
88333         }
88334         if (isOutOfDateWithInputs) {
88335             return {
88336                 type: ts.UpToDateStatusType.OutOfDateWithSelf,
88337                 outOfDateOutputFileName: oldestOutputFileName,
88338                 newerInputFileName: newestInputFileName
88339             };
88340         }
88341         else {
88342             var configStatus = checkConfigFileUpToDateStatus(state, project.options.configFilePath, oldestOutputFileTime, oldestOutputFileName);
88343             if (configStatus)
88344                 return configStatus;
88345             var extendedConfigStatus = ts.forEach(project.options.configFile.extendedSourceFiles || ts.emptyArray, function (configFile) { return checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName); });
88346             if (extendedConfigStatus)
88347                 return extendedConfigStatus;
88348         }
88349         if (!state.buildInfoChecked.has(resolvedPath)) {
88350             state.buildInfoChecked.set(resolvedPath, true);
88351             var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options);
88352             if (buildInfoPath) {
88353                 var value = state.readFileWithCache(buildInfoPath);
88354                 var buildInfo = value && ts.getBuildInfo(value);
88355                 if (buildInfo && (buildInfo.bundle || buildInfo.program) && buildInfo.version !== ts.version) {
88356                     return {
88357                         type: ts.UpToDateStatusType.TsVersionOutputOfDate,
88358                         version: buildInfo.version
88359                     };
88360                 }
88361             }
88362         }
88363         if (usesPrepend && pseudoUpToDate) {
88364             return {
88365                 type: ts.UpToDateStatusType.OutOfDateWithPrepend,
88366                 outOfDateOutputFileName: oldestOutputFileName,
88367                 newerProjectName: upstreamChangedProject
88368             };
88369         }
88370         return {
88371             type: pseudoUpToDate ? ts.UpToDateStatusType.UpToDateWithUpstreamTypes : ts.UpToDateStatusType.UpToDate,
88372             newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime,
88373             newestInputFileTime: newestInputFileTime,
88374             newestOutputFileTime: newestOutputFileTime,
88375             newestInputFileName: newestInputFileName,
88376             newestOutputFileName: newestOutputFileName,
88377             oldestOutputFileName: oldestOutputFileName
88378         };
88379     }
88380     function getUpToDateStatus(state, project, resolvedPath) {
88381         if (project === undefined) {
88382             return { type: ts.UpToDateStatusType.Unbuildable, reason: "File deleted mid-build" };
88383         }
88384         var prior = state.projectStatus.get(resolvedPath);
88385         if (prior !== undefined) {
88386             return prior;
88387         }
88388         var actual = getUpToDateStatusWorker(state, project, resolvedPath);
88389         state.projectStatus.set(resolvedPath, actual);
88390         return actual;
88391     }
88392     function updateOutputTimestampsWorker(state, proj, priorNewestUpdateTime, verboseMessage, skipOutputs) {
88393         var host = state.host;
88394         var outputs = ts.getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames());
88395         if (!skipOutputs || outputs.length !== skipOutputs.size) {
88396             var reportVerbose = !!state.options.verbose;
88397             var now = host.now ? host.now() : new Date();
88398             for (var _i = 0, outputs_2 = outputs; _i < outputs_2.length; _i++) {
88399                 var file = outputs_2[_i];
88400                 if (skipOutputs && skipOutputs.has(toPath(state, file))) {
88401                     continue;
88402                 }
88403                 if (reportVerbose) {
88404                     reportVerbose = false;
88405                     reportStatus(state, verboseMessage, proj.options.configFilePath);
88406                 }
88407                 if (isDeclarationFile(file)) {
88408                     priorNewestUpdateTime = newer(priorNewestUpdateTime, host.getModifiedTime(file) || ts.missingFileModifiedTime);
88409                 }
88410                 host.setModifiedTime(file, now);
88411             }
88412         }
88413         return priorNewestUpdateTime;
88414     }
88415     function updateOutputTimestamps(state, proj, resolvedPath) {
88416         if (state.options.dry) {
88417             return reportStatus(state, ts.Diagnostics.A_non_dry_build_would_update_timestamps_for_output_of_project_0, proj.options.configFilePath);
88418         }
88419         var priorNewestUpdateTime = updateOutputTimestampsWorker(state, proj, minimumDate, ts.Diagnostics.Updating_output_timestamps_of_project_0);
88420         state.projectStatus.set(resolvedPath, {
88421             type: ts.UpToDateStatusType.UpToDate,
88422             newestDeclarationFileContentChangedTime: priorNewestUpdateTime,
88423             oldestOutputFileName: ts.getFirstProjectOutput(proj, !state.host.useCaseSensitiveFileNames())
88424         });
88425     }
88426     function queueReferencingProjects(state, project, projectPath, projectIndex, config, buildOrder, buildResult) {
88427         if (buildResult & BuildResultFlags.AnyErrors)
88428             return;
88429         if (!config.options.composite)
88430             return;
88431         for (var index = projectIndex + 1; index < buildOrder.length; index++) {
88432             var nextProject = buildOrder[index];
88433             var nextProjectPath = toResolvedConfigFilePath(state, nextProject);
88434             if (state.projectPendingBuild.has(nextProjectPath))
88435                 continue;
88436             var nextProjectConfig = parseConfigFile(state, nextProject, nextProjectPath);
88437             if (!nextProjectConfig || !nextProjectConfig.projectReferences)
88438                 continue;
88439             for (var _i = 0, _a = nextProjectConfig.projectReferences; _i < _a.length; _i++) {
88440                 var ref = _a[_i];
88441                 var resolvedRefPath = resolveProjectName(state, ref.path);
88442                 if (toResolvedConfigFilePath(state, resolvedRefPath) !== projectPath)
88443                     continue;
88444                 var status = state.projectStatus.get(nextProjectPath);
88445                 if (status) {
88446                     switch (status.type) {
88447                         case ts.UpToDateStatusType.UpToDate:
88448                             if (buildResult & BuildResultFlags.DeclarationOutputUnchanged) {
88449                                 if (ref.prepend) {
88450                                     state.projectStatus.set(nextProjectPath, {
88451                                         type: ts.UpToDateStatusType.OutOfDateWithPrepend,
88452                                         outOfDateOutputFileName: status.oldestOutputFileName,
88453                                         newerProjectName: project
88454                                     });
88455                                 }
88456                                 else {
88457                                     status.type = ts.UpToDateStatusType.UpToDateWithUpstreamTypes;
88458                                 }
88459                                 break;
88460                             }
88461                         case ts.UpToDateStatusType.UpToDateWithUpstreamTypes:
88462                         case ts.UpToDateStatusType.OutOfDateWithPrepend:
88463                             if (!(buildResult & BuildResultFlags.DeclarationOutputUnchanged)) {
88464                                 state.projectStatus.set(nextProjectPath, {
88465                                     type: ts.UpToDateStatusType.OutOfDateWithUpstream,
88466                                     outOfDateOutputFileName: status.type === ts.UpToDateStatusType.OutOfDateWithPrepend ? status.outOfDateOutputFileName : status.oldestOutputFileName,
88467                                     newerProjectName: project
88468                                 });
88469                             }
88470                             break;
88471                         case ts.UpToDateStatusType.UpstreamBlocked:
88472                             if (toResolvedConfigFilePath(state, resolveProjectName(state, status.upstreamProjectName)) === projectPath) {
88473                                 clearProjectStatus(state, nextProjectPath);
88474                             }
88475                             break;
88476                     }
88477                 }
88478                 addProjToQueue(state, nextProjectPath, ts.ConfigFileProgramReloadLevel.None);
88479                 break;
88480             }
88481         }
88482     }
88483     function build(state, project, cancellationToken, onlyReferences) {
88484         var buildOrder = getBuildOrderFor(state, project, onlyReferences);
88485         if (!buildOrder)
88486             return ts.ExitStatus.InvalidProject_OutputsSkipped;
88487         setupInitialBuild(state, cancellationToken);
88488         var reportQueue = true;
88489         var successfulProjects = 0;
88490         while (true) {
88491             var invalidatedProject = getNextInvalidatedProject(state, buildOrder, reportQueue);
88492             if (!invalidatedProject)
88493                 break;
88494             reportQueue = false;
88495             invalidatedProject.done(cancellationToken);
88496             if (!state.diagnostics.has(invalidatedProject.projectPath))
88497                 successfulProjects++;
88498         }
88499         disableCache(state);
88500         reportErrorSummary(state, buildOrder);
88501         startWatching(state, buildOrder);
88502         return isCircularBuildOrder(buildOrder)
88503             ? ts.ExitStatus.ProjectReferenceCycle_OutputsSkipped
88504             : !buildOrder.some(function (p) { return state.diagnostics.has(toResolvedConfigFilePath(state, p)); })
88505                 ? ts.ExitStatus.Success
88506                 : successfulProjects
88507                     ? ts.ExitStatus.DiagnosticsPresent_OutputsGenerated
88508                     : ts.ExitStatus.DiagnosticsPresent_OutputsSkipped;
88509     }
88510     function clean(state, project, onlyReferences) {
88511         var buildOrder = getBuildOrderFor(state, project, onlyReferences);
88512         if (!buildOrder)
88513             return ts.ExitStatus.InvalidProject_OutputsSkipped;
88514         if (isCircularBuildOrder(buildOrder)) {
88515             reportErrors(state, buildOrder.circularDiagnostics);
88516             return ts.ExitStatus.ProjectReferenceCycle_OutputsSkipped;
88517         }
88518         var options = state.options, host = state.host;
88519         var filesToDelete = options.dry ? [] : undefined;
88520         for (var _i = 0, buildOrder_1 = buildOrder; _i < buildOrder_1.length; _i++) {
88521             var proj = buildOrder_1[_i];
88522             var resolvedPath = toResolvedConfigFilePath(state, proj);
88523             var parsed = parseConfigFile(state, proj, resolvedPath);
88524             if (parsed === undefined) {
88525                 reportParseConfigFileDiagnostic(state, resolvedPath);
88526                 continue;
88527             }
88528             var outputs = ts.getAllProjectOutputs(parsed, !host.useCaseSensitiveFileNames());
88529             for (var _a = 0, outputs_3 = outputs; _a < outputs_3.length; _a++) {
88530                 var output = outputs_3[_a];
88531                 if (host.fileExists(output)) {
88532                     if (filesToDelete) {
88533                         filesToDelete.push(output);
88534                     }
88535                     else {
88536                         host.deleteFile(output);
88537                         invalidateProject(state, resolvedPath, ts.ConfigFileProgramReloadLevel.None);
88538                     }
88539                 }
88540             }
88541         }
88542         if (filesToDelete) {
88543             reportStatus(state, ts.Diagnostics.A_non_dry_build_would_delete_the_following_files_Colon_0, filesToDelete.map(function (f) { return "\r\n * " + f; }).join(""));
88544         }
88545         return ts.ExitStatus.Success;
88546     }
88547     function invalidateProject(state, resolved, reloadLevel) {
88548         if (state.host.getParsedCommandLine && reloadLevel === ts.ConfigFileProgramReloadLevel.Partial) {
88549             reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
88550         }
88551         if (reloadLevel === ts.ConfigFileProgramReloadLevel.Full) {
88552             state.configFileCache.delete(resolved);
88553             state.buildOrder = undefined;
88554         }
88555         state.needsSummary = true;
88556         clearProjectStatus(state, resolved);
88557         addProjToQueue(state, resolved, reloadLevel);
88558         enableCache(state);
88559     }
88560     function invalidateProjectAndScheduleBuilds(state, resolvedPath, reloadLevel) {
88561         state.reportFileChangeDetected = true;
88562         invalidateProject(state, resolvedPath, reloadLevel);
88563         scheduleBuildInvalidatedProject(state);
88564     }
88565     function scheduleBuildInvalidatedProject(state) {
88566         var hostWithWatch = state.hostWithWatch;
88567         if (!hostWithWatch.setTimeout || !hostWithWatch.clearTimeout) {
88568             return;
88569         }
88570         if (state.timerToBuildInvalidatedProject) {
88571             hostWithWatch.clearTimeout(state.timerToBuildInvalidatedProject);
88572         }
88573         state.timerToBuildInvalidatedProject = hostWithWatch.setTimeout(buildNextInvalidatedProject, 250, state);
88574     }
88575     function buildNextInvalidatedProject(state) {
88576         state.timerToBuildInvalidatedProject = undefined;
88577         if (state.reportFileChangeDetected) {
88578             state.reportFileChangeDetected = false;
88579             state.projectErrorsReported.clear();
88580             reportWatchStatus(state, ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
88581         }
88582         var buildOrder = getBuildOrder(state);
88583         var invalidatedProject = getNextInvalidatedProject(state, buildOrder, false);
88584         if (invalidatedProject) {
88585             invalidatedProject.done();
88586             if (state.projectPendingBuild.size) {
88587                 if (state.watch && !state.timerToBuildInvalidatedProject) {
88588                     scheduleBuildInvalidatedProject(state);
88589                 }
88590                 return;
88591             }
88592         }
88593         disableCache(state);
88594         reportErrorSummary(state, buildOrder);
88595     }
88596     function watchConfigFile(state, resolved, resolvedPath, parsed) {
88597         if (!state.watch || state.allWatchedConfigFiles.has(resolvedPath))
88598             return;
88599         state.allWatchedConfigFiles.set(resolvedPath, state.watchFile(state.hostWithWatch, resolved, function () {
88600             invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Full);
88601         }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.ConfigFile, resolved));
88602     }
88603     function isSameFile(state, file1, file2) {
88604         return ts.comparePaths(file1, file2, state.currentDirectory, !state.host.useCaseSensitiveFileNames()) === 0;
88605     }
88606     function isOutputFile(state, fileName, configFile) {
88607         if (configFile.options.noEmit)
88608             return false;
88609         if (!ts.fileExtensionIs(fileName, ".d.ts") &&
88610             (ts.fileExtensionIs(fileName, ".ts") || ts.fileExtensionIs(fileName, ".tsx"))) {
88611             return false;
88612         }
88613         var out = configFile.options.outFile || configFile.options.out;
88614         if (out && (isSameFile(state, fileName, out) || isSameFile(state, fileName, ts.removeFileExtension(out) + ".d.ts"))) {
88615             return true;
88616         }
88617         if (configFile.options.declarationDir && ts.containsPath(configFile.options.declarationDir, fileName, state.currentDirectory, !state.host.useCaseSensitiveFileNames())) {
88618             return true;
88619         }
88620         if (configFile.options.outDir && ts.containsPath(configFile.options.outDir, fileName, state.currentDirectory, !state.host.useCaseSensitiveFileNames())) {
88621             return true;
88622         }
88623         return !ts.forEach(configFile.fileNames, function (inputFile) { return isSameFile(state, fileName, inputFile); });
88624     }
88625     function watchWildCardDirectories(state, resolved, resolvedPath, parsed) {
88626         if (!state.watch)
88627             return;
88628         ts.updateWatchingWildcardDirectories(getOrCreateValueMapFromConfigFileMap(state.allWatchedWildcardDirectories, resolvedPath), ts.createMapFromTemplate(parsed.configFileSpecs.wildcardDirectories), function (dir, flags) { return state.watchDirectory(state.hostWithWatch, dir, function (fileOrDirectory) {
88629             var fileOrDirectoryPath = toPath(state, fileOrDirectory);
88630             if (fileOrDirectoryPath !== toPath(state, dir) && ts.hasExtension(fileOrDirectoryPath) && !ts.isSupportedSourceFileName(fileOrDirectory, parsed.options)) {
88631                 state.writeLog("Project: " + resolved + " Detected file add/remove of non supported extension: " + fileOrDirectory);
88632                 return;
88633             }
88634             if (isOutputFile(state, fileOrDirectory, parsed)) {
88635                 state.writeLog(fileOrDirectory + " is output file");
88636                 return;
88637             }
88638             invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Partial);
88639         }, flags, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.WildcardDirectory, resolved); });
88640     }
88641     function watchInputFiles(state, resolved, resolvedPath, parsed) {
88642         if (!state.watch)
88643             return;
88644         ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedInputFiles, resolvedPath), ts.arrayToMap(parsed.fileNames, function (fileName) { return toPath(state, fileName); }), {
88645             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); },
88646             onDeleteValue: ts.closeFileWatcher,
88647         });
88648     }
88649     function startWatching(state, buildOrder) {
88650         if (!state.watchAllProjectsPending)
88651             return;
88652         state.watchAllProjectsPending = false;
88653         for (var _i = 0, _a = getBuildOrderFromAnyBuildOrder(buildOrder); _i < _a.length; _i++) {
88654             var resolved = _a[_i];
88655             var resolvedPath = toResolvedConfigFilePath(state, resolved);
88656             var cfg = parseConfigFile(state, resolved, resolvedPath);
88657             watchConfigFile(state, resolved, resolvedPath, cfg);
88658             if (cfg) {
88659                 watchWildCardDirectories(state, resolved, resolvedPath, cfg);
88660                 watchInputFiles(state, resolved, resolvedPath, cfg);
88661             }
88662         }
88663     }
88664     function stopWatching(state) {
88665         ts.clearMap(state.allWatchedConfigFiles, ts.closeFileWatcher);
88666         ts.clearMap(state.allWatchedWildcardDirectories, function (watchedWildcardDirectories) { return ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcherOf); });
88667         ts.clearMap(state.allWatchedInputFiles, function (watchedWildcardDirectories) { return ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcher); });
88668     }
88669     function createSolutionBuilderWorker(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions) {
88670         var state = createSolutionBuilderState(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions);
88671         return {
88672             build: function (project, cancellationToken) { return build(state, project, cancellationToken); },
88673             clean: function (project) { return clean(state, project); },
88674             buildReferences: function (project, cancellationToken) { return build(state, project, cancellationToken, true); },
88675             cleanReferences: function (project) { return clean(state, project, true); },
88676             getNextInvalidatedProject: function (cancellationToken) {
88677                 setupInitialBuild(state, cancellationToken);
88678                 return getNextInvalidatedProject(state, getBuildOrder(state), false);
88679             },
88680             getBuildOrder: function () { return getBuildOrder(state); },
88681             getUpToDateStatusOfProject: function (project) {
88682                 var configFileName = resolveProjectName(state, project);
88683                 var configFilePath = toResolvedConfigFilePath(state, configFileName);
88684                 return getUpToDateStatus(state, parseConfigFile(state, configFileName, configFilePath), configFilePath);
88685             },
88686             invalidateProject: function (configFilePath, reloadLevel) { return invalidateProject(state, configFilePath, reloadLevel || ts.ConfigFileProgramReloadLevel.None); },
88687             buildNextInvalidatedProject: function () { return buildNextInvalidatedProject(state); },
88688             getAllParsedConfigs: function () { return ts.arrayFrom(ts.mapDefinedIterator(state.configFileCache.values(), function (config) { return isParsedCommandLine(config) ? config : undefined; })); },
88689             close: function () { return stopWatching(state); },
88690         };
88691     }
88692     function relName(state, path) {
88693         return ts.convertToRelativePath(path, state.currentDirectory, function (f) { return state.getCanonicalFileName(f); });
88694     }
88695     function reportStatus(state, message) {
88696         var args = [];
88697         for (var _i = 2; _i < arguments.length; _i++) {
88698             args[_i - 2] = arguments[_i];
88699         }
88700         state.host.reportSolutionBuilderStatus(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)));
88701     }
88702     function reportWatchStatus(state, message) {
88703         var args = [];
88704         for (var _i = 2; _i < arguments.length; _i++) {
88705             args[_i - 2] = arguments[_i];
88706         }
88707         if (state.hostWithWatch.onWatchStatusChange) {
88708             state.hostWithWatch.onWatchStatusChange(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)), state.host.getNewLine(), state.baseCompilerOptions);
88709         }
88710     }
88711     function reportErrors(_a, errors) {
88712         var host = _a.host;
88713         errors.forEach(function (err) { return host.reportDiagnostic(err); });
88714     }
88715     function reportAndStoreErrors(state, proj, errors) {
88716         reportErrors(state, errors);
88717         state.projectErrorsReported.set(proj, true);
88718         if (errors.length) {
88719             state.diagnostics.set(proj, errors);
88720         }
88721     }
88722     function reportParseConfigFileDiagnostic(state, proj) {
88723         reportAndStoreErrors(state, proj, [state.configFileCache.get(proj)]);
88724     }
88725     function reportErrorSummary(state, buildOrder) {
88726         if (!state.needsSummary)
88727             return;
88728         state.needsSummary = false;
88729         var canReportSummary = state.watch || !!state.host.reportErrorSummary;
88730         var diagnostics = state.diagnostics;
88731         var totalErrors = 0;
88732         if (isCircularBuildOrder(buildOrder)) {
88733             reportBuildQueue(state, buildOrder.buildOrder);
88734             reportErrors(state, buildOrder.circularDiagnostics);
88735             if (canReportSummary)
88736                 totalErrors += ts.getErrorCountForSummary(buildOrder.circularDiagnostics);
88737         }
88738         else {
88739             buildOrder.forEach(function (project) {
88740                 var projectPath = toResolvedConfigFilePath(state, project);
88741                 if (!state.projectErrorsReported.has(projectPath)) {
88742                     reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray);
88743                 }
88744             });
88745             if (canReportSummary)
88746                 diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); });
88747         }
88748         if (state.watch) {
88749             reportWatchStatus(state, ts.getWatchErrorSummaryDiagnosticMessage(totalErrors), totalErrors);
88750         }
88751         else if (state.host.reportErrorSummary) {
88752             state.host.reportErrorSummary(totalErrors);
88753         }
88754     }
88755     function reportBuildQueue(state, buildQueue) {
88756         if (state.options.verbose) {
88757             reportStatus(state, ts.Diagnostics.Projects_in_this_build_Colon_0, buildQueue.map(function (s) { return "\r\n    * " + relName(state, s); }).join(""));
88758         }
88759     }
88760     function reportUpToDateStatus(state, configFileName, status) {
88761         switch (status.type) {
88762             case ts.UpToDateStatusType.OutOfDateWithSelf:
88763                 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));
88764             case ts.UpToDateStatusType.OutOfDateWithUpstream:
88765                 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));
88766             case ts.UpToDateStatusType.OutputMissing:
88767                 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));
88768             case ts.UpToDateStatusType.UpToDate:
88769                 if (status.newestInputFileTime !== undefined) {
88770                     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 || ""));
88771                 }
88772                 break;
88773             case ts.UpToDateStatusType.OutOfDateWithPrepend:
88774                 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));
88775             case ts.UpToDateStatusType.UpToDateWithUpstreamTypes:
88776                 return reportStatus(state, ts.Diagnostics.Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies, relName(state, configFileName));
88777             case ts.UpToDateStatusType.UpstreamOutOfDate:
88778                 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));
88779             case ts.UpToDateStatusType.UpstreamBlocked:
88780                 return reportStatus(state, status.upstreamProjectBlocked ?
88781                     ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_was_not_built :
88782                     ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName));
88783             case ts.UpToDateStatusType.Unbuildable:
88784                 return reportStatus(state, ts.Diagnostics.Failed_to_parse_file_0_Colon_1, relName(state, configFileName), status.reason);
88785             case ts.UpToDateStatusType.TsVersionOutputOfDate:
88786                 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);
88787             case ts.UpToDateStatusType.ContainerOnly:
88788             case ts.UpToDateStatusType.ComputingUpstream:
88789                 break;
88790             default:
88791                 ts.assertType(status);
88792         }
88793     }
88794     function verboseReportProjectStatus(state, configFileName, status) {
88795         if (state.options.verbose) {
88796             reportUpToDateStatus(state, configFileName, status);
88797         }
88798     }
88799 })(ts || (ts = {}));
88800 var ts;
88801 (function (ts) {
88802     function countLines(program) {
88803         var count = 0;
88804         ts.forEach(program.getSourceFiles(), function (file) {
88805             count += ts.getLineStarts(file).length;
88806         });
88807         return count;
88808     }
88809     function updateReportDiagnostic(sys, existing, options) {
88810         return shouldBePretty(sys, options) ?
88811             ts.createDiagnosticReporter(sys, true) :
88812             existing;
88813     }
88814     function defaultIsPretty(sys) {
88815         return !!sys.writeOutputIsTTY && sys.writeOutputIsTTY();
88816     }
88817     function shouldBePretty(sys, options) {
88818         if (!options || typeof options.pretty === "undefined") {
88819             return defaultIsPretty(sys);
88820         }
88821         return options.pretty;
88822     }
88823     function getOptionsForHelp(commandLine) {
88824         return !!commandLine.options.all ?
88825             ts.sort(ts.optionDeclarations, function (a, b) { return ts.compareStringsCaseInsensitive(a.name, b.name); }) :
88826             ts.filter(ts.optionDeclarations.slice(), function (v) { return !!v.showInSimplifiedHelpView; });
88827     }
88828     function printVersion(sys) {
88829         sys.write(ts.getDiagnosticText(ts.Diagnostics.Version_0, ts.version) + sys.newLine);
88830     }
88831     function printHelp(sys, optionsList, syntaxPrefix) {
88832         if (syntaxPrefix === void 0) { syntaxPrefix = ""; }
88833         var output = [];
88834         var syntaxLength = ts.getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, "").length;
88835         var examplesLength = ts.getDiagnosticText(ts.Diagnostics.Examples_Colon_0, "").length;
88836         var marginLength = Math.max(syntaxLength, examplesLength);
88837         var syntax = makePadding(marginLength - syntaxLength);
88838         syntax += "tsc " + syntaxPrefix + "[" + ts.getDiagnosticText(ts.Diagnostics.options) + "] [" + ts.getDiagnosticText(ts.Diagnostics.file) + "...]";
88839         output.push(ts.getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, syntax));
88840         output.push(sys.newLine + sys.newLine);
88841         var padding = makePadding(marginLength);
88842         output.push(ts.getDiagnosticText(ts.Diagnostics.Examples_Colon_0, makePadding(marginLength - examplesLength) + "tsc hello.ts") + sys.newLine);
88843         output.push(padding + "tsc --outFile file.js file.ts" + sys.newLine);
88844         output.push(padding + "tsc @args.txt" + sys.newLine);
88845         output.push(padding + "tsc --build tsconfig.json" + sys.newLine);
88846         output.push(sys.newLine);
88847         output.push(ts.getDiagnosticText(ts.Diagnostics.Options_Colon) + sys.newLine);
88848         marginLength = 0;
88849         var usageColumn = [];
88850         var descriptionColumn = [];
88851         var optionsDescriptionMap = ts.createMap();
88852         for (var _i = 0, optionsList_1 = optionsList; _i < optionsList_1.length; _i++) {
88853             var option = optionsList_1[_i];
88854             if (!option.description) {
88855                 continue;
88856             }
88857             var usageText_1 = " ";
88858             if (option.shortName) {
88859                 usageText_1 += "-" + option.shortName;
88860                 usageText_1 += getParamType(option);
88861                 usageText_1 += ", ";
88862             }
88863             usageText_1 += "--" + option.name;
88864             usageText_1 += getParamType(option);
88865             usageColumn.push(usageText_1);
88866             var description = void 0;
88867             if (option.name === "lib") {
88868                 description = ts.getDiagnosticText(option.description);
88869                 var element = option.element;
88870                 var typeMap = element.type;
88871                 optionsDescriptionMap.set(description, ts.arrayFrom(typeMap.keys()).map(function (key) { return "'" + key + "'"; }));
88872             }
88873             else {
88874                 description = ts.getDiagnosticText(option.description);
88875             }
88876             descriptionColumn.push(description);
88877             marginLength = Math.max(usageText_1.length, marginLength);
88878         }
88879         var usageText = " @<" + ts.getDiagnosticText(ts.Diagnostics.file) + ">";
88880         usageColumn.push(usageText);
88881         descriptionColumn.push(ts.getDiagnosticText(ts.Diagnostics.Insert_command_line_options_and_files_from_a_file));
88882         marginLength = Math.max(usageText.length, marginLength);
88883         for (var i = 0; i < usageColumn.length; i++) {
88884             var usage = usageColumn[i];
88885             var description = descriptionColumn[i];
88886             var kindsList = optionsDescriptionMap.get(description);
88887             output.push(usage + makePadding(marginLength - usage.length + 2) + description + sys.newLine);
88888             if (kindsList) {
88889                 output.push(makePadding(marginLength + 4));
88890                 for (var _a = 0, kindsList_1 = kindsList; _a < kindsList_1.length; _a++) {
88891                     var kind = kindsList_1[_a];
88892                     output.push(kind + " ");
88893                 }
88894                 output.push(sys.newLine);
88895             }
88896         }
88897         for (var _b = 0, output_1 = output; _b < output_1.length; _b++) {
88898             var line = output_1[_b];
88899             sys.write(line);
88900         }
88901         return;
88902         function getParamType(option) {
88903             if (option.paramType !== undefined) {
88904                 return " " + ts.getDiagnosticText(option.paramType);
88905             }
88906             return "";
88907         }
88908         function makePadding(paddingLength) {
88909             return Array(paddingLength + 1).join(" ");
88910         }
88911     }
88912     function executeCommandLineWorker(sys, cb, commandLine) {
88913         var reportDiagnostic = ts.createDiagnosticReporter(sys);
88914         if (commandLine.options.build) {
88915             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Option_build_must_be_the_first_command_line_argument));
88916             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
88917         }
88918         var configFileName;
88919         if (commandLine.options.locale) {
88920             ts.validateLocaleAndSetLanguage(commandLine.options.locale, sys, commandLine.errors);
88921         }
88922         if (commandLine.errors.length > 0) {
88923             commandLine.errors.forEach(reportDiagnostic);
88924             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
88925         }
88926         if (commandLine.options.init) {
88927             writeConfigFile(sys, reportDiagnostic, commandLine.options, commandLine.fileNames);
88928             return sys.exit(ts.ExitStatus.Success);
88929         }
88930         if (commandLine.options.version) {
88931             printVersion(sys);
88932             return sys.exit(ts.ExitStatus.Success);
88933         }
88934         if (commandLine.options.help || commandLine.options.all) {
88935             printVersion(sys);
88936             printHelp(sys, getOptionsForHelp(commandLine));
88937             return sys.exit(ts.ExitStatus.Success);
88938         }
88939         if (commandLine.options.watch && commandLine.options.listFilesOnly) {
88940             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Options_0_and_1_cannot_be_combined, "watch", "listFilesOnly"));
88941             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
88942         }
88943         if (commandLine.options.project) {
88944             if (commandLine.fileNames.length !== 0) {
88945                 reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line));
88946                 return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
88947             }
88948             var fileOrDirectory = ts.normalizePath(commandLine.options.project);
88949             if (!fileOrDirectory || sys.directoryExists(fileOrDirectory)) {
88950                 configFileName = ts.combinePaths(fileOrDirectory, "tsconfig.json");
88951                 if (!sys.fileExists(configFileName)) {
88952                     reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0, commandLine.options.project));
88953                     return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
88954                 }
88955             }
88956             else {
88957                 configFileName = fileOrDirectory;
88958                 if (!sys.fileExists(configFileName)) {
88959                     reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_specified_path_does_not_exist_Colon_0, commandLine.options.project));
88960                     return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
88961                 }
88962             }
88963         }
88964         else if (commandLine.fileNames.length === 0) {
88965             var searchPath = ts.normalizePath(sys.getCurrentDirectory());
88966             configFileName = ts.findConfigFile(searchPath, function (fileName) { return sys.fileExists(fileName); });
88967         }
88968         if (commandLine.fileNames.length === 0 && !configFileName) {
88969             if (commandLine.options.showConfig) {
88970                 reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_a_tsconfig_json_file_at_the_current_directory_Colon_0, ts.normalizePath(sys.getCurrentDirectory())));
88971             }
88972             else {
88973                 printVersion(sys);
88974                 printHelp(sys, getOptionsForHelp(commandLine));
88975             }
88976             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
88977         }
88978         var currentDirectory = sys.getCurrentDirectory();
88979         var commandLineOptions = ts.convertToOptionsWithAbsolutePaths(commandLine.options, function (fileName) { return ts.getNormalizedAbsolutePath(fileName, currentDirectory); });
88980         if (configFileName) {
88981             var configParseResult = ts.parseConfigFileWithSystem(configFileName, commandLineOptions, commandLine.watchOptions, sys, reportDiagnostic);
88982             if (commandLineOptions.showConfig) {
88983                 if (configParseResult.errors.length !== 0) {
88984                     reportDiagnostic = updateReportDiagnostic(sys, reportDiagnostic, configParseResult.options);
88985                     configParseResult.errors.forEach(reportDiagnostic);
88986                     return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
88987                 }
88988                 sys.write(JSON.stringify(ts.convertToTSConfig(configParseResult, configFileName, sys), null, 4) + sys.newLine);
88989                 return sys.exit(ts.ExitStatus.Success);
88990             }
88991             reportDiagnostic = updateReportDiagnostic(sys, reportDiagnostic, configParseResult.options);
88992             if (ts.isWatchSet(configParseResult.options)) {
88993                 if (reportWatchModeWithoutSysSupport(sys, reportDiagnostic))
88994                     return;
88995                 return createWatchOfConfigFile(sys, cb, reportDiagnostic, configParseResult, commandLineOptions, commandLine.watchOptions);
88996             }
88997             else if (ts.isIncrementalCompilation(configParseResult.options)) {
88998                 performIncrementalCompilation(sys, cb, reportDiagnostic, configParseResult);
88999             }
89000             else {
89001                 performCompilation(sys, cb, reportDiagnostic, configParseResult);
89002             }
89003         }
89004         else {
89005             if (commandLineOptions.showConfig) {
89006                 sys.write(JSON.stringify(ts.convertToTSConfig(commandLine, ts.combinePaths(currentDirectory, "tsconfig.json"), sys), null, 4) + sys.newLine);
89007                 return sys.exit(ts.ExitStatus.Success);
89008             }
89009             reportDiagnostic = updateReportDiagnostic(sys, reportDiagnostic, commandLineOptions);
89010             if (ts.isWatchSet(commandLineOptions)) {
89011                 if (reportWatchModeWithoutSysSupport(sys, reportDiagnostic))
89012                     return;
89013                 return createWatchOfFilesAndCompilerOptions(sys, cb, reportDiagnostic, commandLine.fileNames, commandLineOptions, commandLine.watchOptions);
89014             }
89015             else if (ts.isIncrementalCompilation(commandLineOptions)) {
89016                 performIncrementalCompilation(sys, cb, reportDiagnostic, __assign(__assign({}, commandLine), { options: commandLineOptions }));
89017             }
89018             else {
89019                 performCompilation(sys, cb, reportDiagnostic, __assign(__assign({}, commandLine), { options: commandLineOptions }));
89020             }
89021         }
89022     }
89023     function isBuild(commandLineArgs) {
89024         if (commandLineArgs.length > 0 && commandLineArgs[0].charCodeAt(0) === 45) {
89025             var firstOption = commandLineArgs[0].slice(commandLineArgs[0].charCodeAt(1) === 45 ? 2 : 1).toLowerCase();
89026             return firstOption === "build" || firstOption === "b";
89027         }
89028         return false;
89029     }
89030     ts.isBuild = isBuild;
89031     function executeCommandLine(system, cb, commandLineArgs) {
89032         if (isBuild(commandLineArgs)) {
89033             var _a = ts.parseBuildCommand(commandLineArgs.slice(1)), buildOptions_1 = _a.buildOptions, watchOptions_1 = _a.watchOptions, projects_1 = _a.projects, errors_1 = _a.errors;
89034             if (buildOptions_1.generateCpuProfile && system.enableCPUProfiler) {
89035                 system.enableCPUProfiler(buildOptions_1.generateCpuProfile, function () { return performBuild(system, cb, buildOptions_1, watchOptions_1, projects_1, errors_1); });
89036             }
89037             else {
89038                 return performBuild(system, cb, buildOptions_1, watchOptions_1, projects_1, errors_1);
89039             }
89040         }
89041         var commandLine = ts.parseCommandLine(commandLineArgs, function (path) { return system.readFile(path); });
89042         if (commandLine.options.generateCpuProfile && system.enableCPUProfiler) {
89043             system.enableCPUProfiler(commandLine.options.generateCpuProfile, function () { return executeCommandLineWorker(system, cb, commandLine); });
89044         }
89045         else {
89046             return executeCommandLineWorker(system, cb, commandLine);
89047         }
89048     }
89049     ts.executeCommandLine = executeCommandLine;
89050     function reportWatchModeWithoutSysSupport(sys, reportDiagnostic) {
89051         if (!sys.watchFile || !sys.watchDirectory) {
89052             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"));
89053             sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
89054             return true;
89055         }
89056         return false;
89057     }
89058     function performBuild(sys, cb, buildOptions, watchOptions, projects, errors) {
89059         var reportDiagnostic = updateReportDiagnostic(sys, ts.createDiagnosticReporter(sys), buildOptions);
89060         if (buildOptions.locale) {
89061             ts.validateLocaleAndSetLanguage(buildOptions.locale, sys, errors);
89062         }
89063         if (errors.length > 0) {
89064             errors.forEach(reportDiagnostic);
89065             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
89066         }
89067         if (buildOptions.help) {
89068             printVersion(sys);
89069             printHelp(sys, ts.buildOpts, "--build ");
89070             return sys.exit(ts.ExitStatus.Success);
89071         }
89072         if (projects.length === 0) {
89073             printVersion(sys);
89074             printHelp(sys, ts.buildOpts, "--build ");
89075             return sys.exit(ts.ExitStatus.Success);
89076         }
89077         if (!sys.getModifiedTime || !sys.setModifiedTime || (buildOptions.clean && !sys.deleteFile)) {
89078             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--build"));
89079             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
89080         }
89081         if (buildOptions.watch) {
89082             if (reportWatchModeWithoutSysSupport(sys, reportDiagnostic))
89083                 return;
89084             var buildHost_1 = ts.createSolutionBuilderWithWatchHost(sys, undefined, reportDiagnostic, ts.createBuilderStatusReporter(sys, shouldBePretty(sys, buildOptions)), createWatchStatusReporter(sys, buildOptions));
89085             updateSolutionBuilderHost(sys, cb, buildHost_1);
89086             var builder_1 = ts.createSolutionBuilderWithWatch(buildHost_1, projects, buildOptions, watchOptions);
89087             builder_1.build();
89088             return builder_1;
89089         }
89090         var buildHost = ts.createSolutionBuilderHost(sys, undefined, reportDiagnostic, ts.createBuilderStatusReporter(sys, shouldBePretty(sys, buildOptions)), createReportErrorSummary(sys, buildOptions));
89091         updateSolutionBuilderHost(sys, cb, buildHost);
89092         var builder = ts.createSolutionBuilder(buildHost, projects, buildOptions);
89093         var exitStatus = buildOptions.clean ? builder.clean() : builder.build();
89094         return sys.exit(exitStatus);
89095     }
89096     function createReportErrorSummary(sys, options) {
89097         return shouldBePretty(sys, options) ?
89098             function (errorCount) { return sys.write(ts.getErrorSummaryText(errorCount, sys.newLine)); } :
89099             undefined;
89100     }
89101     function performCompilation(sys, cb, reportDiagnostic, config) {
89102         var fileNames = config.fileNames, options = config.options, projectReferences = config.projectReferences;
89103         var host = ts.createCompilerHostWorker(options, undefined, sys);
89104         var currentDirectory = host.getCurrentDirectory();
89105         var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
89106         ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, currentDirectory, getCanonicalFileName); });
89107         enableStatistics(sys, options);
89108         var programOptions = {
89109             rootNames: fileNames,
89110             options: options,
89111             projectReferences: projectReferences,
89112             host: host,
89113             configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics(config)
89114         };
89115         var program = ts.createProgram(programOptions);
89116         var exitStatus = ts.emitFilesAndReportErrorsAndGetExitStatus(program, reportDiagnostic, function (s) { return sys.write(s + sys.newLine); }, createReportErrorSummary(sys, options));
89117         reportStatistics(sys, program);
89118         cb(program);
89119         return sys.exit(exitStatus);
89120     }
89121     function performIncrementalCompilation(sys, cb, reportDiagnostic, config) {
89122         var options = config.options, fileNames = config.fileNames, projectReferences = config.projectReferences;
89123         enableStatistics(sys, options);
89124         var host = ts.createIncrementalCompilerHost(options, sys);
89125         var exitStatus = ts.performIncrementalCompilation({
89126             host: host,
89127             system: sys,
89128             rootNames: fileNames,
89129             options: options,
89130             configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics(config),
89131             projectReferences: projectReferences,
89132             reportDiagnostic: reportDiagnostic,
89133             reportErrorSummary: createReportErrorSummary(sys, options),
89134             afterProgramEmitAndDiagnostics: function (builderProgram) {
89135                 reportStatistics(sys, builderProgram.getProgram());
89136                 cb(builderProgram);
89137             }
89138         });
89139         return sys.exit(exitStatus);
89140     }
89141     function updateSolutionBuilderHost(sys, cb, buildHost) {
89142         updateCreateProgram(sys, buildHost);
89143         buildHost.afterProgramEmitAndDiagnostics = function (program) {
89144             reportStatistics(sys, program.getProgram());
89145             cb(program);
89146         };
89147         buildHost.afterEmitBundle = cb;
89148     }
89149     function updateCreateProgram(sys, host) {
89150         var compileUsingBuilder = host.createProgram;
89151         host.createProgram = function (rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences) {
89152             ts.Debug.assert(rootNames !== undefined || (options === undefined && !!oldProgram));
89153             if (options !== undefined) {
89154                 enableStatistics(sys, options);
89155             }
89156             return compileUsingBuilder(rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences);
89157         };
89158     }
89159     function updateWatchCompilationHost(sys, cb, watchCompilerHost) {
89160         updateCreateProgram(sys, watchCompilerHost);
89161         var emitFilesUsingBuilder = watchCompilerHost.afterProgramCreate;
89162         watchCompilerHost.afterProgramCreate = function (builderProgram) {
89163             emitFilesUsingBuilder(builderProgram);
89164             reportStatistics(sys, builderProgram.getProgram());
89165             cb(builderProgram);
89166         };
89167     }
89168     function createWatchStatusReporter(sys, options) {
89169         return ts.createWatchStatusReporter(sys, shouldBePretty(sys, options));
89170     }
89171     function createWatchOfConfigFile(system, cb, reportDiagnostic, configParseResult, optionsToExtend, watchOptionsToExtend) {
89172         var watchCompilerHost = ts.createWatchCompilerHostOfConfigFile({
89173             configFileName: configParseResult.options.configFilePath,
89174             optionsToExtend: optionsToExtend,
89175             watchOptionsToExtend: watchOptionsToExtend,
89176             system: system,
89177             reportDiagnostic: reportDiagnostic,
89178             reportWatchStatus: createWatchStatusReporter(system, configParseResult.options)
89179         });
89180         updateWatchCompilationHost(system, cb, watchCompilerHost);
89181         watchCompilerHost.configFileParsingResult = configParseResult;
89182         return ts.createWatchProgram(watchCompilerHost);
89183     }
89184     function createWatchOfFilesAndCompilerOptions(system, cb, reportDiagnostic, rootFiles, options, watchOptions) {
89185         var watchCompilerHost = ts.createWatchCompilerHostOfFilesAndCompilerOptions({
89186             rootFiles: rootFiles,
89187             options: options,
89188             watchOptions: watchOptions,
89189             system: system,
89190             reportDiagnostic: reportDiagnostic,
89191             reportWatchStatus: createWatchStatusReporter(system, options)
89192         });
89193         updateWatchCompilationHost(system, cb, watchCompilerHost);
89194         return ts.createWatchProgram(watchCompilerHost);
89195     }
89196     function canReportDiagnostics(system, compilerOptions) {
89197         return system === ts.sys && (compilerOptions.diagnostics || compilerOptions.extendedDiagnostics);
89198     }
89199     function enableStatistics(sys, compilerOptions) {
89200         if (canReportDiagnostics(sys, compilerOptions)) {
89201             ts.performance.enable();
89202         }
89203     }
89204     function reportStatistics(sys, program) {
89205         var statistics;
89206         var compilerOptions = program.getCompilerOptions();
89207         if (canReportDiagnostics(sys, compilerOptions)) {
89208             statistics = [];
89209             var memoryUsed = sys.getMemoryUsage ? sys.getMemoryUsage() : -1;
89210             reportCountStatistic("Files", program.getSourceFiles().length);
89211             reportCountStatistic("Lines", countLines(program));
89212             reportCountStatistic("Nodes", program.getNodeCount());
89213             reportCountStatistic("Identifiers", program.getIdentifierCount());
89214             reportCountStatistic("Symbols", program.getSymbolCount());
89215             reportCountStatistic("Types", program.getTypeCount());
89216             reportCountStatistic("Instantiations", program.getInstantiationCount());
89217             if (memoryUsed >= 0) {
89218                 reportStatisticalValue("Memory used", Math.round(memoryUsed / 1000) + "K");
89219             }
89220             var programTime = ts.performance.getDuration("Program");
89221             var bindTime = ts.performance.getDuration("Bind");
89222             var checkTime = ts.performance.getDuration("Check");
89223             var emitTime = ts.performance.getDuration("Emit");
89224             if (compilerOptions.extendedDiagnostics) {
89225                 var caches = program.getRelationCacheSizes();
89226                 reportCountStatistic("Assignability cache size", caches.assignable);
89227                 reportCountStatistic("Identity cache size", caches.identity);
89228                 reportCountStatistic("Subtype cache size", caches.subtype);
89229                 reportCountStatistic("Strict subtype cache size", caches.strictSubtype);
89230                 ts.performance.forEachMeasure(function (name, duration) { return reportTimeStatistic(name + " time", duration); });
89231             }
89232             else {
89233                 reportTimeStatistic("I/O read", ts.performance.getDuration("I/O Read"));
89234                 reportTimeStatistic("I/O write", ts.performance.getDuration("I/O Write"));
89235                 reportTimeStatistic("Parse time", programTime);
89236                 reportTimeStatistic("Bind time", bindTime);
89237                 reportTimeStatistic("Check time", checkTime);
89238                 reportTimeStatistic("Emit time", emitTime);
89239             }
89240             reportTimeStatistic("Total time", programTime + bindTime + checkTime + emitTime);
89241             reportStatistics();
89242             ts.performance.disable();
89243         }
89244         function reportStatistics() {
89245             var nameSize = 0;
89246             var valueSize = 0;
89247             for (var _i = 0, statistics_1 = statistics; _i < statistics_1.length; _i++) {
89248                 var _a = statistics_1[_i], name = _a.name, value = _a.value;
89249                 if (name.length > nameSize) {
89250                     nameSize = name.length;
89251                 }
89252                 if (value.length > valueSize) {
89253                     valueSize = value.length;
89254                 }
89255             }
89256             for (var _b = 0, statistics_2 = statistics; _b < statistics_2.length; _b++) {
89257                 var _c = statistics_2[_b], name = _c.name, value = _c.value;
89258                 sys.write(ts.padRight(name + ":", nameSize + 2) + ts.padLeft(value.toString(), valueSize) + sys.newLine);
89259             }
89260         }
89261         function reportStatisticalValue(name, value) {
89262             statistics.push({ name: name, value: value });
89263         }
89264         function reportCountStatistic(name, count) {
89265             reportStatisticalValue(name, "" + count);
89266         }
89267         function reportTimeStatistic(name, time) {
89268             reportStatisticalValue(name, (time / 1000).toFixed(2) + "s");
89269         }
89270     }
89271     function writeConfigFile(sys, reportDiagnostic, options, fileNames) {
89272         var currentDirectory = sys.getCurrentDirectory();
89273         var file = ts.normalizePath(ts.combinePaths(currentDirectory, "tsconfig.json"));
89274         if (sys.fileExists(file)) {
89275             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file));
89276         }
89277         else {
89278             sys.writeFile(file, ts.generateTSConfig(options, fileNames, sys.newLine));
89279             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Successfully_created_a_tsconfig_json_file));
89280         }
89281         return;
89282     }
89283 })(ts || (ts = {}));
89284 // This file actually uses arguments passed on commandline and executes it
89285 if (ts.Debug.isDebugging) {
89286     ts.Debug.enableDebugInfo();
89287 }
89288 if (ts.sys.tryEnableSourceMapsForHost && /^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV"))) {
89289     ts.sys.tryEnableSourceMapsForHost();
89290 }
89291 if (ts.sys.setBlocking) {
89292     ts.sys.setBlocking();
89293 }
89294 ts.executeCommandLine(ts.sys, ts.noop, ts.sys.args);